21 lines
495 B
TypeScript
21 lines
495 B
TypeScript
import { Client as Session } from "whatsapp-web.js";
|
|
import { getWbot } from "../libs/wbot";
|
|
import GetDefaultWhatsApp from "./GetDefaultWhatsApp";
|
|
import Ticket from "../models/Ticket";
|
|
|
|
const GetTicketWbot = async (ticket: Ticket): Promise<Session> => {
|
|
|
|
if (!ticket.whatsappId) {
|
|
|
|
const defaultWhatsapp = await GetDefaultWhatsApp();
|
|
|
|
await ticket.$set("whatsapp", defaultWhatsapp);
|
|
}
|
|
|
|
const wbot = getWbot(ticket.whatsappId);
|
|
|
|
return wbot;
|
|
};
|
|
|
|
export default GetTicketWbot;
|