diff --git a/backend/src/libs/wbot.ts b/backend/src/libs/wbot.ts index f58830b..0ef7ecb 100644 --- a/backend/src/libs/wbot.ts +++ b/backend/src/libs/wbot.ts @@ -1,5 +1,5 @@ import qrCode from "qrcode-terminal"; -import { Client } from "whatsapp-web.js"; +import { Client, LocalAuth } from "whatsapp-web.js"; import { getIO } from "./socket"; import Whatsapp from "../models/Whatsapp"; import AppError from "../errors/AppError"; @@ -42,17 +42,14 @@ export const initWbot = async (whatsapp: Whatsapp): Promise => { if (whatsapp && whatsapp.session) { sessionCfg = JSON.parse(whatsapp.session); } - - const args:String = process.env.CHROME_ARGS || ""; - - const wbot: Session = new Client({ + + const wbot: Session = new Client({ session: sessionCfg, - puppeteer: { - executablePath: process.env.CHROME_BIN || undefined, - // @ts-ignore - browserWSEndpoint: process.env.CHROME_WS || undefined, - args: args.split(' ') - } + authStrategy: new LocalAuth({clientId: 'bd_'+whatsapp.id}), + puppeteer: { + args: ['--no-sandbox', '--disable-setuid-sandbox'], + executablePath: process.env.CHROME_BIN || undefined + }, }); wbot.initialize(); @@ -76,9 +73,9 @@ export const initWbot = async (whatsapp: Whatsapp): Promise => { wbot.on("authenticated", async session => { logger.info(`Session: ${sessionName} AUTHENTICATED`); - await whatsapp.update({ - session: JSON.stringify(session) - }); +// await whatsapp.update({ +// session: JSON.stringify(session) +// }); }); wbot.on("auth_failure", async msg => {