Test multi device
parent
37f2cb26ad
commit
96f9e200d3
|
@ -37,7 +37,7 @@
|
||||||
"sequelize-cli": "^5.5.1",
|
"sequelize-cli": "^5.5.1",
|
||||||
"sequelize-typescript": "^1.1.0",
|
"sequelize-typescript": "^1.1.0",
|
||||||
"socket.io": "^3.0.5",
|
"socket.io": "^3.0.5",
|
||||||
"whatsapp-web.js": "^1.15.6",
|
"whatsapp-web.js": "github:pedroslopez/whatsapp-web.js",
|
||||||
"yup": "^0.32.8"
|
"yup": "^0.32.8"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import qrCode from "qrcode-terminal";
|
import qrCode from "qrcode-terminal";
|
||||||
import { Client } from "whatsapp-web.js";
|
import { Client, LocalAuth } from "whatsapp-web.js";
|
||||||
import { getIO } from "./socket";
|
import { getIO } from "./socket";
|
||||||
import Whatsapp from "../models/Whatsapp";
|
import Whatsapp from "../models/Whatsapp";
|
||||||
import AppError from "../errors/AppError";
|
import AppError from "../errors/AppError";
|
||||||
|
@ -37,6 +37,8 @@ const syncUnreadMessages = async (wbot: Session) => {
|
||||||
export const initWbot = async (whatsapp: Whatsapp): Promise<Session> => {
|
export const initWbot = async (whatsapp: Whatsapp): Promise<Session> => {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
|
|
||||||
const io = getIO();
|
const io = getIO();
|
||||||
const sessionName = whatsapp.name;
|
const sessionName = whatsapp.name;
|
||||||
let sessionCfg;
|
let sessionCfg;
|
||||||
|
@ -45,11 +47,19 @@ export const initWbot = async (whatsapp: Whatsapp): Promise<Session> => {
|
||||||
sessionCfg = JSON.parse(whatsapp.session);
|
sessionCfg = JSON.parse(whatsapp.session);
|
||||||
}
|
}
|
||||||
|
|
||||||
const wbot: Session = new Client({session: sessionCfg,
|
|
||||||
puppeteer: {executablePath: process.env.CHROME_BIN || undefined
|
//NOVA OPÇÃO MD
|
||||||
}
|
const wbot: Session = new Client({session: sessionCfg, authStrategy: new LocalAuth({clientId: 'bd_'+whatsapp.id}),
|
||||||
|
puppeteer: { args: ['--no-sandbox', '--disable-setuid-sandbox'], executablePath: process.env.CHROME_BIN || undefined },
|
||||||
});
|
});
|
||||||
|
|
||||||
|
//OPÇÃO DEFAULT NAO MD
|
||||||
|
// const wbot: Session = new Client({session: sessionCfg,
|
||||||
|
// puppeteer: {executablePath: process.env.CHROME_BIN || undefined
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
|
||||||
|
//OPÇÃO MD COM ERRO
|
||||||
// const io = getIO();
|
// const io = getIO();
|
||||||
// const sessionName = whatsapp.name;
|
// const sessionName = whatsapp.name;
|
||||||
// const SESSION_FILE_PATH = './session.json'
|
// const SESSION_FILE_PATH = './session.json'
|
||||||
|
@ -57,9 +67,10 @@ export const initWbot = async (whatsapp: Whatsapp): Promise<Session> => {
|
||||||
// if(fs.existsSync(SESSION_FILE_PATH)){
|
// if(fs.existsSync(SESSION_FILE_PATH)){
|
||||||
// sessionCfg = require(SESSION_FILE_PATH)
|
// sessionCfg = require(SESSION_FILE_PATH)
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// const wbot: Session = new Client({ puppeteer: { headless: true }, clientId: 'bd_'+whatsapp.id})
|
// const wbot: Session = new Client({ puppeteer: { headless: true }, clientId: 'bd_'+whatsapp.id})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
wbot.initialize();
|
wbot.initialize();
|
||||||
|
|
||||||
wbot.on("qr", async qr => {
|
wbot.on("qr", async qr => {
|
||||||
|
|
Loading…
Reference in New Issue