feat: checking default whatsapp on import and create contacts

This commit is contained in:
canove
2020-09-06 14:31:53 -03:00
parent b793d28e60
commit fae02cf8e3
2 changed files with 24 additions and 2 deletions

View File

@@ -1,10 +1,21 @@
const Contact = require("../models/Contact");
const Whatsapp = require("../models/Whatsapp");
const { getIO } = require("../libs/socket");
const { getWbot, initWbot } = require("../libs/wbot");
exports.store = async (req, res, next) => {
const defaultWhatsapp = await Whatsapp.findOne({
where: { default: true },
});
if (!defaultWhatsapp) {
return res
.status(404)
.json({ error: "No default WhatsApp found. Check Connection page." });
}
const io = getIO();
const wbot = getWbot();
const wbot = getWbot(defaultWhatsapp);
let phoneContacts;