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;