33 lines
896 B
TypeScript
33 lines
896 B
TypeScript
|
import { getIO } from "../libs/socket";
|
||
|
import Ticket from "../models/Ticket";
|
||
|
|
||
|
|
||
|
function sendWhatsAppMessageSocket(ticket: Ticket, body: string, quotedMsgSerializedId?: string | undefined) {
|
||
|
|
||
|
const io = getIO();
|
||
|
|
||
|
io.to(`session_${ticket.whatsappId.toString()}`).emit("send_message", {
|
||
|
action: "create",
|
||
|
msg: {
|
||
|
number: `${ticket.contact.number}@${ticket.isGroup ? "g" : "c"}.us`,
|
||
|
body: body,
|
||
|
quotedMessageId: quotedMsgSerializedId,
|
||
|
linkPreview: false
|
||
|
}
|
||
|
});
|
||
|
|
||
|
|
||
|
// io.emit("send_message", {
|
||
|
// action: "create",
|
||
|
// msg: {
|
||
|
// number: `${ticket.contact.number}@${ticket.isGroup ? "g" : "c"}.us`,
|
||
|
// body: body,
|
||
|
// quotedMessageId: quotedMsgSerializedId,
|
||
|
// linkPreview: false
|
||
|
// }
|
||
|
// });
|
||
|
|
||
|
|
||
|
}
|
||
|
|
||
|
export default sendWhatsAppMessageSocket;
|