<!-- This is an auto-generated comment: release notes by coderabbit.ai --> ### Summary by CodeRabbit - New Feature: Introduced session expiry timeout for WhatsApp integration, allowing users to set the duration after which a session expires. - New Feature: Added an option to enable/disable the start bot condition in WhatsApp integration settings. - Refactor: Enhanced error handling by throwing specific errors when necessary conditions are not met. - Refactor: Improved UI components like `NumberInput` and `SwitchWithLabel` for better usability. - Bug Fix: Fixed issues related to session resumption and message sending in expired sessions. Now, if a session is expired, a new one will be started instead of attempting to resume the old one. - Chore: Updated various schemas to reflect changes in session management and WhatsApp settings. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
12 lines
421 B
TypeScript
12 lines
421 B
TypeScript
import prisma from '@typebot.io/lib/prisma'
|
|
import { ChatSession, sessionStateSchema } from '@typebot.io/schemas'
|
|
|
|
export const getSession = async (sessionId: string) => {
|
|
const session = await prisma.chatSession.findUnique({
|
|
where: { id: sessionId },
|
|
select: { id: true, state: true, updatedAt: true },
|
|
})
|
|
if (!session) return null
|
|
return { ...session, state: sessionStateSchema.parse(session.state) }
|
|
}
|