new(core.gbapp): New param for disabling welcome messages.

This commit is contained in:
Rodrigo Rodriguez 2020-04-03 00:17:21 -03:00
parent 9e15b03d04
commit 134cf31695

View file

@ -137,9 +137,11 @@ export class GBMinService {
res.end(); res.end();
return; // Exit here. return; // Exit here.
} }
let activeMin;
if (process.env.WHATSAPP_WELCOME_DISABLED !== "true") {
const toSwitchMin = GBServer.globals.minInstances.filter(p => p.botId === text)[0]; const toSwitchMin = GBServer.globals.minInstances.filter(p => p.botId === text)[0];
let activeMin = toSwitchMin ? toSwitchMin : GBServer.globals.minBoot; activeMin = toSwitchMin ? toSwitchMin : GBServer.globals.minBoot;
let sec = new SecService(); let sec = new SecService();
let user = await sec.getUserFromPhone(id); let user = await sec.getUserFromPhone(id);
@ -161,9 +163,14 @@ export class GBMinService {
(activeMin as any).whatsAppDirectLine.received(req, res); (activeMin as any).whatsAppDirectLine.received(req, res);
} }
} }
}
else {
(GBServer.globals.minBoot as any).whatsAppDirectLine.received(req, res);
}
} catch (error) { } catch (error) {
GBLog.error(`Error on Whatsapp callback: ${error.message}`); GBLog.error(`Error on Whatsapp callback: ${error.message}`);
} }
}); });
await Promise.all( await Promise.all(