| import 'dotenv/config'; | |
| import path from 'path'; | |
| import dotenv from 'dotenv'; | |
| dotenv.config({ path: path.join(__dirname, '../../../../.env') }); | |
| import { PrismaClient } from '@prisma/client'; | |
| const prisma = new PrismaClient(); | |
| async function fixProdToken() { | |
| const orgId = 'default-org-id'; | |
| const globalToken = process.env.WHATSAPP_ACCESS_TOKEN; | |
| if (!globalToken) { | |
| console.error('β Missing WHATSAPP_ACCESS_TOKEN in .env'); | |
| return; | |
| } | |
| // We set the token to RAW unencrypted text. | |
| // In production, the decrypt function will safely return it as-is. | |
| await prisma.organization.update({ | |
| where: { id: orgId }, | |
| data: { | |
| systemUserToken: globalToken | |
| } | |
| }); | |
| console.log(`β Restored systemUserToken for ${orgId} to RAW string.`); | |
| await prisma.$disconnect(); | |
| } | |
| fixProdToken().catch(console.error); | |