@tiledesk/tiledesk-whatsapp-connector 1.0.29 → 1.0.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.env +1 -1
- package/package.json +2 -2
- package/publish.sh +0 -2
- package/tiledesk/Scheduler.js +15 -9
package/.env
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
# CUSTOM ENV
|
|
2
|
-
NPM_PUBLISH_TOKEN=
|
|
2
|
+
NPM_PUBLISH_TOKEN=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
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tiledesk/tiledesk-whatsapp-connector",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.31",
|
|
4
4
|
"description": "Tiledesk Whatsapp connector",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"license": "MIT",
|
|
17
17
|
"dependencies": {
|
|
18
18
|
"@tiledesk/tiledesk-client": "^0.10.4",
|
|
19
|
-
"@tiledesk/jobs-worker-queued": "^0.0.
|
|
19
|
+
"@tiledesk/jobs-worker-queued": "^0.0.8",
|
|
20
20
|
"app-root-path": "^3.0.0",
|
|
21
21
|
"axios": "^0.27.2",
|
|
22
22
|
"body-parser": "^1.20.0",
|
package/publish.sh
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
echo "Publishing..."
|
|
2
1
|
# Load .env variables
|
|
3
2
|
if [ -f .env ]; then
|
|
4
3
|
export $(grep -v '^#' .env | xargs)
|
|
@@ -18,7 +17,6 @@ if [ -z "$NPM_PUBLISH_TOKEN" ]; then
|
|
|
18
17
|
fi
|
|
19
18
|
else
|
|
20
19
|
# Create temporary .npmrc with the token
|
|
21
|
-
echo "NPM_PUBLISH_TOKEN is present in environment"
|
|
22
20
|
echo "//registry.npmjs.org/:_authToken=${NPM_PUBLISH_TOKEN}" > ~/.npmrc
|
|
23
21
|
fi
|
|
24
22
|
|
package/tiledesk/Scheduler.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
var JobManager = require("@tiledesk/jobs-worker-queued");
|
|
2
2
|
var winston = require('../winston');
|
|
3
|
-
|
|
3
|
+
|
|
4
|
+
// One JobManager (and so one AMQP connection) per url and exchange, shared by all the requests
|
|
5
|
+
var jobManagers = {};
|
|
4
6
|
|
|
5
7
|
class Scheduler {
|
|
6
8
|
|
|
@@ -25,18 +27,22 @@ class Scheduler {
|
|
|
25
27
|
this.log = config.log;
|
|
26
28
|
}
|
|
27
29
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
let key = this.AMQP_MANAGER_URL + "|" + this.JOB_TOPIC_EXCHANGE;
|
|
31
|
+
if (!jobManagers[key]) {
|
|
32
|
+
jobManagers[key] = new JobManager(this.AMQP_MANAGER_URL, {
|
|
33
|
+
debug: false,
|
|
34
|
+
topic: this.JOB_TOPIC_EXCHANGE,
|
|
35
|
+
exchange: this.JOB_TOPIC_EXCHANGE
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
this.jobManager = jobManagers[key];
|
|
33
39
|
}
|
|
34
40
|
|
|
35
41
|
async goSchedule(mydata) {
|
|
36
42
|
mydata.date = new Date();
|
|
37
43
|
try {
|
|
38
|
-
winston.
|
|
39
|
-
jobManager.publish(mydata);
|
|
44
|
+
winston.verbose("(wab) Scheduling job for transaction_id: " + mydata.transaction_id);
|
|
45
|
+
this.jobManager.publish(mydata);
|
|
40
46
|
return { success: true, msg: 'scheduling success!' };
|
|
41
47
|
} catch (err) {
|
|
42
48
|
winston.error('(wab) scheduling error ', err);
|
|
@@ -45,4 +51,4 @@ class Scheduler {
|
|
|
45
51
|
}
|
|
46
52
|
}
|
|
47
53
|
|
|
48
|
-
module.exports = { Scheduler };
|
|
54
|
+
module.exports = { Scheduler };
|