joaomirandas/whats2api

P-Queue OpenWA

Opened this issue · 0 comments

Hello friends, can someone help me to deploy a message delivery queue following OpenwA standards?

global.openWA = require('@open-wa/wa-automate');
const fs = require('fs');
const async = require("async");
const request = require('request');
const moment = require('moment');
const mime = require('mime-types');
const { default: PQueue } = require("p-queue");

const queue = new PQueue({
concurrency: 1,
timeout: 2000
});

WHATS_API.prototype.SETUP = function (CLIENT, WEBHOOK_INPUT, TOKEN_INPUT) {
var that = this;
that.WEBHOOK = WEBHOOK_INPUT;
that.TOKEN = TOKEN_INPUT;
that.CONNECTION = CLIENT;
CLIENT.onMessage(message => {
queue.add(()=>that.PROCESS_MESSAGE(message));
queue.start();
}
}
}