mirror of
https://github.com/cheveguerra/whaticket-community.git
synced 2026-04-18 19:59:20 +00:00
feat: add options to handle whatsapp session on frontend
This commit is contained in:
@@ -2,8 +2,6 @@ import { Request, Response } from "express";
|
||||
import { getIO } from "../libs/socket";
|
||||
import { removeWbot } from "../libs/wbot";
|
||||
import { StartWhatsAppSession } from "../services/WbotServices/StartWhatsAppSession";
|
||||
import wbotMessageListener from "../services/WbotServices/wbotMessageListener";
|
||||
import wbotMonitor from "../services/WbotServices/wbotMonitor";
|
||||
|
||||
import CreateWhatsAppService from "../services/WhatsappService/CreateWhatsAppService";
|
||||
import DeleteWhatsAppService from "../services/WhatsappService/DeleteWhatsAppService";
|
||||
|
||||
@@ -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 };
|
||||
|
||||
Reference in New Issue
Block a user