🐛 (wa) Fix WhatsApp session stuck if state object is empty
Closes #1513
This commit is contained in:
20
packages/bot-engine/queries/setIsReplyingInChatSession.ts
Normal file
20
packages/bot-engine/queries/setIsReplyingInChatSession.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import prisma from '@typebot.io/lib/prisma'
|
||||
|
||||
type Props = {
|
||||
existingSessionId: string | undefined
|
||||
newSessionId: string
|
||||
}
|
||||
export const setIsReplyingInChatSession = async ({
|
||||
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: {} },
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user