Compare commits
No commits in common. "88a71e5758b98a4635ca6706456b0fd6ec1408a9" and "90e9e311c3c039fb826ec3c124018f33532cfa23" have entirely different histories.
88a71e5758
...
90e9e311c3
|
@ -75,10 +75,10 @@ import GetProfilePicUrl from "../services/WbotServices/GetProfilePicUrl";
|
||||||
import CreateContactService from "../services/ContactServices/CreateContactService";
|
import CreateContactService from "../services/ContactServices/CreateContactService";
|
||||||
import { botSendMessage } from "../services/WbotServices/wbotMessageListener";
|
import { botSendMessage } from "../services/WbotServices/wbotMessageListener";
|
||||||
import WhatsappQueue from "../models/WhatsappQueue";
|
import WhatsappQueue from "../models/WhatsappQueue";
|
||||||
import { get } from "../helpers/RedisClient";
|
import { get } from "../helpers/RedisClient"
|
||||||
import CountStatusChatEndService from "../services/StatusChatEndService/CountStatusChatEndService";
|
import CountStatusChatEndService from "../services/StatusChatEndService/CountStatusChatEndService"
|
||||||
|
|
||||||
export const index = async (req: Request, res: Response): Promise<Response> => {
|
export const index = async (req: Request, res: Response): Promise<Response> => {
|
||||||
const {
|
const {
|
||||||
pageNumber,
|
pageNumber,
|
||||||
status,
|
status,
|
||||||
|
@ -110,8 +110,8 @@ export const index = async (req: Request, res: Response): Promise<Response> => {
|
||||||
withUnreadMessages,
|
withUnreadMessages,
|
||||||
unlimited,
|
unlimited,
|
||||||
searchParamContent
|
searchParamContent
|
||||||
});
|
});
|
||||||
|
|
||||||
return res.status(200).json({ tickets, count, hasMore });
|
return res.status(200).json({ tickets, count, hasMore });
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -141,8 +141,8 @@ export const remoteTicketCreation = async (
|
||||||
|
|
||||||
const whatsapp = await Whatsapp.findOne({
|
const whatsapp = await Whatsapp.findOne({
|
||||||
where: { number: contact_from, status: "CONNECTED" }
|
where: { number: contact_from, status: "CONNECTED" }
|
||||||
});
|
});
|
||||||
|
|
||||||
if (whatsapp) {
|
if (whatsapp) {
|
||||||
const { id: whatsappId, number, status } = whatsapp;
|
const { id: whatsappId, number, status } = whatsapp;
|
||||||
|
|
||||||
|
@ -213,7 +213,7 @@ export const remoteTicketCreation = async (
|
||||||
undefined,
|
undefined,
|
||||||
queueId
|
queueId
|
||||||
);
|
);
|
||||||
botSendMessage(ticket, `${msg}`);
|
botSendMessage(ticket, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
const io = getIO();
|
const io = getIO();
|
||||||
|
@ -408,6 +408,7 @@ export const update = async (
|
||||||
for (const w of whatsappsByqueue) {
|
for (const w of whatsappsByqueue) {
|
||||||
let whats = await ListWhatsAppsNumber(w.id);
|
let whats = await ListWhatsAppsNumber(w.id);
|
||||||
|
|
||||||
|
console.log("-------> WHATS: ", JSON.stringify(whats, null, 6));
|
||||||
const ticket = await Ticket.findOne({
|
const ticket = await Ticket.findOne({
|
||||||
where: {
|
where: {
|
||||||
[Op.and]: [
|
[Op.and]: [
|
||||||
|
|
|
@ -62,8 +62,21 @@ const isWeekend = async (number: string | number) => {
|
||||||
weekend.value == "enabled" &&
|
weekend.value == "enabled" &&
|
||||||
weekend.message?.trim()?.length > 0
|
weekend.message?.trim()?.length > 0
|
||||||
) {
|
) {
|
||||||
|
// Specify your desired timezone
|
||||||
|
const brazilTimeZone = "America/Sao_Paulo";
|
||||||
|
|
||||||
|
const currentDateUtc = new Date();
|
||||||
|
|
||||||
|
// Convert UTC date to Brazil time zone
|
||||||
|
const currentDate = utcToZonedTime(currentDateUtc, brazilTimeZone);
|
||||||
|
|
||||||
|
// Format the date using the desired format
|
||||||
|
const formattedDate = _format(currentDate, "yyyy-MM-dd HH:mm:ssXXX");
|
||||||
|
|
||||||
|
const parsedDate = parseISO(formattedDate);
|
||||||
|
|
||||||
// Convert parsed date to Brazil time zone
|
// Convert parsed date to Brazil time zone
|
||||||
const localDate = localDateConvert();
|
const localDate = utcToZonedTime(parsedDate, brazilTimeZone);
|
||||||
|
|
||||||
// Check if it's Saturday or Sunday
|
// Check if it's Saturday or Sunday
|
||||||
if (isSaturday(localDate)) {
|
if (isSaturday(localDate)) {
|
||||||
|
@ -163,14 +176,6 @@ async function isOutBusinessTime(number: string | number) {
|
||||||
async function isOutBusinessTimeSaturday(number: string | number) {
|
async function isOutBusinessTimeSaturday(number: string | number) {
|
||||||
let obj = { set: false, msg: "" };
|
let obj = { set: false, msg: "" };
|
||||||
|
|
||||||
// Convert parsed date to Brazil time zone
|
|
||||||
const localDate = localDateConvert();
|
|
||||||
|
|
||||||
// Check if it's Saturday or Sunday
|
|
||||||
if (!isSaturday(localDate)) {
|
|
||||||
return obj;
|
|
||||||
}
|
|
||||||
|
|
||||||
const outBusinessHoursSaturday = await SettingTicket.findOne({
|
const outBusinessHoursSaturday = await SettingTicket.findOne({
|
||||||
where: { key: "saturdayBusinessTime", number }
|
where: { key: "saturdayBusinessTime", number }
|
||||||
});
|
});
|
||||||
|
@ -178,9 +183,11 @@ async function isOutBusinessTimeSaturday(number: string | number) {
|
||||||
let isWithinRange = false;
|
let isWithinRange = false;
|
||||||
|
|
||||||
if (
|
if (
|
||||||
outBusinessHoursSaturday &&
|
true &&
|
||||||
outBusinessHoursSaturday.value == "enabled" &&
|
outBusinessHoursSaturday
|
||||||
outBusinessHoursSaturday?.message?.trim()?.length > 0
|
// outBusinessHoursSaturday &&
|
||||||
|
// outBusinessHoursSaturday.value == "enabled" &&
|
||||||
|
// outBusinessHoursSaturday?.message?.trim()?.length > 0
|
||||||
) {
|
) {
|
||||||
const ticketDateTimeUpdate = splitDateTime(
|
const ticketDateTimeUpdate = splitDateTime(
|
||||||
new Date(
|
new Date(
|
||||||
|
@ -242,22 +249,4 @@ async function isOutBusinessTimeSaturday(number: string | number) {
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
function localDateConvert() {
|
|
||||||
const brazilTimeZone = "America/Sao_Paulo";
|
|
||||||
|
|
||||||
const currentDateUtc = new Date();
|
|
||||||
|
|
||||||
// Convert UTC date to Brazil time zone
|
|
||||||
const currentDate = utcToZonedTime(currentDateUtc, brazilTimeZone);
|
|
||||||
|
|
||||||
// Format the date using the desired format
|
|
||||||
const formattedDate = _format(currentDate, "yyyy-MM-dd HH:mm:ssXXX");
|
|
||||||
|
|
||||||
const parsedDate = parseISO(formattedDate);
|
|
||||||
|
|
||||||
// Convert parsed date to Brazil time zone
|
|
||||||
const localDate = utcToZonedTime(parsedDate, brazilTimeZone);
|
|
||||||
return localDate;
|
|
||||||
}
|
|
||||||
|
|
||||||
export { isWeekend, isHoliday, isOutBusinessTime, isOutBusinessTimeSaturday };
|
export { isWeekend, isHoliday, isOutBusinessTime, isOutBusinessTimeSaturday };
|
||||||
|
|
Loading…
Reference in New Issue