Correção para limite de 4 sessões de whatsapp

pull/21/head
adriano 2023-04-10 11:07:53 -03:00
parent bb0e93128a
commit 54ab3cb297
3 changed files with 9 additions and 4 deletions

View File

@ -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;

View File

@ -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');

View File

@ -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"