diff --git a/backend/src/controllers/ContactController.ts b/backend/src/controllers/ContactController.ts index 767863a7..4bd8899a 100644 --- a/backend/src/controllers/ContactController.ts +++ b/backend/src/controllers/ContactController.ts @@ -22,6 +22,7 @@ type IndexQuery = { type IndexGetContactQuery = { name: string; number: string; + email: string; }; interface ExtraInfo { @@ -47,11 +48,12 @@ export const index = async (req: Request, res: Response): Promise => { }; export const getContact = async (req: Request, res: Response): Promise => { - const { name, number } = req.body as IndexGetContactQuery; + const { name, number, email } = req.body as IndexGetContactQuery; const contact = await GetContactService({ name, - number + number, + email }); return res.status(200).json(contact); @@ -59,7 +61,13 @@ export const getContact = async (req: Request, res: Response): Promise export const store = async (req: Request, res: Response): Promise => { const newContact: ContactData = req.body; - newContact.number = newContact.number.replace("-", "").replace(" ", ""); + newContact.number = newContact.number.replace("-", "") + .replace(" ", "") + .replace("(", "") + .replace(")", "") + .replace("+", "") + .replace(".", "") + .replace("_", "");; const schema = Yup.object().shape({ name: Yup.string().required(), @@ -75,8 +83,8 @@ export const store = async (req: Request, res: Response): Promise => { } await CheckIsValidContact(newContact.number); - const validNumber : any = await CheckContactNumber(newContact.number) - + const validNumber: any = await CheckContactNumber(newContact.number) + const profilePicUrl = await GetProfilePicUrl(validNumber); let name = newContact.name diff --git a/backend/src/database/seeds/20200904070004-create-default-settings.ts b/backend/src/database/seeds/20200904070004-create-default-settings.ts index b385284f..e7fa676d 100644 --- a/backend/src/database/seeds/20200904070004-create-default-settings.ts +++ b/backend/src/database/seeds/20200904070004-create-default-settings.ts @@ -40,6 +40,12 @@ module.exports = { value: "disabled", createdAt: new Date(), updatedAt: new Date() + }, + { + key: "darkMode", + value: "disabled", + createdAt: new Date(), + updatedAt: new Date() } ], {} diff --git a/backend/src/services/ContactServices/ListContactsService.ts b/backend/src/services/ContactServices/ListContactsService.ts index 0bd7a38f..7d19884d 100644 --- a/backend/src/services/ContactServices/ListContactsService.ts +++ b/backend/src/services/ContactServices/ListContactsService.ts @@ -25,7 +25,14 @@ const ListContactsService = async ({ `%${searchParam.toLowerCase().trim()}%` ) }, - { number: { [Op.like]: `%${searchParam.toLowerCase().trim()}%` } } + { number: { [Op.like]: `%${searchParam.toLowerCase().trim()}%` } }, + { + email: Sequelize.where( + Sequelize.fn("LOWER", Sequelize.col("email")), + "LIKE", + `%${searchParam.toLowerCase().trim()}%` + ) + }, ] }; const limit = 20; diff --git a/backend/src/services/TicketServices/ShowTicketService.ts b/backend/src/services/TicketServices/ShowTicketService.ts index 06440661..353abcf2 100644 --- a/backend/src/services/TicketServices/ShowTicketService.ts +++ b/backend/src/services/TicketServices/ShowTicketService.ts @@ -11,7 +11,7 @@ const ShowTicketService = async (id: string | number): Promise => { { model: Contact, as: "contact", - attributes: ["id", "name", "number", "profilePicUrl"], + attributes: ["id", "name", "number", "email", "profilePicUrl"], include: ["extraInfo"] }, { diff --git a/backend/src/services/WbotServices/wbotMessageListener.ts b/backend/src/services/WbotServices/wbotMessageListener.ts index c2b16a58..012c6959 100644 --- a/backend/src/services/WbotServices/wbotMessageListener.ts +++ b/backend/src/services/WbotServices/wbotMessageListener.ts @@ -25,7 +25,7 @@ import ShowWhatsAppService from "../WhatsappService/ShowWhatsAppService"; import { debounce } from "../../helpers/Debounce"; import UpdateTicketService from "../TicketServices/UpdateTicketService"; import CreateContactService from "../ContactServices/CreateContactService"; -import GetContactService from "../ContactServices/GetContactService"; +// import GetContactService from "../ContactServices/GetContactService"; import formatBody from "../../helpers/Mustache"; interface Session extends Client { @@ -214,7 +214,7 @@ const isValidMsg = (msg: WbotMessage): boolean => { msg.type === "document" || msg.type === "vcard" || msg.type === "call_log" || - //msg.type === "multi_vcard" || + // msg.type === "multi_vcard" || msg.type === "sticker" ) return true; @@ -229,13 +229,16 @@ const handleMessage = async ( return; } - //IGNORAR MENSAGENS DE GRUPO + // IGNORAR MENSAGENS DE GRUPO const Settingdb = await Settings.findOne({ where: { key: 'CheckMsgIsGroup' } }); - if (Settingdb?.value == 'enabled') { + if (Settingdb?.value === 'enabled') { const chat = await msg.getChat(); if ( + msg.type === "sticker" || + msg.type === "e2e_notification" || + msg.type === "notification_template" || msg.from === "status@broadcast" || msg.author != null || chat.isGroup @@ -243,7 +246,7 @@ const handleMessage = async ( return; } } - //IGNORAR MENSAGENS DE GRUPO + // IGNORAR MENSAGENS DE GRUPO try { let msgContact: WbotContact; @@ -261,16 +264,16 @@ const handleMessage = async ( !msg.hasMedia && msg.type !== "chat" && msg.type !== "vcard" - //&& msg.type !== "multi_vcard" + // && msg.type !== "multi_vcard" ) return; msgContact = await wbot.getContactById(msg.to); } else { - const listSettingsService = await ListSettingsServiceOne({key: "call"}); - var callSetting = listSettingsService?.value; + const listSettingsService = await ListSettingsServiceOne({ key: "call" }); + let callSetting = listSettingsService?.value; - msgContact = await msg.getContact(); + msgContact = await msg.getContact(); } const chat = await msg.getChat(); @@ -350,7 +353,7 @@ const handleMessage = async ( } } - /*if (msg.type === "multi_vcard") { + /* if (msg.type === "multi_vcard") { try { const array = msg.vCards.toString().split("\n"); let name = ""; @@ -409,12 +412,12 @@ const handleMessage = async ( } catch (error) { console.log(error); } - }*/ + } */ -if(msg.type==="call_log" && callSetting==="disabled"){ - const sentMessage = await wbot.sendMessage(`${contact.number}@c.us`, "*Mensagem Automática:*\nAs chamadas de voz e vídeo estão desabilitas para esse WhatsApp, favor enviar uma mensagem de texto. Obrigado"); - await verifyMessage(sentMessage, ticket, contact); - } + if (msg.type === "call_log" && callSetting === "disabled") { + const sentMessage = await wbot.sendMessage(`${contact.number}@c.us`, "*Mensagem Automática:*\nAs chamadas de voz e vídeo estão desabilitas para esse WhatsApp, favor enviar uma mensagem de texto. Obrigado"); + await verifyMessage(sentMessage, ticket, contact); + } } catch (err) { Sentry.captureException(err); diff --git a/frontend/src/translate/languages/en.js b/frontend/src/translate/languages/en.js index 7b5a27de..5575a052 100644 --- a/frontend/src/translate/languages/en.js +++ b/frontend/src/translate/languages/en.js @@ -411,6 +411,14 @@ const messages = { disabled: "Disabled", }, }, + darkMode: { + name: "Enable Dark Mode", + note: "Switch between light mode and dark mode", + options: { + enabled: "Enabled", + disabled: "Disabled", + }, + }, messagesList: { header: { assignedTo: "Assigned to:", diff --git a/frontend/src/translate/languages/es.js b/frontend/src/translate/languages/es.js index db24dec9..5effec99 100644 --- a/frontend/src/translate/languages/es.js +++ b/frontend/src/translate/languages/es.js @@ -398,9 +398,17 @@ const messages = { note: "Cierra automáticamente el ticket cuando se envía a través de API", options: { enabled: "Habilitado", - disabled: "Habilitado", + disabled: "Deshabilitado", }, }, + darkMode: { + name: "Habilitar modo oscuro", + note: "Cambiar entre el modo claro y el modo oscuro", + options: { + enabled: "Habilitado", + disabled: "Deshabilitado", + }, + }, timeCreateNewTicket: { name: "Crear nuevo ticket después", note: "Selecciona el tiempo que tardará en abrir un nuevo ticket si el cliente te vuelve a contactar", diff --git a/frontend/src/translate/languages/pt.js b/frontend/src/translate/languages/pt.js index a599c2da..c6aeb1f2 100644 --- a/frontend/src/translate/languages/pt.js +++ b/frontend/src/translate/languages/pt.js @@ -421,7 +421,7 @@ const messages = { }, darkMode: { name: "Ativa Modo Escuro", - note: "Se habilitado, modo escuro no sistema", + note: "Alternar entre o modo claro e o modo escuro", options: { enabled: "Ativado", disabled: "Desativado",