Adding multidevice whatsapp support

This commit is contained in:
Ricardo Araújo Paes
2022-08-19 08:36:36 -03:00
parent e13f93db3d
commit fbbecdc0b2
5 changed files with 28 additions and 11 deletions

12
.gitattributes vendored Executable file
View File

@@ -0,0 +1,12 @@
* text=auto
*.sh text eol=lf
Dockerfile eol=lf
docker-compose.yml eol=lf
docker-compose.*.yml eol=lf
*.jpg binary
*.png binary
*.gif binary
*.woff binary
*.tff binary
*.eot binary
*.otf binary

View File

@@ -3,3 +3,4 @@
*docker-compose* *docker-compose*
node_modules node_modules
dist dist
.wwebjs_auth

2
backend/.gitignore vendored
View File

@@ -14,3 +14,5 @@ yarn-error.log
# Ignore test-related files # Ignore test-related files
/coverage.data /coverage.data
/coverage/ /coverage/
.wwebjs_auth/

View File

@@ -43,13 +43,17 @@ export const initWbot = async (whatsapp: Whatsapp): Promise<Session> => {
sessionCfg = JSON.parse(whatsapp.session); sessionCfg = JSON.parse(whatsapp.session);
} }
const wbot: Session = new Client({ const args:String = process.env.CHROME_ARGS || "";
const wbot: Session = new Client({
session: sessionCfg, session: sessionCfg,
authStrategy: new LocalAuth({clientId: 'bd_'+whatsapp.id}), authStrategy: new LocalAuth({clientId: 'bd_'+whatsapp.id}),
puppeteer: { puppeteer: {
args: ['--no-sandbox', '--disable-setuid-sandbox'], executablePath: process.env.CHROME_BIN || undefined,
executablePath: process.env.CHROME_BIN || undefined // @ts-ignore
}, browserWSEndpoint: process.env.CHROME_WS || undefined,
args: args.split(' ')
}
}); });
wbot.initialize(); wbot.initialize();
@@ -73,9 +77,6 @@ export const initWbot = async (whatsapp: Whatsapp): Promise<Session> => {
wbot.on("authenticated", async session => { wbot.on("authenticated", async session => {
logger.info(`Session: ${sessionName} AUTHENTICATED`); logger.info(`Session: ${sessionName} AUTHENTICATED`);
// await whatsapp.update({
// session: JSON.stringify(session)
// });
}); });
wbot.on("auth_failure", async msg => { wbot.on("auth_failure", async msg => {

View File

@@ -24,6 +24,7 @@ services:
- ${BACKEND_PORT:-8080}:3000 - ${BACKEND_PORT:-8080}:3000
volumes: volumes:
- ./backend/public/:/usr/src/app/public/ - ./backend/public/:/usr/src/app/public/
- ./backend/.wwebjs_auth/:/usr/src/app/.wwebjs_auth/
networks: networks:
- whaticket - whaticket