mirror of
https://github.com/cheveguerra/whaticket-community.git
synced 2026-04-19 04:09:26 +00:00
Migrate from moment to date-fns and some changes
This commit is contained in:
22
backend/src/controllers/whatsapp.js
Normal file
22
backend/src/controllers/whatsapp.js
Normal file
@@ -0,0 +1,22 @@
|
||||
const Whatsapp = require("../models/Whatsapp");
|
||||
const { getIO } = require("../libs/socket");
|
||||
const { getWbot, init } = require("./wbot");
|
||||
|
||||
exports.getSession = async (req, res, next) => {
|
||||
const dbSession = await Whatsapp.findOne({ where: { id: 1 } });
|
||||
|
||||
if (!dbSession) {
|
||||
return res.status(200).json({ message: "Session not found" });
|
||||
}
|
||||
|
||||
return res.status(200).json(dbSession);
|
||||
};
|
||||
|
||||
exports.getContacts = async (req, res, next) => {
|
||||
const io = getIO();
|
||||
const wbot = getWbot();
|
||||
|
||||
const phoneContacts = await wbot.getContacts();
|
||||
|
||||
return res.status(200).json(phoneContacts);
|
||||
};
|
||||
Reference in New Issue
Block a user