From c5af96e7092d8e7bedec4c248a2700c1747e4d02 Mon Sep 17 00:00:00 2001 From: Arvin Xu Date: Sun, 3 Nov 2024 20:40:14 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix:=20fix=20duplicate=20key=20v?= =?UTF-8?q?alue=20violates=20unique=20constraint=20"slug=5Fuser=5Fid=5Funi?= =?UTF-8?q?que"=20when=20create=20inbox=20session=20(#4596)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/database/server/models/session.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/database/server/models/session.ts b/src/database/server/models/session.ts index 4fb43b315a24..136104da2ead 100644 --- a/src/database/server/models/session.ts +++ b/src/database/server/models/session.ts @@ -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({