feat: finished multiple whatsapps handle in frontend

This commit is contained in:
canove
2020-09-06 12:09:12 -03:00
parent f423dd60bc
commit b0f28c16ad
17 changed files with 595 additions and 511 deletions

View File

@@ -60,11 +60,11 @@ const startWhatsAppSessions = async () => {
const whatsapps = await Whatsapp.findAll();
if (whatsapps.length > 0) {
whatsapps.forEach(dbSession => {
initWbot(dbSession)
whatsapps.forEach(whatsapp => {
initWbot(whatsapp)
.then(() => {
wbotMessageListener(dbSession);
wbotMonitor(dbSession);
wbotMessageListener(whatsapp);
wbotMonitor(whatsapp);
})
.catch(err => console.log(err));
});
@@ -72,14 +72,6 @@ const startWhatsAppSessions = async () => {
};
startWhatsAppSessions();
// wBot
// .init()
// .then(({ dbSession }) => {
// wbotMessageListener();
// wbotMonitor(dbSession);
// })
// .catch(err => console.log(err));
app.use(Sentry.Handlers.errorHandler());
app.use(async (err, req, res, next) => {
@@ -88,5 +80,6 @@ app.use(async (err, req, res, next) => {
console.log(err);
return res.status(500).json(errors);
}
return res.status(500).json({ error: "Internal server error" });
});