2023-02-07 15:47:40 +00:00
|
|
|
import { getIO } from "../libs/socket";
|
|
|
|
import Ticket from "../models/Ticket";
|
|
|
|
|
|
|
|
|
2023-07-12 14:54:29 +00:00
|
|
|
function sendWhatsAppMessageSocket(ticket: Ticket, body: string, quotedMsgSerializedId?: string | undefined, number?: string ) {
|
2023-02-07 15:47:40 +00:00
|
|
|
|
|
|
|
const io = getIO();
|
|
|
|
|
|
|
|
io.to(`session_${ticket.whatsappId.toString()}`).emit("send_message", {
|
|
|
|
action: "create",
|
|
|
|
msg: {
|
2023-07-12 14:54:29 +00:00
|
|
|
number: number ? number : `${ticket.contact.number}@${ticket.isGroup ? "g" : "c"}.us`,
|
2023-02-07 15:47:40 +00:00
|
|
|
body: body,
|
|
|
|
quotedMessageId: quotedMsgSerializedId,
|
|
|
|
linkPreview: false
|
|
|
|
}
|
2023-07-12 14:54:29 +00:00
|
|
|
});
|
2023-02-07 15:47:40 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
export default sendWhatsAppMessageSocket;
|