Skip to content

Commit

Permalink
🐛 fix: fix duplicate key value violates unique constraint "slug_user_…
Browse files Browse the repository at this point in the history
…id_unique" when create inbox session (lobehub#4596)
  • Loading branch information
arvinxx authored Nov 3, 2024
1 parent 46c5306 commit c5af96e
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/database/server/models/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,11 @@ export class SessionModel {
}

async createInbox() {
const item = await serverDB.query.sessions.findFirst({
where: and(eq(sessions.userId, this.userId), eq(sessions.slug, INBOX_SESSION_ID)),
});
if (item) return;

const serverAgentConfig = parseAgentConfig(appEnv.DEFAULT_AGENT_CONFIG) || {};

return await this.create({
Expand Down

0 comments on commit c5af96e

Please sign in to comment.