diff --git a/backend/package.json b/backend/package.json index d4890c7..41743e5 100644 --- a/backend/package.json +++ b/backend/package.json @@ -16,10 +16,10 @@ "license": "MIT", "dependencies": { "@google-cloud/dialogflow": "^4.6.0", - "actions-on-google": "^3.0.0", - "axios": "^0.27.2", "@sentry/node": "^5.29.2", "@types/pino": "^6.3.4", + "actions-on-google": "^3.0.0", + "axios": "^0.27.2", "bcryptjs": "^2.4.3", "cookie-parser": "^1.4.5", "cors": "^2.8.5", diff --git a/backend/src/controllers/HitController.ts b/backend/src/controllers/HitController.ts new file mode 100644 index 0000000..509bc94 --- /dev/null +++ b/backend/src/controllers/HitController.ts @@ -0,0 +1,26 @@ +import { Request, Response } from "express"; + + +// type IndexQuery = { +// centro_custo: string; +// }; + +export const hit = async (req: Request, res: Response): Promise => { + +// 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" }); +}; \ No newline at end of file diff --git a/backend/src/controllers/TicketController.ts b/backend/src/controllers/TicketController.ts index 8e8db5e..9987e26 100644 --- a/backend/src/controllers/TicketController.ts +++ b/backend/src/controllers/TicketController.ts @@ -259,8 +259,7 @@ export const update = async (req: Request, res: Response): Promise => }; - - + // export const update = async ( // req: Request, diff --git a/backend/src/routes/hitRoutes.ts b/backend/src/routes/hitRoutes.ts new file mode 100644 index 0000000..1c47bfb --- /dev/null +++ b/backend/src/routes/hitRoutes.ts @@ -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; diff --git a/backend/src/routes/index.ts b/backend/src/routes/index.ts index 3093b52..3382424 100644 --- a/backend/src/routes/index.ts +++ b/backend/src/routes/index.ts @@ -14,6 +14,7 @@ import reportRoutes from "./reportRoutes"; import schedulingNotifiyRoutes from "./SchedulingNotifyRoutes"; import statusChatEndRoutes from "./statusChatEndRoutes"; import dialogflowRoutes from "./dialogflowRoutes"; +import hitRoutes from "./hitRoutes"; const routes = Router(); @@ -33,5 +34,6 @@ routes.use(schedulingNotifiyRoutes); routes.use(reportRoutes); routes.use(statusChatEndRoutes); routes.use(dialogflowRoutes); +routes.use(hitRoutes); export default routes; diff --git a/backend/src/routes/ticketRoutes.ts b/backend/src/routes/ticketRoutes.ts index 0524925..1c43ec0 100644 --- a/backend/src/routes/ticketRoutes.ts +++ b/backend/src/routes/ticketRoutes.ts @@ -14,7 +14,7 @@ ticketRoutes.get("/tickets", isAuth, TicketController.index); 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); diff --git a/backend/src/services/WbotServices/wbotMessageListener.ts b/backend/src/services/WbotServices/wbotMessageListener.ts index fef377b..76f5464 100644 --- a/backend/src/services/WbotServices/wbotMessageListener.ts +++ b/backend/src/services/WbotServices/wbotMessageListener.ts @@ -246,7 +246,7 @@ const monitoramento_response2 = async (response: any | null, wbot: any, contact: 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 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++) { - 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 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) { - 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 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++) { - 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` }