Alteração para receber informação de endpoit externo
parent
9036e446e7
commit
d816360fc0
|
@ -16,10 +16,10 @@
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@google-cloud/dialogflow": "^4.6.0",
|
"@google-cloud/dialogflow": "^4.6.0",
|
||||||
"actions-on-google": "^3.0.0",
|
|
||||||
"axios": "^0.27.2",
|
|
||||||
"@sentry/node": "^5.29.2",
|
"@sentry/node": "^5.29.2",
|
||||||
"@types/pino": "^6.3.4",
|
"@types/pino": "^6.3.4",
|
||||||
|
"actions-on-google": "^3.0.0",
|
||||||
|
"axios": "^0.27.2",
|
||||||
"bcryptjs": "^2.4.3",
|
"bcryptjs": "^2.4.3",
|
||||||
"cookie-parser": "^1.4.5",
|
"cookie-parser": "^1.4.5",
|
||||||
"cors": "^2.8.5",
|
"cors": "^2.8.5",
|
||||||
|
|
|
@ -0,0 +1,26 @@
|
||||||
|
import { Request, Response } from "express";
|
||||||
|
|
||||||
|
|
||||||
|
// type IndexQuery = {
|
||||||
|
// centro_custo: string;
|
||||||
|
// };
|
||||||
|
|
||||||
|
export const hit = async (req: Request, res: Response): Promise<Response> => {
|
||||||
|
|
||||||
|
// const {
|
||||||
|
// centro_custo,
|
||||||
|
// } = req.body as IndexQuery;
|
||||||
|
|
||||||
|
console.log('req.boy: ', req.body)
|
||||||
|
|
||||||
|
|
||||||
|
if (req.headers["auth"] === '0424bd59b807674191e7d77572075f33'){
|
||||||
|
console.log('fffffffffffffffffff')
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
res.status(401).json({ "message": "Token Inválido!" });
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return res.status(200).json({ "message": "Ok" });
|
||||||
|
};
|
|
@ -259,8 +259,7 @@ export const update = async (req: Request, res: Response): Promise<Response> =>
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// export const update = async (
|
// export const update = async (
|
||||||
// req: Request,
|
// req: Request,
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
import express from "express";
|
||||||
|
|
||||||
|
import * as HitController from "../controllers/HitController";
|
||||||
|
|
||||||
|
const hitRoutes = express.Router();
|
||||||
|
|
||||||
|
hitRoutes.post("/espacolaser/incidente", HitController.hit);
|
||||||
|
|
||||||
|
export default hitRoutes;
|
|
@ -14,6 +14,7 @@ import reportRoutes from "./reportRoutes";
|
||||||
import schedulingNotifiyRoutes from "./SchedulingNotifyRoutes";
|
import schedulingNotifiyRoutes from "./SchedulingNotifyRoutes";
|
||||||
import statusChatEndRoutes from "./statusChatEndRoutes";
|
import statusChatEndRoutes from "./statusChatEndRoutes";
|
||||||
import dialogflowRoutes from "./dialogflowRoutes";
|
import dialogflowRoutes from "./dialogflowRoutes";
|
||||||
|
import hitRoutes from "./hitRoutes";
|
||||||
|
|
||||||
const routes = Router();
|
const routes = Router();
|
||||||
|
|
||||||
|
@ -33,5 +34,6 @@ routes.use(schedulingNotifiyRoutes);
|
||||||
routes.use(reportRoutes);
|
routes.use(reportRoutes);
|
||||||
routes.use(statusChatEndRoutes);
|
routes.use(statusChatEndRoutes);
|
||||||
routes.use(dialogflowRoutes);
|
routes.use(dialogflowRoutes);
|
||||||
|
routes.use(hitRoutes);
|
||||||
|
|
||||||
export default routes;
|
export default routes;
|
||||||
|
|
|
@ -14,7 +14,7 @@ ticketRoutes.get("/tickets", isAuth, TicketController.index);
|
||||||
|
|
||||||
ticketRoutes.get("/tickets/:ticketId", isAuth, TicketController.show);
|
ticketRoutes.get("/tickets/:ticketId", isAuth, TicketController.show);
|
||||||
|
|
||||||
ticketRoutes.post("/tickets", isAuth, TicketController.store);
|
ticketRoutes.post("/tickets", isAuth, TicketController.store);
|
||||||
|
|
||||||
ticketRoutes.put("/tickets/:ticketId", isAuth, TicketController.update);
|
ticketRoutes.put("/tickets/:ticketId", isAuth, TicketController.update);
|
||||||
|
|
||||||
|
|
|
@ -246,7 +246,7 @@ const monitoramento_response2 = async (response: any | null, wbot: any, contact:
|
||||||
|
|
||||||
if (!response) {
|
if (!response) {
|
||||||
|
|
||||||
const msg = await wbot.sendMessage(`${contact.number}@c.us`, `Houve um erro ao tentar consultar o monitoramento da hit!${final_message}`);
|
const msg = await wbot.sendMessage(`${contact.number}@c.us`, `Houve um erro ao tentar consultar o monitoramento da Operadora!${final_message}`);
|
||||||
await verifyMessage(msg, ticket, contact);
|
await verifyMessage(msg, ticket, contact);
|
||||||
await new Promise(f => setTimeout(f, 1000));
|
await new Promise(f => setTimeout(f, 1000));
|
||||||
|
|
||||||
|
@ -255,7 +255,7 @@ const monitoramento_response2 = async (response: any | null, wbot: any, contact:
|
||||||
|
|
||||||
for (let i = 0; i < response.length; i++) {
|
for (let i = 0; i < response.length; i++) {
|
||||||
|
|
||||||
const msg = await wbot.sendMessage(`${contact.number}@c.us`, `Centro de custo: ${centro_de_custo}*\n\n*Incidente*:\n\n ${response[i].header}\n${response[i].body}${final_message}`);
|
const msg = await wbot.sendMessage(`${contact.number}@c.us`, `*Situação do chamado na Operadora*\n\n*Incidente*:\n\n ${response[i].header}\n${response[i].body}${final_message}`);
|
||||||
await verifyMessage(msg, ticket, contact);
|
await verifyMessage(msg, ticket, contact);
|
||||||
await new Promise(f => setTimeout(f, 1000));
|
await new Promise(f => setTimeout(f, 1000));
|
||||||
|
|
||||||
|
@ -264,7 +264,7 @@ const monitoramento_response2 = async (response: any | null, wbot: any, contact:
|
||||||
}
|
}
|
||||||
else if (send_empty_incident) {
|
else if (send_empty_incident) {
|
||||||
|
|
||||||
const msg = await wbot.sendMessage(`${contact.number}@c.us`, `Sem incidente!${final_message}`);
|
const msg = await wbot.sendMessage(`${contact.number}@c.us`, `Conforme Monitoramento a internet da unidade está operacional${final_message}`);
|
||||||
await verifyMessage(msg, ticket, contact);
|
await verifyMessage(msg, ticket, contact);
|
||||||
await new Promise(f => setTimeout(f, 1000));
|
await new Promise(f => setTimeout(f, 1000));
|
||||||
|
|
||||||
|
@ -316,7 +316,10 @@ async function sendDelayedMessages(wbot: Session, ticket: Ticket, contact: Conta
|
||||||
|
|
||||||
for (let i = 0; i < response.length; i++) {
|
for (let i = 0; i < response.length; i++) {
|
||||||
|
|
||||||
msg_endpoint_response += `*${response[i][0]}*: ${response[i][1]}\n`
|
if (['id_solicitante', 'centro_custo_departamento', 'departamento_do_formulario', 'centro_de_custo_do_departamento_do_formulario'].includes(response[i][0]))
|
||||||
|
continue
|
||||||
|
|
||||||
|
msg_endpoint_response += `*${response[i][0]}*: ${String(response[i][1]).replace(/(<([^>]+)>)/gi, "")}\n`
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue