mirror of
https://github.com/cheveguerra/whaticket-community.git
synced 2026-04-21 21:29:25 +00:00
use appError on socket io
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import socketIo, { Server as SocketIO } from "socket.io";
|
||||
import { Server } from "http";
|
||||
import AppError from "../errors/AppError";
|
||||
|
||||
let io: SocketIO;
|
||||
|
||||
@@ -9,7 +10,7 @@ export const initIO = (httpServer: Server): SocketIO => {
|
||||
};
|
||||
export const getIO = (): SocketIO => {
|
||||
if (!io) {
|
||||
throw new Error("Socket IO not initialized");
|
||||
throw new AppError("Socket IO not initialized");
|
||||
}
|
||||
return io;
|
||||
};
|
||||
|
||||
@@ -24,7 +24,7 @@ module.exports = {
|
||||
|
||||
const wbot = new Client({
|
||||
session: sessionCfg,
|
||||
restartOnAuthFail: true,
|
||||
restartOnAuthFail: true
|
||||
});
|
||||
wbot.initialize();
|
||||
|
||||
@@ -37,7 +37,7 @@ module.exports = {
|
||||
|
||||
io.emit("whatsappSession", {
|
||||
action: "update",
|
||||
session: whatsapp,
|
||||
session: whatsapp
|
||||
});
|
||||
});
|
||||
|
||||
@@ -46,12 +46,12 @@ module.exports = {
|
||||
|
||||
await whatsapp.update({
|
||||
session: JSON.stringify(session),
|
||||
status: "authenticated",
|
||||
status: "authenticated"
|
||||
});
|
||||
|
||||
io.emit("whatsappSession", {
|
||||
action: "update",
|
||||
session: whatsapp,
|
||||
session: whatsapp
|
||||
});
|
||||
});
|
||||
|
||||
@@ -66,12 +66,12 @@ module.exports = {
|
||||
|
||||
await whatsapp.update({
|
||||
status: "CONNECTED",
|
||||
qrcode: "",
|
||||
qrcode: ""
|
||||
});
|
||||
|
||||
io.emit("whatsappSession", {
|
||||
action: "update",
|
||||
session: whatsapp,
|
||||
session: whatsapp
|
||||
});
|
||||
|
||||
wbot.sendPresenceAvailable();
|
||||
@@ -106,5 +106,5 @@ module.exports = {
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
}
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user