import { Op } from "sequelize"
import { getWbot } from "../libs/wbot";
import Message from "../models/Message"
import Ticket from "../models/Ticket";
import Whatsapp from "../models/Whatsapp";
import endPointQuery from "./old_EndPointQuery";

import whatsappOfficialAPI from "./WhatsappOfficialAPI";

export async function setMessageAsRead(ticket: Ticket) {
  if (ticket?.phoneNumberId) {  
    return;
  }

  const wbot_url = await getWbot(ticket.whatsappId);

  console.log(
    "from wbotMessagelistener wbot_url: ",
    wbot_url,
    " | ticket.contact.number: ",
    ticket.contact.number
  );

  await endPointQuery(`${wbot_url}/api/sendSeen`, {
    number: `${ticket.contact.number}@${ticket.isGroup ? "g" : "c"}.us`
  });
}
