2024-04-18 09:38:22 +02:00
|
|
|
import prisma from '@typebot.io/lib/prisma'
|
|
|
|
|
|
|
|
|
|
type Props = {
|
|
|
|
|
existingSessionId: string | undefined
|
|
|
|
|
newSessionId: string
|
|
|
|
|
}
|
2024-05-15 17:47:38 +02:00
|
|
|
export const setIsReplyingInChatSession = async ({
|
2024-04-18 09:38:22 +02:00
|
|
|
existingSessionId,
|
|
|
|
|
newSessionId,
|
|
|
|
|
}: Props) => {
|
|
|
|
|
if (existingSessionId) {
|
|
|
|
|
return prisma.chatSession.updateMany({
|
|
|
|
|
where: { id: existingSessionId },
|
|
|
|
|
data: { isReplying: true },
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
return prisma.chatSession.createMany({
|
|
|
|
|
data: { id: newSessionId, isReplying: true, state: {} },
|
|
|
|
|
})
|
|
|
|
|
}
|