Merge branch 'master' into queue

This commit is contained in:
Cassio Santos
2021-01-14 08:03:40 -03:00
committed by GitHub
6 changed files with 31 additions and 29 deletions

View File

@@ -368,13 +368,15 @@ sudo service nginx restart
Now, enable SSL (https) on your sites to use all app features like notifications and sending audio messages. A easy way to this is using Certbot: Now, enable SSL (https) on your sites to use all app features like notifications and sending audio messages. A easy way to this is using Certbot:
Install certbor with snapd: Install certbot:
```bash ```bash
sudo snap install --classic certbot sudo add-apt-repository ppa:certbot/certbot
sudo apt update
sudo apt install python-certbot-nginx
``` ```
Enable SSL on nginx (Accept all information asked): Enable SSL on nginx (Fill / Accept all information asked):
```bash ```bash
sudo certbot --nginx sudo certbot --nginx
@@ -423,20 +425,13 @@ chmod +x updateWhaticket
This project helps you and you want to help keep it going? Buy me a coffee: This project helps you and you want to help keep it going? Buy me a coffee:
<a href="https://www.buymeacoffee.com/canove" target="_blank"><img src="https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png" alt="Buy Me A Coffee" style="height: 41px !important;width: 174px !important;box-shadow: 0px 3px 2px 0px rgba(190, 190, 190, 0.5) !important;-webkit-box-shadow: 0px 3px 2px 0px rgba(190, 190, 190, 0.5) !important;" ></a> <a href="https://www.buymeacoffee.com/canove" target="_blank"><img src="https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png" alt="Buy Me A Coffee" style="height: 61px !important;width: 174px !important;box-shadow: 0px 3px 2px 0px rgba(190, 190, 190, 0.5) !important;" ></a>
Para doações em BRL, você pode doar utilizando o Paypal: Para doações em BRL, utilize o Paypal:
<form action="https://www.paypal.com/donate" method="post" target="_top"> [![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://www.paypal.com/donate?business=VWW3BHW4AWHUY&item_name=Desenvolvimento+de+Software&currency_code=BRL)
<input type="hidden" name="cmd" value="_donations" />
<input type="hidden" name="business" value="VWW3BHW4AWHUY" />
<input type="hidden" name="item_name" value="Desenvolvimento de Software" />
<input type="hidden" name="currency_code" value="BRL" />
<input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif" border="0" name="submit" title="PayPal - The safer, easier way to pay online!" alt="Donate with PayPal button" />
<img alt="" border="0" src="https://www.paypal.com/en_BR/i/scr/pixel.gif" width="1" height="1" />
</form>
Any help and suggestions are welcome! Any help and suggestions will be apreciated.
## Disclaimer ## Disclaimer

View File

@@ -15,7 +15,7 @@
"author": "", "author": "",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@sentry/node": "5.27.0", "@sentry/node": "^5.29.2",
"@types/pino": "^6.3.4", "@types/pino": "^6.3.4",
"bcryptjs": "^2.4.3", "bcryptjs": "^2.4.3",
"cookie-parser": "^1.4.5", "cookie-parser": "^1.4.5",
@@ -36,9 +36,9 @@
"sequelize": "^5.22.3", "sequelize": "^5.22.3",
"sequelize-cli": "^5.5.1", "sequelize-cli": "^5.5.1",
"sequelize-typescript": "^1.1.0", "sequelize-typescript": "^1.1.0",
"socket.io": "^2.3.0", "socket.io": "^3.0.5",
"whatsapp-web.js": "1.11.1", "whatsapp-web.js": "^1.12.0",
"yup": "^0.29.3" "yup": "^0.32.8"
}, },
"devDependencies": { "devDependencies": {
"@types/bcryptjs": "^2.4.2", "@types/bcryptjs": "^2.4.2",

View File

@@ -30,7 +30,7 @@ export const index = async (req: Request, res: Response): Promise<Response> => {
ticketId ticketId
}); });
await SetTicketMessagesAsRead(ticket); SetTicketMessagesAsRead(ticket);
return res.json({ count, messages, ticket, hasMore }); 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); const ticket = await ShowTicketService(ticketId);
await SetTicketMessagesAsRead(ticket); SetTicketMessagesAsRead(ticket);
if (medias) { if (medias) {
await Promise.all( await Promise.all(

View File

@@ -1,4 +1,4 @@
import socketIo, { Server as SocketIO } from "socket.io"; import { Server as SocketIO } from "socket.io";
import { Server } from "http"; import { Server } from "http";
import AppError from "../errors/AppError"; import AppError from "../errors/AppError";
import { logger } from "../utils/logger"; import { logger } from "../utils/logger";
@@ -6,11 +6,15 @@ import { logger } from "../utils/logger";
let io: SocketIO; let io: SocketIO;
export const initIO = (httpServer: Server): SocketIO => { export const initIO = (httpServer: Server): SocketIO => {
io = socketIo(httpServer); io = new SocketIO(httpServer, {
cors: {
origin: process.env.FRONTEND_URL
}
});
io.on("connection", socket => { io.on("connection", socket => {
logger.info("Client Connected"); logger.info("Client Connected");
socket.on("joinChatBox", ticketId => { socket.on("joinChatBox", (ticketId: string) => {
logger.info("A client joined a ticket channel"); logger.info("A client joined a ticket channel");
socket.join(ticketId); socket.join(ticketId);
}); });
@@ -20,7 +24,7 @@ export const initIO = (httpServer: Server): SocketIO => {
socket.join("notification"); socket.join("notification");
}); });
socket.on("joinTickets", status => { socket.on("joinTickets", (status: string) => {
logger.info(`A client joined to ${status} tickets channel.`); logger.info(`A client joined to ${status} tickets channel.`);
socket.join(status); socket.join(status);
}); });
@@ -31,6 +35,7 @@ export const initIO = (httpServer: Server): SocketIO => {
}); });
return io; return io;
}; };
export const getIO = (): SocketIO => { export const getIO = (): SocketIO => {
if (!io) { if (!io) {
throw new AppError("Socket IO not initialized"); throw new AppError("Socket IO not initialized");

View File

@@ -239,11 +239,13 @@ const handleMessage = async (
groupContact = await verifyContact(msgGroupContact); groupContact = await verifyContact(msgGroupContact);
} }
const unreadMessages = msg.fromMe ? 0 : chat.unreadCount;
const contact = await verifyContact(msgContact); const contact = await verifyContact(msgContact);
const ticket = await FindOrCreateTicketService( const ticket = await FindOrCreateTicketService(
contact, contact,
wbot.id!, wbot.id!,
chat.unreadCount, unreadMessages,
groupContact groupContact
); );

View File

@@ -25,10 +25,10 @@
"react-router-dom": "^5.2.0", "react-router-dom": "^5.2.0",
"react-scripts": "3.4.3", "react-scripts": "3.4.3",
"react-toastify": "^6.0.9", "react-toastify": "^6.0.9",
"recharts": "^1.8.5", "recharts": "^2.0.2",
"socket.io-client": "^2.3.1", "socket.io-client": "^3.0.5",
"use-sound": "^1.0.2", "use-sound": "^2.0.1",
"yup": "^0.29.3" "yup": "^0.32.8"
}, },
"scripts": { "scripts": {
"start": "react-scripts start", "start": "react-scripts start",