Merge branch 'dual_session_test' into dialogflow
commit
4fe913cf4e
|
@ -13,7 +13,7 @@ import CheckIsValidContact from "../services/WbotServices/CheckIsValidContact";
|
||||||
import GetProfilePicUrl from "../services/WbotServices/GetProfilePicUrl";
|
import GetProfilePicUrl from "../services/WbotServices/GetProfilePicUrl";
|
||||||
import AppError from "../errors/AppError";
|
import AppError from "../errors/AppError";
|
||||||
|
|
||||||
import { searchContactCache, insertContactsCache } from '../helpers/ContactsCache'
|
import { searchContactCache, insertContactsCache, escapeCharCache } from '../helpers/ContactsCache'
|
||||||
|
|
||||||
import { off } from "process";
|
import { off } from "process";
|
||||||
|
|
||||||
|
@ -47,15 +47,23 @@ type IndexGetContactQuery = {
|
||||||
export const index = async (req: Request, res: Response): Promise<Response> => {
|
export const index = async (req: Request, res: Response): Promise<Response> => {
|
||||||
let { searchParam, pageNumber } = req.query as IndexQuery;
|
let { searchParam, pageNumber } = req.query as IndexQuery;
|
||||||
|
|
||||||
|
console.log('PAGE NUMBER CONTACT: ', pageNumber)
|
||||||
|
|
||||||
|
if (pageNumber === undefined || pageNumber.trim().length == 0) {
|
||||||
|
pageNumber = '1'
|
||||||
|
}
|
||||||
|
|
||||||
// TEST DEL
|
// TEST DEL
|
||||||
if (searchParam && searchParam.trim().length > 0 && process.env.CACHE) {
|
if (searchParam && searchParam.trim().length > 0 && process.env.CACHE) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
console.log('QUERY CONTACTS FROM CACHE SEARCH PARAM: ', searchParam)
|
|
||||||
|
|
||||||
const offset = 20 * (+pageNumber - 1);
|
const offset = 20 * (+pageNumber - 1);
|
||||||
|
|
||||||
|
searchParam = searchParam.replace(/\s+/g, ' ').trim().toLowerCase();
|
||||||
|
|
||||||
|
console.log('QUERY CONTACTS FROM CACHE SEARCH PARAM: ', searchParam)
|
||||||
|
|
||||||
const data = await searchContactCache(searchParam, offset, 20)
|
const data = await searchContactCache(searchParam, offset, 20)
|
||||||
|
|
||||||
if (data) {
|
if (data) {
|
||||||
|
@ -101,7 +109,7 @@ export const store = async (req: Request, res: Response): Promise<Response> => {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await schema.validate(newContact);
|
await schema.validate(newContact);
|
||||||
} catch (err) {
|
} catch (err: any) {
|
||||||
throw new AppError(err.message);
|
throw new AppError(err.message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -158,7 +166,7 @@ export const update = async (
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await schema.validate(contactData);
|
await schema.validate(contactData);
|
||||||
} catch (err) {
|
} catch (err: any) {
|
||||||
throw new AppError(err.message);
|
throw new AppError(err.message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -143,13 +143,15 @@ async function searchContactCache(search: string, offset: number, limit: number)
|
||||||
|
|
||||||
const removeExtraSpace = (str: string) => {
|
const removeExtraSpace = (str: string) => {
|
||||||
|
|
||||||
str = str.replace(/^\s+/g, '')
|
// str = str.replace(/^\s+/g, '')
|
||||||
|
|
||||||
return str.replace(/\s+/g, ' ')
|
return str.replace(/\s+/g, ' ')
|
||||||
}
|
}
|
||||||
|
|
||||||
const escapeCharCache = (str: string) => {
|
const escapeCharCache = (str: string) => {
|
||||||
|
|
||||||
|
str = str.replace(/\s+/g,' ').trim().toLowerCase();
|
||||||
|
|
||||||
const pattern = /[\'|\"|\.|\,|\;|\<|\>|\{|\}|\[|\]|\"|\'|\=|\~|\*|\:|\#|\+|\^|\$|\@|\%|\!|\&|\)|\(|/|\-|\\)]/g; // no match, use replace function.
|
const pattern = /[\'|\"|\.|\,|\;|\<|\>|\{|\}|\[|\]|\"|\'|\=|\~|\*|\:|\#|\+|\^|\$|\@|\%|\!|\&|\)|\(|/|\-|\\)]/g; // no match, use replace function.
|
||||||
|
|
||||||
let newStr = str.replace(pattern, (t1) => `\\${t1}`);
|
let newStr = str.replace(pattern, (t1) => `\\${t1}`);
|
||||||
|
|
|
@ -53,12 +53,21 @@ const ListTicketsService = async ({
|
||||||
|
|
||||||
let whereCondition: Filterable["where"] = { [Op.or]: [{ userId }, { status: "pending" }], queueId: { [Op.or]: [queueIds, null] } };
|
let whereCondition: Filterable["where"] = { [Op.or]: [{ userId }, { status: "pending" }], queueId: { [Op.or]: [queueIds, null] } };
|
||||||
|
|
||||||
|
console.log('PAGE NUMBER TICKET: ', pageNumber)
|
||||||
|
|
||||||
|
if (pageNumber.trim().length == 0) {
|
||||||
|
pageNumber = '1'
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (searchParam && searchParam.trim().length > 0 && process.env.CACHE) {
|
if (searchParam && searchParam.trim().length > 0 && process.env.CACHE) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
const offset = 40 * (+pageNumber - 1);
|
const offset = 40 * (+pageNumber - 1);
|
||||||
|
|
||||||
|
searchParam = searchParam.replace(/\s+/g, ' ').trim().toLowerCase();
|
||||||
|
|
||||||
console.log('QUERY TICKET SEARCH PARAM FROM CACHE: ', searchParam)
|
console.log('QUERY TICKET SEARCH PARAM FROM CACHE: ', searchParam)
|
||||||
|
|
||||||
let tickets: any = await searchTicketCache(searchParam, offset, 40);
|
let tickets: any = await searchTicketCache(searchParam, offset, 40);
|
||||||
|
|
|
@ -38,7 +38,8 @@ const SendWhatsAppMessage = async ({
|
||||||
quotedMsg
|
quotedMsg
|
||||||
}: Request): Promise<WbotMessage> => {
|
}: Request): Promise<WbotMessage> => {
|
||||||
|
|
||||||
var timetaken = "####### Time taken to send message";
|
let timestamp = Math.floor(Date.now() / 1000)
|
||||||
|
var timetaken = `########################################${timestamp}| TicketId: ${ticket.id} => Time taken to send the message`;
|
||||||
|
|
||||||
|
|
||||||
console.time(timetaken)
|
console.time(timetaken)
|
||||||
|
|
Loading…
Reference in New Issue