From 54ab3cb297dcd27856f183b291637013392b7445 Mon Sep 17 00:00:00 2001 From: adriano Date: Mon, 10 Apr 2023 11:07:53 -0300 Subject: [PATCH] =?UTF-8?q?Corre=C3=A7=C3=A3o=20para=20limite=20de=204=20s?= =?UTF-8?q?ess=C3=B5es=20de=20whatsapp?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- TEST_SERVER1/api/app.js | 4 ++-- TEST_SERVER1/whats/app.js | 7 ++++++- TEST_SERVER1/whats/package.json | 2 +- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/TEST_SERVER1/api/app.js b/TEST_SERVER1/api/app.js index 42f9964..1a9bb2e 100644 --- a/TEST_SERVER1/api/app.js +++ b/TEST_SERVER1/api/app.js @@ -192,7 +192,7 @@ app.post('/api/session', async function (req, res) { console.log('whatsapp_numbers.length: ', whatsapp_numbers.length) - if (whatsapp_numbers.length == 4) { + if (whatsapp_numbers.length == 5) { res.status(400).json({ message: 'Cannot create more than 4 sessions from the same number' }) return } @@ -340,7 +340,7 @@ app.post('/api/session', async function (req, res) { console.log('----------------destDir: ', destDir) - execSync(`npm install && npm update whatsapp-web.js`, { cwd: destDir }, (error, stdout, stderr) => { + execSync(`npm install`, { cwd: destDir }, (error, stdout, stderr) => { if (error) { console.log(`error: ${error.message}`); return; diff --git a/TEST_SERVER1/whats/app.js b/TEST_SERVER1/whats/app.js index f396341..cb1bbdb 100644 --- a/TEST_SERVER1/whats/app.js +++ b/TEST_SERVER1/whats/app.js @@ -8,7 +8,7 @@ const restore = require('./helpers/restore'); const { Client, Location, List, Buttons, LocalAuth } = require('whatsapp-web.js/index'); -const { MessageMedia } = require('./node_modules/whatsapp-web.js/src/structures'); + const qrencode = require('qr-encode'); const axios = require('axios').default; const bodyparser = require('body-parser'); @@ -18,6 +18,11 @@ const express = require('express'); // const dbcloud = require('./funcs/dbcloud.js'); const FormData = require('form-data'); +// const { MessageMedia } = require('./node_modules/whatsapp-web.js/src/structures'); +let whatsappWebGlobalPath = path.join(process.env.NODE_PATH, 'whatsapp-web.js', '/src/structures'); +whatsappWebGlobalPath = whatsappWebGlobalPath.replace(':','') +const { MessageMedia } = require(whatsappWebGlobalPath); + const logger = require('logger') const dotenv = require('dotenv'); diff --git a/TEST_SERVER1/whats/package.json b/TEST_SERVER1/whats/package.json index 55756eb..b2f7256 100644 --- a/TEST_SERVER1/whats/package.json +++ b/TEST_SERVER1/whats/package.json @@ -25,7 +25,7 @@ "qrcode-terminal": "^0.12.0", "socket.io": "^4.5.4", "socket.io-client": "^4.5.4", - "whatsapp-web.js": "github:pedroslopez/whatsapp-web.js" + "fs-extra": "^11.1.0" }, "devDependencies": { "nodemon": "^2.0.20"