Skip to content

Commit

Permalink
🐛 fix: fix duplicate error when creating new user (lobehub#4554)
Browse files Browse the repository at this point in the history
  • Loading branch information
arvinxx authored Oct 30, 2024
1 parent 56727c0 commit fe47aae
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/database/server/models/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ export class UserNotFoundError extends TRPCError {

export class UserModel {
static createUser = async (params: NewUser) => {
// if user already exists, skip creation
if (params.id) {
const user = await serverDB.query.users.findFirst({ where: eq(users.id, params.id) });
if (!!user) return;
}

const [user] = await serverDB
.insert(users)
.values({ ...params })
Expand Down
2 changes: 1 addition & 1 deletion src/libs/langchain/loaders/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export class ChunkingLoader {

default: {
throw new Error(
'Unsupported file type, please check your file is a supported type, or just create an issue.',
`Unsupported file type [${type}], please check your file is supported, or create report issue here: https://github.com/lobehub/lobe-chat/discussions/3550`,
);
}
}
Expand Down

0 comments on commit fe47aae

Please sign in to comment.