CognxSafeTrack
Claude Sonnet 4.6
refactor(worker): Sprint 2 β dead code removal and queue consolidation
37fb9ce Download scripts/db-ops/test_wa_send.ts from safetrack/edtech: direct link, hf CLI and curl.
- Browser
- Download file 1.84 kB
-
https://huggingface.co/spaces/safetrack/edtech/resolve/main/scripts/db-ops/test_wa_send.ts
- Command line
-
hf download hf://spaces/safetrack/edtech/scripts/db-ops/test_wa_send.ts
-
curl -L -o test_wa_send.ts https://huggingface.co/spaces/safetrack/edtech/resolve/main/scripts/db-ops/test_wa_send.ts
1.84 kB
| import 'dotenv/config'; | |
| import path from 'path'; | |
| import dotenv from 'dotenv'; | |
| dotenv.config({ path: path.join(__dirname, '../../../../.env') }); | |
| import { PrismaClient } from '@prisma/client'; | |
| import { decrypt } from '../../../packages/shared-types/src/crypto'; | |
| import axios from 'axios'; | |
| const prisma = new PrismaClient(); | |
| async function testSend() { | |
| const orgId = 'default-org-id'; | |
| const org = await prisma.organization.findUnique({ | |
| where: { id: orgId }, | |
| include: { phoneNumbers: true } | |
| }); | |
| if (!org || !org.systemUserToken || !org.phoneNumbers[0]) { | |
| console.log('β Org or token or phone missing'); | |
| return; | |
| } | |
| const encryptionSecret = process.env.ENCRYPTION_SECRET || ''; | |
| const decryptedToken = decrypt(org.systemUserToken, encryptionSecret); | |
| const phoneNumberId = org.phoneNumbers[0].id; | |
| console.log(`Testing send for Org: ${org.name}`); | |
| console.log(`Token starts with EAA: ${decryptedToken.startsWith('EAA')}`); | |
| console.log(`Phone Number ID: ${phoneNumberId}`); | |
| const url = `https://graph.facebook.com/v18.0/${phoneNumberId}/messages`; | |
| const payload = { | |
| messaging_product: 'whatsapp', | |
| recipient_type: 'individual', | |
| to: '221771234567', // Dummy number, just testing auth | |
| type: 'text', | |
| text: { body: 'Test Audit' } | |
| }; | |
| try { | |
| await axios.post(url, payload, { | |
| headers: { | |
| 'Authorization': `Bearer ${decryptedToken}`, | |
| 'Content-Type': 'application/json' | |
| } | |
| }); | |
| console.log('β Auth successful (Meta accepted the token, even if phone is dummy)'); | |
| } catch (err: any) { | |
| console.error('β Auth FAILED:', err.response?.data || err.message); | |
| } | |
| await prisma.$disconnect(); | |
| } | |
| testSend().catch(console.error); | |