From 51cfa56f856b5257e4802718d2ad01854504d3e8 Mon Sep 17 00:00:00 2001 From: Rodrigo Rodriguez Date: Sat, 10 Aug 2024 13:35:34 -0300 Subject: [PATCH] new(whatsapp.gblib): Auto-create WhatsApp templates from articles in .docx. --- .../whatsapp.gblib/services/WhatsappDirectLine.ts | 11 ++++++++--- src/app.ts | 7 ++----- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/packages/whatsapp.gblib/services/WhatsappDirectLine.ts b/packages/whatsapp.gblib/services/WhatsappDirectLine.ts index a8b97adc..29b2ced8 100644 --- a/packages/whatsapp.gblib/services/WhatsappDirectLine.ts +++ b/packages/whatsapp.gblib/services/WhatsappDirectLine.ts @@ -126,7 +126,12 @@ export class WhatsappDirectLine extends GBService { req.headers['Authorization'] = `Bearer ${this.min.instance.webchatKey}`; } }); + this.directLineClient = client; + + // Warms up MSBF. + + await client.apis.Conversations.Conversations_StartConversation(); let url: string; let options: any; @@ -617,7 +622,7 @@ export class WhatsappDirectLine extends GBService { } public pollMessages(client, conversationId, from, fromName) { - GBLogEx.info(this.min, `GBWhatsapp: Starting message polling(${from}, ${conversationId}).`); + GBLogEx.info(this.min, `GBWhatsapp: Starting timer of message polling(${from}, ${conversationId}).`); let watermark: any; @@ -630,7 +635,7 @@ export class WhatsappDirectLine extends GBService { watermark = response.obj.watermark; await this.printMessages(response.obj.activities, conversationId, from, fromName); } catch (error) { - GBLog.error(`Error calling printMessages on Whatsapp channel ${GBUtil.toYAML(error)}`); + GBLog.error(`Error pooling messages from Whatsapp channel ${GBUtil.toYAML(error)}`); } }; setInterval(worker, this.pollInterval); @@ -1199,7 +1204,7 @@ export class WhatsappDirectLine extends GBService { } else { let t; activeMin = GBServer.globals.minInstances.filter(p => p.instance.instanceId === user.instanceId)[0]; - if (activeMin === undefined) { + if (activeMin === undefined) { activeMin = GBServer.globals.minBoot; t = (activeMin as any).whatsAppDirectLine; await t.sendToDevice( diff --git a/src/app.ts b/src/app.ts index 2f0b7ca3..c01c293d 100644 --- a/src/app.ts +++ b/src/app.ts @@ -117,7 +117,7 @@ export class GBServer { }); process.on('uncaughtException', (err, p) => { - GBLogEx.error(0, `GBEXCEPTION: ${GBUtil.toYAML(err)}`); + GBLogEx.error(0, `GBEXCEPTION: ${GBUtil.toYAML(err)} ${GBUtil.toYAML(p)}`); }); process.on('unhandledRejection', (err, p) => { @@ -131,15 +131,12 @@ export class GBServer { } if(!bypass){ - GBLogEx.error(0,`GBREJECTION: ${GBUtil.toYAML(err)}`); + GBLogEx.error(0,`GBREJECTION: ${GBUtil.toYAML(err)} ${GBUtil.toYAML(p)}`); } }); // Creates working directory. - - - process.env.PWD = process.cwd(); const workDir = Path.join(process.env.PWD, 'work'); if (!fs.existsSync(workDir)) {