Compare commits

..

No commits in common. "ea163b62b46e4355470e0dbf0b4c52b20ebfb4a8" and "0048fa483fb31b9432be58bbff0d8e248cc65a1c" have entirely different histories.

8 changed files with 98 additions and 114 deletions

View File

@ -22,7 +22,6 @@
"@types/pino": "^6.3.4", "@types/pino": "^6.3.4",
"axios": "^1.2.3", "axios": "^1.2.3",
"bcryptjs": "^2.4.3", "bcryptjs": "^2.4.3",
"compression": "^1.7.4",
"cookie-parser": "^1.4.5", "cookie-parser": "^1.4.5",
"cors": "^2.8.5", "cors": "^2.8.5",
"date-fns": "^2.30.0", "date-fns": "^2.30.0",
@ -57,9 +56,9 @@
"yup": "^0.32.8" "yup": "^0.32.8"
}, },
"devDependencies": { "devDependencies": {
"@types/lodash": "4.14",
"@types/bcryptjs": "^2.4.2", "@types/bcryptjs": "^2.4.2",
"@types/bluebird": "^3.5.32", "@types/bluebird": "^3.5.32",
"@types/compression": "^1.7.5",
"@types/cookie-parser": "^1.4.2", "@types/cookie-parser": "^1.4.2",
"@types/cors": "^2.8.7", "@types/cors": "^2.8.7",
"@types/express": "^4.17.13", "@types/express": "^4.17.13",
@ -67,7 +66,6 @@
"@types/faker": "^5.1.3", "@types/faker": "^5.1.3",
"@types/jest": "^26.0.15", "@types/jest": "^26.0.15",
"@types/jsonwebtoken": "^8.5.0", "@types/jsonwebtoken": "^8.5.0",
"@types/lodash": "4.14",
"@types/multer": "^1.4.4", "@types/multer": "^1.4.4",
"@types/node": "^14.11.8", "@types/node": "^14.11.8",
"@types/supertest": "^2.0.10", "@types/supertest": "^2.0.10",

View File

@ -11,7 +11,6 @@ import uploadConfig from "./config/upload";
import AppError from "./errors/AppError"; import AppError from "./errors/AppError";
import routes from "./routes"; import routes from "./routes";
import { logger } from "./utils/logger"; import { logger } from "./utils/logger";
import compression from 'compression';
Sentry.init({ dsn: process.env.SENTRY_DSN }); Sentry.init({ dsn: process.env.SENTRY_DSN });
@ -24,7 +23,6 @@ app.use(
}) })
); );
app.use(compression());
app.use(cookieParser()); app.use(cookieParser());
app.use(express.json()); app.use(express.json());
app.use(Sentry.Handlers.requestHandler()); app.use(Sentry.Handlers.requestHandler());

View File

@ -1,6 +1,5 @@
import { getIO } from "../../libs/socket"; import { getIO } from "../../libs/socket";
import Contact from "../../models/Contact"; import Contact from "../../models/Contact";
const { Op } = require('sequelize');
import { createOrUpdateContactCache } from '../../helpers/ContactsCache' import { createOrUpdateContactCache } from '../../helpers/ContactsCache'
import { tr } from "date-fns/locale"; import { tr } from "date-fns/locale";
@ -36,37 +35,15 @@ const CreateOrUpdateContactService = async ({
const io = getIO(); const io = getIO();
let contact: Contact | null; let contact: Contact | null;
const firstFourDigits = number.slice(0, 4);
const lastEightDigits = number.slice(-8);
//const numberFormat = number?.length === 13 && number[4] == '9' ? number.slice(0, 4) + number.slice(0, 4) : number; contact = await Contact.findOne({ where: { number } });
//contact = await Contact.findOne({ where: { number } });
contact = await Contact.findOne({
where: {
[Op.and]: [
{
number: {
[Op.like]: `%${firstFourDigits}%`
}
},
{
number: {
[Op.like]: `%${lastEightDigits}%`
}
}
]
}
});
if (contact) { if (contact) {
contact.update({ profilePicUrl });
if(contact.number == number){ // TEST DEL
contact.update({ profilePicUrl }); await createOrUpdateContactCache(`contact:${contact.id}`, { profilePicUrl })
await createOrUpdateContactCache(`contact:${contact.id}`, { profilePicUrl }) //
} else{
contact.update({ profilePicUrl, number });
await createOrUpdateContactCache(`contact:${contact.id}`, { profilePicUrl, number })
}
io.emit("contact", { io.emit("contact", {
action: "update", action: "update",

View File

@ -12,6 +12,9 @@ import UpdateTicketService from "./UpdateTicketService";
import { getSettingValue } from "../../helpers/WhaticketSettings" import { getSettingValue } from "../../helpers/WhaticketSettings"
import ListWhatsAppsNumber from "../WhatsappService/ListWhatsAppsNumber" import ListWhatsAppsNumber from "../WhatsappService/ListWhatsAppsNumber"
import { getSettingValue } from "../../helpers/WhaticketSettings";
import ListWhatsAppsNumber from "../WhatsappService/ListWhatsAppsNumber";
const FindOrCreateTicketServiceBot = async ( const FindOrCreateTicketServiceBot = async (
contact: Contact, contact: Contact,
whatsappId: number, whatsappId: number,
@ -101,6 +104,8 @@ const FindOrCreateTicketServiceBot = async (
unreadMessages unreadMessages
}); });
console.log("lxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
await dialogFlowStartContext(contact, ticket, botInfo); await dialogFlowStartContext(contact, ticket, botInfo);
} }
} }
@ -126,6 +131,8 @@ const FindOrCreateTicketServiceBot = async (
phoneNumberId phoneNumberId
}); });
console.log("yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy");
await dialogFlowStartContext(contact, ticket, botInfo); await dialogFlowStartContext(contact, ticket, botInfo);
} }

