feat: add options to handle whatsapp session on frontend

This commit is contained in:
canove
2020-10-27 16:08:50 -03:00
parent 73cb08a557
commit e573656276
11 changed files with 408 additions and 84 deletions

View File

@@ -1,10 +1,7 @@
import { Request, Response } from "express";
// import Whatsapp from "../models/Whatsapp";
// import { getIO } from "../libs/socket";
import { getWbot } from "../libs/wbot";
import ShowWhatsAppService from "../services/WhatsappService/ShowWhatsAppService";
import { StartWhatsAppSession } from "../services/WbotServices/StartWhatsAppSession";
// import wbotMonitor from "../services/wbotMonitor";
const store = async (req: Request, res: Response): Promise<Response> => {
const { whatsappId } = req.params;
@@ -15,6 +12,17 @@ const store = async (req: Request, res: Response): Promise<Response> => {
return res.status(200).json({ message: "Starting session." });
};
const update = async (req: Request, res: Response): Promise<Response> => {
const { whatsappId } = req.params;
const whatsapp = await ShowWhatsAppService(whatsappId);
await whatsapp.update({ session: "" });
StartWhatsAppSession(whatsapp);
return res.status(200).json({ message: "Starting session." });
};
const remove = async (req: Request, res: Response): Promise<Response> => {
const { whatsappId } = req.params;
const whatsapp = await ShowWhatsAppService(whatsappId);
@@ -26,4 +34,4 @@ const remove = async (req: Request, res: Response): Promise<Response> => {
return res.status(200).json({ message: "Session disconnected." });
};
export default { store, remove };
export default { store, remove, update };