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)) {