mirror of
https://github.com/sourcebot-dev/sourcebot.git
synced 2025-12-13 12:55:19 +00:00
fix
This commit is contained in:
parent
f1dd16be82
commit
3d88505257
3 changed files with 9 additions and 5 deletions
|
|
@ -0,0 +1,5 @@
|
||||||
|
-- Set all chats created by the guest user (id: 1) to have a NULL createdById.
|
||||||
|
UPDATE "Chat" SET "createdById" = NULL WHERE "createdById" = '1';
|
||||||
|
|
||||||
|
-- AlterTable
|
||||||
|
ALTER TABLE "Chat" ALTER COLUMN "createdById" DROP NOT NULL;
|
||||||
|
|
@ -437,8 +437,8 @@ model Chat {
|
||||||
|
|
||||||
name String?
|
name String?
|
||||||
|
|
||||||
createdBy User @relation(fields: [createdById], references: [id], onDelete: Cascade)
|
createdBy User? @relation(fields: [createdById], references: [id], onDelete: Cascade)
|
||||||
createdById String
|
createdById String?
|
||||||
|
|
||||||
createdAt DateTime @default(now())
|
createdAt DateTime @default(now())
|
||||||
updatedAt DateTime @updatedAt
|
updatedAt DateTime @updatedAt
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
'use server';
|
'use server';
|
||||||
|
|
||||||
import { sew } from "@/actions";
|
import { sew } from "@/actions";
|
||||||
import { SOURCEBOT_GUEST_USER_ID } from "@/lib/constants";
|
|
||||||
import { ErrorCode } from "@/lib/errorCodes";
|
import { ErrorCode } from "@/lib/errorCodes";
|
||||||
import { chatIsReadonly, notFound, ServiceError, serviceErrorResponse } from "@/lib/serviceError";
|
import { chatIsReadonly, notFound, ServiceError, serviceErrorResponse } from "@/lib/serviceError";
|
||||||
import { createAmazonBedrock } from '@ai-sdk/amazon-bedrock';
|
import { createAmazonBedrock } from '@ai-sdk/amazon-bedrock';
|
||||||
|
|
@ -34,13 +33,13 @@ const logger = createLogger('chat-actions');
|
||||||
|
|
||||||
export const createChat = async () => sew(() =>
|
export const createChat = async () => sew(() =>
|
||||||
withOptionalAuthV2(async ({ org, user, prisma }) => {
|
withOptionalAuthV2(async ({ org, user, prisma }) => {
|
||||||
const isGuestUser = user?.id === SOURCEBOT_GUEST_USER_ID;
|
const isGuestUser = user === undefined;
|
||||||
|
|
||||||
const chat = await prisma.chat.create({
|
const chat = await prisma.chat.create({
|
||||||
data: {
|
data: {
|
||||||
orgId: org.id,
|
orgId: org.id,
|
||||||
messages: [] as unknown as Prisma.InputJsonValue,
|
messages: [] as unknown as Prisma.InputJsonValue,
|
||||||
createdById: user?.id ?? SOURCEBOT_GUEST_USER_ID,
|
createdById: user?.id,
|
||||||
visibility: isGuestUser ? ChatVisibility.PUBLIC : ChatVisibility.PRIVATE,
|
visibility: isGuestUser ? ChatVisibility.PUBLIC : ChatVisibility.PRIVATE,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue