mirror of
https://github.com/lobehub/lobe-chat.git
synced 2026-06-13 19:20:04 +00:00
🔥 refactor: remove invite code requirement feature (#12474)
This commit is contained in:
@@ -409,11 +409,6 @@
|
||||
"count": 1
|
||||
}
|
||||
},
|
||||
"src/server/routers/lambda/user.ts": {
|
||||
"sort-keys-fix/sort-keys-fix": {
|
||||
"count": 2
|
||||
}
|
||||
},
|
||||
"src/server/routers/tools/mcp.ts": {
|
||||
"sort-keys-fix/sort-keys-fix": {
|
||||
"count": 1
|
||||
|
||||
@@ -61,6 +61,12 @@ export default eslint(
|
||||
'react/no-unknown-property': 0,
|
||||
'regexp/match-any': 0,
|
||||
'unicorn/better-regex': 0,
|
||||
},
|
||||
},
|
||||
// TypeScript files - enforce consistent type imports
|
||||
{
|
||||
files: ['**/*.{ts,tsx}'],
|
||||
rules: {
|
||||
'@typescript-eslint/consistent-type-imports': [
|
||||
2,
|
||||
{
|
||||
@@ -76,6 +82,7 @@ export default eslint(
|
||||
rules: {
|
||||
...mdxFlat.rules,
|
||||
'@typescript-eslint/no-unused-vars': 1,
|
||||
'mdx/remark': 0,
|
||||
'no-undef': 0,
|
||||
'react/jsx-no-undef': 0,
|
||||
'react/no-unescaped-entities': 0,
|
||||
|
||||
@@ -9,18 +9,6 @@
|
||||
"import.importConfigFile.title": "Import Failed",
|
||||
"import.incompatible.description": "This file was exported from a higher version. Please try upgrading to the latest version and then re-importing.",
|
||||
"import.incompatible.title": "Current application does not support importing this file",
|
||||
"inviteCode.continue": "Continue",
|
||||
"inviteCode.currentEmail": "Current account: {{email}}",
|
||||
"inviteCode.desc": "An invite code is required to access LobeHub. Please enter a valid invite code to continue.",
|
||||
"inviteCode.friends": "Ask a friend",
|
||||
"inviteCode.joinUsOn": "Join us on",
|
||||
"inviteCode.lookingForInvite": "Looking for an invite?",
|
||||
"inviteCode.notYou": "Not you?",
|
||||
"inviteCode.openingInStages": "is opening in stages.",
|
||||
"inviteCode.placeholder": "Invite code or link",
|
||||
"inviteCode.pleaseEnterCode": "Enter your invite code to continue.",
|
||||
"inviteCode.switchAccount": "Switch account",
|
||||
"inviteCode.title": "You're Almost In",
|
||||
"loginRequired.desc": "You will be redirected to the login page shortly",
|
||||
"loginRequired.title": "Please log in to use this feature",
|
||||
"notFound.backHome": "Back to Home",
|
||||
|
||||
@@ -9,18 +9,6 @@
|
||||
"import.importConfigFile.title": "导入遇到了问题",
|
||||
"import.incompatible.description": "该文件由更高版本导出。请升级到最新版后再导入",
|
||||
"import.incompatible.title": "版本不兼容",
|
||||
"inviteCode.continue": "继续",
|
||||
"inviteCode.currentEmail": "当前账号:{{email}}",
|
||||
"inviteCode.desc": "需要邀请码才能访问 LobeHub。请输入有效的邀请码以继续。",
|
||||
"inviteCode.friends": "问问好友",
|
||||
"inviteCode.joinUsOn": "关注我们",
|
||||
"inviteCode.lookingForInvite": "需要邀请码?",
|
||||
"inviteCode.notYou": "不是你?",
|
||||
"inviteCode.openingInStages": "正在分阶段开放中。",
|
||||
"inviteCode.placeholder": "输入邀请码或链接",
|
||||
"inviteCode.pleaseEnterCode": "请输入邀请码以继续。",
|
||||
"inviteCode.switchAccount": "切换账号",
|
||||
"inviteCode.title": "即将完成",
|
||||
"loginRequired.desc": "将为你跳转到登录页。登录后即可继续",
|
||||
"loginRequired.title": "需要登录后继续",
|
||||
"notFound.backHome": "返回首页",
|
||||
|
||||
@@ -84,7 +84,6 @@ export interface UserInitializationState {
|
||||
hasConversation?: boolean;
|
||||
interests?: string[];
|
||||
isFreePlan?: boolean;
|
||||
isInviteCodeRequired?: boolean;
|
||||
/** @deprecated Use onboarding field instead */
|
||||
isOnboard?: boolean;
|
||||
lastName?: string;
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
#!/bin/bash
|
||||
set -o pipefail
|
||||
|
||||
eslint "{src,tests}/**/*.{js,jsx,ts,tsx}" --fix --concurrency=auto --prune-suppressions
|
||||
eslint "{src,tests}/**/*.{js,jsx,ts,tsx}" --concurrency=auto
|
||||
eslint src/ tests/ --fix --concurrency=auto --prune-suppressions
|
||||
eslint src/ tests/ --concurrency=auto
|
||||
@@ -10,10 +10,6 @@ export async function getSubscriptionPlan(userId: string): Promise<Plans> {
|
||||
return Plans.Free;
|
||||
}
|
||||
|
||||
export async function getIsInviteCodeRequired(userId: string): Promise<boolean> {
|
||||
return false;
|
||||
}
|
||||
|
||||
export async function initNewUserForBusiness(
|
||||
userId: string,
|
||||
createdAt: Date | null | undefined,
|
||||
|
||||
@@ -51,11 +51,6 @@ export const useDesktopUserStateRedirect = () => {
|
||||
|
||||
return useCallback(
|
||||
(state: UserInitializationState) => {
|
||||
if (state.isInviteCodeRequired === true) {
|
||||
void openExternalAndLogout('/invite-code');
|
||||
return;
|
||||
}
|
||||
|
||||
if (!getDesktopOnboardingCompleted()) return;
|
||||
// Desktop onboarding is handled by desktop-only flow.
|
||||
},
|
||||
@@ -67,21 +62,6 @@ export const useWebUserStateRedirect = () =>
|
||||
useCallback((state: UserInitializationState) => {
|
||||
const { pathname } = window.location;
|
||||
|
||||
if (state.isInviteCodeRequired === true) {
|
||||
redirectIfNotOn(pathname, '/invite-code');
|
||||
return;
|
||||
}
|
||||
|
||||
// Redirect away from invite-code page if no longer required
|
||||
// Skip redirect if force=true is present (for re-entering invite code)
|
||||
if (pathname.startsWith('/invite-code')) {
|
||||
const params = new URLSearchParams(window.location.search);
|
||||
if (params.get('force') !== 'true') {
|
||||
window.location.href = '/';
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!onboardingSelectors.needsOnboarding(state)) return;
|
||||
|
||||
redirectIfNotOn(pathname, '/onboarding');
|
||||
|
||||
@@ -10,19 +10,6 @@ export default {
|
||||
'import.incompatible.description':
|
||||
'This file was exported from a higher version. Please try upgrading to the latest version and then re-importing.',
|
||||
'import.incompatible.title': 'Current application does not support importing this file',
|
||||
'inviteCode.continue': 'Continue',
|
||||
'inviteCode.currentEmail': 'Current account: {{email}}',
|
||||
'inviteCode.desc':
|
||||
'An invite code is required to access LobeHub. Please enter a valid invite code to continue.',
|
||||
'inviteCode.friends': 'Ask a friend',
|
||||
'inviteCode.joinUsOn': 'Join us on',
|
||||
'inviteCode.lookingForInvite': 'Looking for an invite?',
|
||||
'inviteCode.notYou': 'Not you?',
|
||||
'inviteCode.openingInStages': 'is opening in stages.',
|
||||
'inviteCode.placeholder': 'Invite code or link',
|
||||
'inviteCode.pleaseEnterCode': 'Enter your invite code to continue.',
|
||||
'inviteCode.switchAccount': 'Switch account',
|
||||
'inviteCode.title': "You're Almost In",
|
||||
'loginRequired.desc': 'You will be redirected to the login page shortly',
|
||||
'loginRequired.title': 'Please log in to use this feature',
|
||||
'notFound.backHome': 'Back to Home',
|
||||
|
||||
@@ -16,11 +16,7 @@ import { after } from 'next/server';
|
||||
import { v4 as uuidv4 } from 'uuid';
|
||||
import { z } from 'zod';
|
||||
|
||||
import {
|
||||
getIsInviteCodeRequired,
|
||||
getReferralStatus,
|
||||
getSubscriptionPlan,
|
||||
} from '@/business/server/user';
|
||||
import { getReferralStatus, getSubscriptionPlan } from '@/business/server/user';
|
||||
import { MessageModel } from '@/database/models/message';
|
||||
import { SessionModel } from '@/database/models/session';
|
||||
import { UserModel } from '@/database/models/user';
|
||||
@@ -75,25 +71,17 @@ export const userRouter = router({
|
||||
}
|
||||
|
||||
// Run user state fetch and count queries in parallel
|
||||
const [
|
||||
state,
|
||||
messageCount,
|
||||
hasExtraSession,
|
||||
referralStatus,
|
||||
subscriptionPlan,
|
||||
isInviteCodeRequired,
|
||||
] = await Promise.all([
|
||||
ctx.userModel.getUserState(KeyVaultsGateKeeper.getUserKeyVaults),
|
||||
ctx.messageModel.countUpTo(5),
|
||||
ctx.sessionModel.hasMoreThanN(1),
|
||||
getReferralStatus(ctx.userId),
|
||||
getSubscriptionPlan(ctx.userId),
|
||||
getIsInviteCodeRequired(ctx.userId),
|
||||
]);
|
||||
const [state, messageCount, hasExtraSession, referralStatus, subscriptionPlan] =
|
||||
await Promise.all([
|
||||
ctx.userModel.getUserState(KeyVaultsGateKeeper.getUserKeyVaults),
|
||||
ctx.messageModel.countUpTo(5),
|
||||
ctx.sessionModel.hasMoreThanN(1),
|
||||
getReferralStatus(ctx.userId),
|
||||
getSubscriptionPlan(ctx.userId),
|
||||
]);
|
||||
|
||||
const hasMoreThan4Messages = messageCount > 4;
|
||||
const hasAnyMessages = messageCount > 0;
|
||||
/* eslint-disable sort-keys-fix/sort-keys-fix */
|
||||
return {
|
||||
avatar: state.avatar,
|
||||
canEnablePWAGuide: hasMoreThan4Messages,
|
||||
@@ -119,10 +107,8 @@ export const userRouter = router({
|
||||
// business features
|
||||
referralStatus,
|
||||
subscriptionPlan,
|
||||
isInviteCodeRequired,
|
||||
isFreePlan: !subscriptionPlan || subscriptionPlan === Plans.Free,
|
||||
} satisfies UserInitializationState;
|
||||
/* eslint-enable sort-keys-fix/sort-keys-fix */
|
||||
}),
|
||||
|
||||
makeUserOnboarded: userProcedure.mutation(async ({ ctx }) => {
|
||||
|
||||
Reference in New Issue
Block a user