Corrreção para abrir links de whatsapp pelo omnihit
parent
307ceca26e
commit
9f2d574251
|
@ -25,6 +25,8 @@ export const index = async (req: Request, res: Response): Promise<Response> => {
|
|||
const { ticketId } = req.params;
|
||||
const { pageNumber } = req.query as IndexQuery;
|
||||
|
||||
// console.log(':::::::::::::> TICKET ID: ', ticketId)
|
||||
|
||||
const { count, messages, ticket, hasMore } = await ListMessagesService({
|
||||
pageNumber,
|
||||
ticketId
|
||||
|
|
|
@ -223,7 +223,7 @@ export const initIO = (httpServer: Server): SocketIO => {
|
|||
logger.info("A client joined a ticket channel");
|
||||
|
||||
const regex = /^[0-9\b]+$/; // Regular expression to match only numbers
|
||||
if (ticketId && !ticketId.match(regex)) return
|
||||
if (ticketId && !ticketId.match(regex) || !ticketId) return
|
||||
|
||||
socket.join(ticketId);
|
||||
});
|
||||
|
@ -249,8 +249,8 @@ export const initIO = (httpServer: Server): SocketIO => {
|
|||
|
||||
console.log('rooms: ', rooms, ' | rooms.size: ', rooms.size)
|
||||
|
||||
if(rooms && rooms.size==1) return
|
||||
if(rooms && rooms.size==2 && !([...rooms][1].startsWith('session_'))) return
|
||||
if (rooms && rooms.size == 1) return
|
||||
if (rooms && rooms.size == 2 && !([...rooms][1].startsWith('session_'))) return
|
||||
|
||||
let whatsappIds: any = await Whatsapp.findAll({ attributes: ['id'], raw: true })
|
||||
|
||||
|
@ -258,7 +258,7 @@ export const initIO = (httpServer: Server): SocketIO => {
|
|||
|
||||
whatsappIds = whatsappIds.map((e: any) => `${e.id}`)
|
||||
|
||||
console.log('whatsappIds whatsappIds whatsappIds whatsappIds whatsappIds: ',whatsappIds)
|
||||
console.log('whatsappIds whatsappIds whatsappIds whatsappIds whatsappIds: ', whatsappIds)
|
||||
|
||||
if (rooms && rooms.size == 2 &&
|
||||
[...rooms][1].startsWith('session_') &&
|
||||
|
|
|
@ -20,9 +20,7 @@ const ListMessagesService = async ({
|
|||
ticketId
|
||||
}: Request): Promise<Response> => {
|
||||
|
||||
console.log('>>>>>>>>>>>>>>>>>>>> ticketId: ', ticketId)
|
||||
|
||||
if (ticketId && ticketId.length > 9) {
|
||||
if ((ticketId && ticketId.length > 9) || !ticketId || (ticketId && ticketId === 'undefined')) {
|
||||
return {
|
||||
messages: [],
|
||||
ticket: new Ticket,
|
||||
|
|
|
@ -72,10 +72,6 @@ const CreateTicketService = async ({
|
|||
throw new AppError("ERR_CREATING_TICKET");
|
||||
}
|
||||
|
||||
// console.log('CONTACT ticket.id: ', ticket.id)
|
||||
|
||||
// console.log('>>>>>>>>>>>>>>>>> msg: ', msg)
|
||||
|
||||
if (msg.length > 0) {
|
||||
sendWhatsAppMessageSocket(ticket, msg)
|
||||
}
|
||||
|
|
|
@ -16,7 +16,6 @@ const FindOrCreateTicketService = async (
|
|||
): Promise<Ticket> => {
|
||||
|
||||
try {
|
||||
|
||||
let ticket = await Ticket.findOne({
|
||||
where: {
|
||||
status: {
|
||||
|
|
|
@ -117,7 +117,7 @@ const Ticket = () => {
|
|||
useEffect(() => {
|
||||
|
||||
const regex = /^[0-9\b]+$/; // Regular expression to match only numbers
|
||||
if (ticketId && !ticketId.match(regex) || ticketId && ticketId.length > 9 ) return
|
||||
if (ticketId && !ticketId.match(regex) || ticketId && ticketId.length > 9 || !ticketId) return
|
||||
|
||||
const socket = openSocket(process.env.REACT_APP_BACKEND_URL);
|
||||
|
||||
|
|
|
@ -185,7 +185,6 @@ const TicketsList = (props) => {
|
|||
|
||||
const { searchTicket } = useContext(SearchTicketContext)
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
dispatch({ type: "RESET" });
|
||||
|
@ -193,8 +192,6 @@ const TicketsList = (props) => {
|
|||
|
||||
}, [status, searchParam, showAll, selectedQueueIds, searchTicket]);
|
||||
|
||||
|
||||
|
||||
const { tickets, hasMore, loading } = useTickets({
|
||||
pageNumber,
|
||||
searchParam,
|
||||
|
|
|
@ -96,23 +96,44 @@ const Ticket = () => {
|
|||
const delayDebounceFn = setTimeout(() => {
|
||||
const fetchTicket = async () => {
|
||||
|
||||
console.log('+++++++++++ ticketId: ', ticketId)
|
||||
|
||||
try {
|
||||
|
||||
let number
|
||||
let msg
|
||||
let msg = ''
|
||||
let contactId
|
||||
let link
|
||||
|
||||
console.log('ticketId: ', ticketId)
|
||||
console.log('window.location.href): ', window.location.href)
|
||||
link = window.location.href
|
||||
|
||||
const link = window.location.href.split('/https://wa.me/')
|
||||
if (link.includes('/https://wa.me/')) {
|
||||
|
||||
link = window.location.href.split('/https://wa.me/')
|
||||
|
||||
number = link[1].split('?text=')[0]
|
||||
msg = link[1].split('?text=')[1] || ''
|
||||
}
|
||||
else if (link.includes('https://web.whatsapp.com/send/?phone')) {
|
||||
|
||||
let aux = link.split('?phone=')
|
||||
|
||||
number = aux[1].split('&text')[0]
|
||||
|
||||
if (link.includes('&text=')) {
|
||||
|
||||
msg = aux[1].split('&text=')[1]
|
||||
|
||||
msg = msg.replaceAll("+", " ");
|
||||
|
||||
msg = msg.split('&type=')[0]
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (msg && msg.trim().length > 0) {
|
||||
msg = decodeURIComponent(msg);
|
||||
}
|
||||
|
||||
console.log('NUMBER: ', number, ' | MESSAGE: ', msg)
|
||||
|
||||
const { data: data0 } = await api.get("/contacts/", { params: { searchParam: number, pageNumber: "1" }, });
|
||||
|
||||
|
@ -162,7 +183,7 @@ const Ticket = () => {
|
|||
useEffect(() => {
|
||||
|
||||
const regex = /^[0-9\b]+$/; // Regular expression to match only numbers
|
||||
if (ticketId && !ticketId.match(regex) || ticketId && ticketId.length > 9 ) return
|
||||
if (ticketId && !ticketId.match(regex) || ticketId && ticketId.length > 9 || !ticketId) return
|
||||
|
||||
const socket = openSocket(process.env.REACT_APP_BACKEND_URL);
|
||||
|
||||
|
|
|
@ -37,6 +37,8 @@ const Routes = () => {
|
|||
<Route exact path="/tickets/:ticketId?" component={Tickets} isPrivate />
|
||||
|
||||
<Route exact path="/tickets/https://wa.me/:ticketId?" component={WhatsLink} isPrivate />
|
||||
<Route exact path="/tickets/https://web.whatsapp.com/send/:ticketId?" component={WhatsLink} isPrivate />
|
||||
|
||||
|
||||
<Route exact path="/connections" component={Connections} isPrivate />
|
||||
|
||||
|
|
Loading…
Reference in New Issue