View File

@ -1061,6 +1061,8 @@ const handleMessage = async (
// console.log('----------> chat: ', JSON.parse(JSON.stringify(chat))) // console.log('----------> chat: ', JSON.parse(JSON.stringify(chat)))
console
if (chat.isGroup) { if (chat.isGroup) {
// let msgGroupContact; // let msgGroupContact;

View File

@ -1,14 +1,9 @@
import React, { useContext, Suspense, lazy } from "react"; import React, { useContext } from "react";
import { Route as RouterRoute, Redirect } from "react-router-dom"; import { Route as RouterRoute, Redirect } from "react-router-dom";
import { AuthContext } from "../context/Auth/AuthContext"; import { AuthContext } from "../context/Auth/AuthContext";
import BackdropLoading from "../components/BackdropLoading"; import BackdropLoading from "../components/BackdropLoading";
// Exemplo de como você carregaria componentes de forma lazy
const Dashboard = lazy(() => import("../pages/Dashboard"));
const Login = lazy(() => import("../pages/Login"));
const Signup = lazy(() => import("../pages/Signup"));
const Route = ({ component: Component, isPrivate = false, ...rest }) => { const Route = ({ component: Component, isPrivate = false, ...rest }) => {
const { isAuth, loading } = useContext(AuthContext); const { isAuth, loading } = useContext(AuthContext);
@ -25,7 +20,7 @@ const Route = ({ component: Component, isPrivate = false, ...rest }) => {
return ( return (
<> <>
{loading && <BackdropLoading />} {loading && <BackdropLoading />}
<Redirect to={{ pathname: "/", state: { from: rest.location } }} /> <Redirect to={{ pathname: "/", state: { from: rest.location } }} />;
</> </>
); );
} }
@ -33,9 +28,7 @@ const Route = ({ component: Component, isPrivate = false, ...rest }) => {
return ( return (
<> <>
{loading && <BackdropLoading />} {loading && <BackdropLoading />}
<Suspense fallback={<BackdropLoading />}> <RouterRoute {...rest} component={Component} />
<RouterRoute {...rest} component={Component} />
</Suspense>
</> </>
); );
}; };

View File

@ -1,85 +1,94 @@
import React, { Suspense, lazy } from 'react'; import React from 'react'
import { BrowserRouter, Switch } from 'react-router-dom' import { BrowserRouter, Switch } from 'react-router-dom'
import { ToastContainer } from 'react-toastify' import { ToastContainer } from 'react-toastify'
import LoggedInLayout from '../layout'
import Dashboard from '../pages/Dashboard/'
import Report from '../pages/Report/'
import SchedulesReminder from '../pages/SchedulesReminder/'
import Tickets from '../pages/Tickets/'
import Signup from '../pages/Signup/'
import Login from '../pages/Login/'
import Connections from '../pages/Connections/'
import Campaign from '../pages/Campaign'
import Settings from '../pages/Settings/'
import Users from '../pages/Users'
import Contacts from '../pages/Contacts/'
import QuickAnswers from '../pages/QuickAnswers/'
import StatusChatEnd from '../pages/StatusChatEnd/'
import Position from '../pages/Position/'
import Queues from '../pages/Queues/'
import { AuthProvider } from '../context/Auth/AuthContext' import { AuthProvider } from '../context/Auth/AuthContext'
import { WhatsAppsProvider } from '../context/WhatsApp/WhatsAppsContext' import { WhatsAppsProvider } from '../context/WhatsApp/WhatsAppsContext'
import LoggedInLayout from '../layout'
import Route from './Route' import Route from './Route'
import BackdropLoading from "../components/BackdropLoading";
const Dashboard = lazy(() => import('../pages/Dashboard/'));
const Report = lazy(() => import('../pages/Report/'));
const SchedulesReminder = lazy(() => import('../pages/SchedulesReminder/'));
const Tickets = lazy(() => import('../pages/Tickets/'));
const Signup = lazy(() => import('../pages/Signup/'));
const Login = lazy(() => import('../pages/Login/'));
const Connections = lazy(() => import('../pages/Connections/'));
const Campaign = lazy(() => import('../pages/Campaign/'));
const Settings = lazy(() => import('../pages/Settings/'));
const Users = lazy(() => import('../pages/Users/'));
const Contacts = lazy(() => import('../pages/Contacts/'));
const QuickAnswers = lazy(() => import('../pages/QuickAnswers/'));
const StatusChatEnd = lazy(() => import('../pages/StatusChatEnd/'));
const Position = lazy(() => import('../pages/Position/'));
const Queues = lazy(() => import('../pages/Queues/'));
const Routes = () => { const Routes = () => {
return ( return (
<BrowserRouter> <BrowserRouter>
<AuthProvider> <AuthProvider>
<Suspense fallback={<BackdropLoading />}> <Switch>
<Switch> <Route exact path="/login" component={Login} />
<Route exact path="/login" component={Login} /> <Route exact path="/signup" component={Signup} />
<Route exact path="/signup" component={Signup} /> <WhatsAppsProvider>
<WhatsAppsProvider> <LoggedInLayout>
<LoggedInLayout> <Route exact path="/" component={Dashboard} isPrivate />
<Route exact path="/" component={Dashboard} isPrivate /> <Route
<Route exact
exact path="/tickets/:ticketId?"
path="/tickets/:ticketId?" component={Tickets}
component={Tickets} isPrivate
isPrivate />
/>
<Route <Route
exact exact
path="/connections" path="/connections"
component={Connections} component={Connections}
isPrivate isPrivate
/> />
<Route exact path="/report" component={Report} isPrivate />
<Route exact path="/contacts" component={Contacts} isPrivate /> <Route exact path="/report" component={Report} isPrivate />
<Route
exact <Route exact path="/contacts" component={Contacts} isPrivate />
path="/schedulesReminder"
component={SchedulesReminder} <Route
isPrivate exact
/> path="/schedulesReminder"
<Route exact path="/users" component={Users} isPrivate /> component={SchedulesReminder}
<Route isPrivate
exact />
path="/quickAnswers"
component={QuickAnswers} <Route exact path="/users" component={Users} isPrivate />
isPrivate <Route
/> exact
<Route path="/quickAnswers"
exact component={QuickAnswers}
path="/statusChatEnd" isPrivate
component={StatusChatEnd} />
isPrivate <Route
/> exact
<Route exact path="/position" component={Position} isPrivate /> path="/statusChatEnd"
<Route exact path="/Settings" component={Settings} isPrivate /> component={StatusChatEnd}
<Route exact path="/Queues" component={Queues} isPrivate /> isPrivate
<Route exact path="/campaign" component={Campaign} isPrivate /> />
</LoggedInLayout> <Route
</WhatsAppsProvider> exact
</Switch> path="/position"
</Suspense> component={Position}
isPrivate
/>
<Route exact path="/Settings" component={Settings} isPrivate />
<Route exact path="/Queues" component={Queues} isPrivate />
<Route exact path="/campaign" component={Campaign} isPrivate />
</LoggedInLayout>
</WhatsAppsProvider>
</Switch>
<ToastContainer autoClose={3000} /> <ToastContainer autoClose={3000} />
</AuthProvider> </AuthProvider>
</BrowserRouter> </BrowserRouter>
); )
} }
export default Routes export default Routes

2
package-lock.json generated
View File

@ -1,5 +1,5 @@
{ {
"name": "projeto-hit", "name": "whaticket",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {