projeto-hit/backend/src/helpers/SendWhatsappMessageMediaSoc...

21 lines
541 B
TypeScript

import { MessageMedia } from "whatsapp-web.js";
import { getIO } from "../libs/socket";
import Ticket from "../models/Ticket";
function sendWhatsAppMediaSocket(ticket: Ticket, newMedia: MessageMedia) {
const io = getIO();
io.to(`session_${ticket.whatsappId.toString()}`).emit("send_media", {
action: "create",
msg: {
number: `${ticket.contact.number}@${ticket.isGroup ? "g" : "c"}.us`,
media: newMedia,
sendAudioAsVoice: true
}
});
}
export default sendWhatsAppMediaSocket;