🐛 (wa) Fix session stuck into reply state
This commit is contained in:
@@ -69,23 +69,25 @@ export const resumeWhatsAppFlow = async ({
|
|||||||
|
|
||||||
const session = await getSession(sessionId)
|
const session = await getSession(sessionId)
|
||||||
|
|
||||||
if (session?.isReplying) {
|
|
||||||
console.log('Is currently replying, skipping...')
|
|
||||||
return {
|
|
||||||
message: 'Message received',
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
await setIsReplyingInChatSession({
|
|
||||||
existingSessionId: session?.id,
|
|
||||||
newSessionId: sessionId,
|
|
||||||
})
|
|
||||||
|
|
||||||
const isSessionExpired =
|
const isSessionExpired =
|
||||||
session &&
|
session &&
|
||||||
isDefined(session.state.expiryTimeout) &&
|
isDefined(session.state.expiryTimeout) &&
|
||||||
session?.updatedAt.getTime() + session.state.expiryTimeout < Date.now()
|
session?.updatedAt.getTime() + session.state.expiryTimeout < Date.now()
|
||||||
|
|
||||||
|
if (session?.isReplying) {
|
||||||
|
if (!isSessionExpired) {
|
||||||
|
console.log('Is currently replying, skipping...')
|
||||||
|
return {
|
||||||
|
message: 'Message received',
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
await setIsReplyingInChatSession({
|
||||||
|
existingSessionId: session?.id,
|
||||||
|
newSessionId: sessionId,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
const resumeResponse =
|
const resumeResponse =
|
||||||
session && !isSessionExpired
|
session && !isSessionExpired
|
||||||
? await continueBotFlow(reply, {
|
? await continueBotFlow(reply, {
|
||||||
|
|||||||
Reference in New Issue
Block a user