mirror of
https://github.com/cheveguerra/whaticket-community.git
synced 2026-04-18 11:49:19 +00:00
Feat: Added import contacts function on frontend
This commit is contained in:
18
backend/src/controllers/ImportPhoneContactsController.js
Normal file
18
backend/src/controllers/ImportPhoneContactsController.js
Normal file
@@ -0,0 +1,18 @@
|
||||
const Contact = require("../models/Contact");
|
||||
const { getIO } = require("../libs/socket");
|
||||
const { getWbot, init } = require("../libs/wbot");
|
||||
|
||||
exports.store = async (req, res, next) => {
|
||||
const io = getIO();
|
||||
const wbot = getWbot();
|
||||
|
||||
const phoneContacts = await wbot.getContacts();
|
||||
|
||||
await Promise.all(
|
||||
phoneContacts.map(async ({ number, name }) => {
|
||||
await Contact.create({ number, name });
|
||||
})
|
||||
);
|
||||
|
||||
return res.status(200).json({ message: "contacts imported" });
|
||||
};
|
||||
Reference in New Issue
Block a user