Skip to content

Commit

Permalink
Inclusão do número da conexão
Browse files Browse the repository at this point in the history
  • Loading branch information
rtenorioh committed Nov 30, 2022
1 parent 75fd718 commit 5827a45
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 33 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { QueryInterface, DataTypes } from "sequelize";

module.exports = {
up: (queryInterface: QueryInterface) => {
return queryInterface.addColumn("Whatsapps", "number", {
type: DataTypes.STRING
});
},

down: (queryInterface: QueryInterface) => {
return queryInterface.removeColumn("Whatsapps", "number");
}
};
69 changes: 36 additions & 33 deletions backend/src/libs/wbot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,41 +46,41 @@ export const initWbot = async (whatsapp: Whatsapp): Promise<Session> => {

const wbot: Session = new Client({
session: sessionCfg,
authStrategy: new LocalAuth({ clientId: 'bd_' + whatsapp.id }),
authStrategy: new LocalAuth({ clientId: `bd_${whatsapp.id}` }),
puppeteer: {
args: [
'--no-sandbox',
'--disable-setuid-sandbox',
'--log-level=3',
'--no-default-browser-check',
'--disable-site-isolation-trials',
'--no-experiments',
'--ignore-gpu-blacklist',
'--ignore-certificate-errors',
'--ignore-certificate-errors-spki-list',
'--disable-gpu',
'--disable-extensions',
'--disable-default-apps',
'--enable-features=NetworkService',
'--disable-setuid-sandbox',
'--no-sandbox',
'--disable-webgl',
'--disable-threaded-animation',
'--disable-threaded-scrolling',
'--disable-in-process-stack-traces',
'--disable-histogram-customizer',
'--disable-gl-extensions',
'--disable-composited-antialiasing',
'--disable-canvas-aa',
'--disable-3d-apis',
'--disable-accelerated-2d-canvas',
'--disable-accelerated-jpeg-decoding',
'--disable-accelerated-mjpeg-decode',
'--disable-app-list-dismiss-on-blur',
'--disable-accelerated-video-decode'
"--no-sandbox",
"--disable-setuid-sandbox",
"--log-level=3",
"--no-default-browser-check",
"--disable-site-isolation-trials",
"--no-experiments",
"--ignore-gpu-blacklist",
"--ignore-certificate-errors",
"--ignore-certificate-errors-spki-list",
"--disable-gpu",
"--disable-extensions",
"--disable-default-apps",
"--enable-features=NetworkService",
"--disable-setuid-sandbox",
"--no-sandbox",
"--disable-webgl",
"--disable-threaded-animation",
"--disable-threaded-scrolling",
"--disable-in-process-stack-traces",
"--disable-histogram-customizer",
"--disable-gl-extensions",
"--disable-composited-antialiasing",
"--disable-canvas-aa",
"--disable-3d-apis",
"--disable-accelerated-2d-canvas",
"--disable-accelerated-jpeg-decoding",
"--disable-accelerated-mjpeg-decode",
"--disable-app-list-dismiss-on-blur",
"--disable-accelerated-video-decode"
],
executablePath: process.env.CHROME_BIN || undefined
},
}
});

wbot.initialize();
Expand Down Expand Up @@ -135,10 +135,13 @@ export const initWbot = async (whatsapp: Whatsapp): Promise<Session> => {
wbot.on("ready", async () => {
logger.info(`Session: ${sessionName} READY`);

console.log("WbotON", wbot.info.wid._serialized.split("@")[0]);

await whatsapp.update({
status: "CONNECTED",
qrcode: "",
retries: 0
retries: 0,
number: wbot.info.wid._serialized.split("@")[0]
});

io.emit("whatsappSession", {
Expand Down Expand Up @@ -182,4 +185,4 @@ export const removeWbot = (whatsappId: number): void => {
} catch (err: any) {
logger.error(err);
}
};
};
3 changes: 3 additions & 0 deletions backend/src/models/Whatsapp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ class Whatsapp extends Model<Whatsapp> {
@Column
status: string;

@Column
number: string;

@Column
battery: string;

Expand Down
6 changes: 6 additions & 0 deletions frontend/src/pages/Connections/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,9 @@ const Connections = () => {
<TableCell align="center">
{i18n.t("connections.table.status")}
</TableCell>
<TableCell align="center">
{i18n.t("connections.table.number")}
</TableCell>
<TableCell align="center">
{i18n.t("connections.table.session")}
</TableCell>
Expand Down Expand Up @@ -366,6 +369,9 @@ const Connections = () => {
<TableCell align="center">
{renderStatusToolTips(whatsApp)}
</TableCell>
<TableCell align="center">
+{whatsApp.number}
</TableCell>
<TableCell align="center">
{renderActionButtons(whatsApp)}
</TableCell>
Expand Down
1 change: 1 addition & 0 deletions frontend/src/translate/languages/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ const messages = {
table: {
id: "Instance ID",
name: "Name",
number: "Number",
status: "Status",
lastUpdate: "Last update",
default: "Default",
Expand Down
1 change: 1 addition & 0 deletions frontend/src/translate/languages/es.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ const messages = {
table: {
id: "ID de instancia",
name: "Nombre",
number: "Número",
status: "Estado",
lastUpdate: "Última actualización",
default: "Predeterminado",
Expand Down
1 change: 1 addition & 0 deletions frontend/src/translate/languages/pt.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ const messages = {
table: {
id: "ID da Instância",
name: "Nome",
number: "Número",
status: "Status",
lastUpdate: "Última atualização",
default: "Padrão",
Expand Down

0 comments on commit 5827a45

Please sign in to comment.