2
0

🔊 more

This commit is contained in:
Baptiste Arnaud
2024-04-17 11:20:58 +02:00
parent 0f1766f072
commit 7e1d5100dd

View File

@@ -46,6 +46,7 @@ export const resumeWhatsAppFlow = async ({
const isPreview = workspaceId === undefined || credentialsId === undefined const isPreview = workspaceId === undefined || credentialsId === undefined
console.log('get credentials', credentialsId)
const credentials = await getCredentials({ credentialsId, isPreview }) const credentials = await getCredentials({ credentialsId, isPreview })
console.log('credentials', isDefined(credentials)) console.log('credentials', isDefined(credentials))
@@ -198,6 +199,7 @@ const getCredentials = async ({
if (!credentialsId) return if (!credentialsId) return
console.log('prisma go')
const credentials = await prisma.credentials.findUnique({ const credentials = await prisma.credentials.findUnique({
where: { where: {
id: credentialsId, id: credentialsId,
@@ -207,11 +209,14 @@ const getCredentials = async ({
iv: true, iv: true,
}, },
}) })
console.log('prisma done')
if (!credentials) return if (!credentials) return
console.log('decrypt')
const data = (await decrypt( const data = (await decrypt(
credentials.data, credentials.data,
credentials.iv credentials.iv
)) as WhatsAppCredentials['data'] )) as WhatsAppCredentials['data']
console.log('decrypted')
return { return {
systemUserAccessToken: data.systemUserAccessToken, systemUserAccessToken: data.systemUserAccessToken,
phoneNumberId: data.phoneNumberId, phoneNumberId: data.phoneNumberId,