mirror of
https://github.com/cheveguerra/whaticket-community.git
synced 2026-04-17 19:37:02 +00:00
Merge branch 'master' into queue
This commit is contained in:
@@ -15,7 +15,7 @@
|
||||
"author": "",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@sentry/node": "5.27.0",
|
||||
"@sentry/node": "^5.29.2",
|
||||
"@types/pino": "^6.3.4",
|
||||
"bcryptjs": "^2.4.3",
|
||||
"cookie-parser": "^1.4.5",
|
||||
@@ -36,9 +36,9 @@
|
||||
"sequelize": "^5.22.3",
|
||||
"sequelize-cli": "^5.5.1",
|
||||
"sequelize-typescript": "^1.1.0",
|
||||
"socket.io": "^2.3.0",
|
||||
"whatsapp-web.js": "1.11.1",
|
||||
"yup": "^0.29.3"
|
||||
"socket.io": "^3.0.5",
|
||||
"whatsapp-web.js": "^1.12.0",
|
||||
"yup": "^0.32.8"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/bcryptjs": "^2.4.2",
|
||||
|
||||
@@ -30,7 +30,7 @@ export const index = async (req: Request, res: Response): Promise<Response> => {
|
||||
ticketId
|
||||
});
|
||||
|
||||
await SetTicketMessagesAsRead(ticket);
|
||||
SetTicketMessagesAsRead(ticket);
|
||||
|
||||
return res.json({ count, messages, ticket, hasMore });
|
||||
};
|
||||
@@ -42,7 +42,7 @@ export const store = async (req: Request, res: Response): Promise<Response> => {
|
||||
|
||||
const ticket = await ShowTicketService(ticketId);
|
||||
|
||||
await SetTicketMessagesAsRead(ticket);
|
||||
SetTicketMessagesAsRead(ticket);
|
||||
|
||||
if (medias) {
|
||||
await Promise.all(
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import socketIo, { Server as SocketIO } from "socket.io";
|
||||
import { Server as SocketIO } from "socket.io";
|
||||
import { Server } from "http";
|
||||
import AppError from "../errors/AppError";
|
||||
import { logger } from "../utils/logger";
|
||||
@@ -6,11 +6,15 @@ import { logger } from "../utils/logger";
|
||||
let io: SocketIO;
|
||||
|
||||
export const initIO = (httpServer: Server): SocketIO => {
|
||||
io = socketIo(httpServer);
|
||||
io = new SocketIO(httpServer, {
|
||||
cors: {
|
||||
origin: process.env.FRONTEND_URL
|
||||
}
|
||||
});
|
||||
|
||||
io.on("connection", socket => {
|
||||
logger.info("Client Connected");
|
||||
socket.on("joinChatBox", ticketId => {
|
||||
socket.on("joinChatBox", (ticketId: string) => {
|
||||
logger.info("A client joined a ticket channel");
|
||||
socket.join(ticketId);
|
||||
});
|
||||
@@ -20,7 +24,7 @@ export const initIO = (httpServer: Server): SocketIO => {
|
||||
socket.join("notification");
|
||||
});
|
||||
|
||||
socket.on("joinTickets", status => {
|
||||
socket.on("joinTickets", (status: string) => {
|
||||
logger.info(`A client joined to ${status} tickets channel.`);
|
||||
socket.join(status);
|
||||
});
|
||||
@@ -31,6 +35,7 @@ export const initIO = (httpServer: Server): SocketIO => {
|
||||
});
|
||||
return io;
|
||||
};
|
||||
|
||||
export const getIO = (): SocketIO => {
|
||||
if (!io) {
|
||||
throw new AppError("Socket IO not initialized");
|
||||
|
||||
@@ -239,11 +239,13 @@ const handleMessage = async (
|
||||
groupContact = await verifyContact(msgGroupContact);
|
||||
}
|
||||
|
||||
const unreadMessages = msg.fromMe ? 0 : chat.unreadCount;
|
||||
|
||||
const contact = await verifyContact(msgContact);
|
||||
const ticket = await FindOrCreateTicketService(
|
||||
contact,
|
||||
wbot.id!,
|
||||
chat.unreadCount,
|
||||
unreadMessages,
|
||||
groupContact
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user