@tiledesk/tiledesk-whatsapp-connector 0.1.54 → 0.1.55

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/index.js CHANGED
@@ -61,6 +61,7 @@ let REDIS_PORT = null;
61
61
  let REDIS_PASSWORD = null;
62
62
  let BASE_FILE_URL = null;
63
63
  let AMQP_MANAGER_URL = null;
64
+ let JOB_TOPIC_EXCHANGE = null;
64
65
 
65
66
 
66
67
  // Handlebars register helpers
@@ -1352,12 +1353,20 @@ async function startApp(settings, callback) {
1352
1353
  }
1353
1354
 
1354
1355
  if (!settings.AMQP_MANAGER_URL) {
1355
- winston.error("(wab api) AMQP_MANAGER_URL is mandatory (?). Exit...");
1356
+ winston.error("(wab) AMQP_MANAGER_URL is mandatory (?). Exit...");
1356
1357
  } else {
1357
1358
  AMQP_MANAGER_URL = settings.AMQP_MANAGER_URL;
1358
- winston.info("(wab api) AMQP_MANAGER_URL is present");
1359
+ winston.info("(wab) AMQP_MANAGER_URL is present");
1359
1360
  }
1360
1361
 
1362
+ if (!settings.JOB_TOPIC_EXCHANGE) {
1363
+ winston.warning("(wab) JOB_TOPIC_EXCHANGE should be present. Using default value");
1364
+ JOB_TOPIC_EXCHANGE = "tiledesk-whatsapp";
1365
+ } else {
1366
+ JOB_TOPIC_EXCHANGE = settings.JOB_TOPIC_EXCHANGE;
1367
+ winston.info("(wab) JOB_TOPIC_EXCHANGE is present");
1368
+ }
1369
+
1361
1370
  mongoose.connect(process.env.MONGODB_URL)
1362
1371
  .then(() => { winston.info("Mongoose DB Connected") })
1363
1372
  .catch((err) => { winston.error("(Mongoose) Unable to connect with MongoDB ", err)
@@ -1376,7 +1385,8 @@ async function startApp(settings, callback) {
1376
1385
  API_URL: API_URL,
1377
1386
  GRAPH_URL: GRAPH_URL,
1378
1387
  BASE_FILE_URL: BASE_FILE_URL,
1379
- AMQP_MANAGER_URL: AMQP_MANAGER_URL
1388
+ AMQP_MANAGER_URL: AMQP_MANAGER_URL,
1389
+ JOB_TOPIC_EXCHANGE: JOB_TOPIC_EXCHANGE,
1380
1390
  }, (err) => {
1381
1391
  if (!err) {
1382
1392
  winston.info("(wab) API route successfully started.")
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tiledesk/tiledesk-whatsapp-connector",
3
- "version": "0.1.54",
3
+ "version": "0.1.55",
4
4
  "description": "Tiledesk Whatsapp connector",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/routes/api.js CHANGED
@@ -152,7 +152,7 @@ router.post('/tiledesk/broadcast', async (req, res) => {
152
152
  return res.status(400).send({ success: false, error: "Missing parameter 'WhatsApp Business Account ID'. Please update your app."})
153
153
  }
154
154
 
155
- let scheduler = new Scheduler({ AMQP_MANAGER_URL: AMQP_MANAGER_URL });
155
+ let scheduler = new Scheduler({ AMQP_MANAGER_URL: AMQP_MANAGER_URL, JOB_TOPIC_EXCHANGE: JOB_TOPIC_EXCHANGE });
156
156
  let data_To_scheduler = {
157
157
  project_id: project_id,
158
158
  receiver_list: receiver_list,
@@ -214,6 +214,13 @@ async function startRoute(settings, callback) {
214
214
  AMQP_MANAGER_URL = settings.AMQP_MANAGER_URL;
215
215
  winston.info("(wab api) AMQP_MANAGER_URL is present");
216
216
  }
217
+
218
+ if (!settings.JOB_TOPIC_EXCHANGE) {
219
+ winston.error("(wab api) JOB_TOPIC_EXCHANGE is mandatory (?). Exit...");
220
+ } else {
221
+ JOB_TOPIC_EXCHANGE = settings.JOB_TOPIC_EXCHANGE;
222
+ winston.info("(wab api) JOB_TOPIC_EXCHANGE is present");
223
+ }
217
224
 
218
225
  }
219
226
 
@@ -220,7 +220,7 @@
220
220
  <p>Added Queue Manager for Whatsapp broadcast</p>
221
221
  <p>Bug fixes and performance improvements</p>
222
222
  </div>
223
- <p style="font-size: 12px; color: #676767; margin-bottom: 0px;">Version <b>0.1.54</b></p>
223
+ <p style="font-size: 12px; color: #676767; margin-bottom: 0px;">Version <b>0.1.55</b></p>
224
224
  </div>
225
225
 
226
226
  <div style="width: 100%; display: flex; flex-direction: row; justify-content: space-between; margin-bottom: 15px;">
@@ -13,7 +13,13 @@ class Scheduler {
13
13
  throw new Error('config.AMQP_MANAGER_URL is mandatory');
14
14
  }
15
15
 
16
+ if (!config.JOB_TOPIC_EXCHANGE) {
17
+ throw new Error('config.JOB_TOPIC_EXCHANGE is mandatory');
18
+ }
19
+
16
20
  this.AMQP_MANAGER_URL = config.AMQP_MANAGER_URL;
21
+ this.JOB_TOPIC_EXCHANGE = config.JOB_TOPIC_EXCHANGE;
22
+
17
23
  this.log = false;
18
24
  if (config.log) {
19
25
  this.log = config.log;
@@ -21,8 +27,8 @@ class Scheduler {
21
27
 
22
28
  jobManager = new JobManager(this.AMQP_MANAGER_URL, {
23
29
  debug: false,
24
- topic: "tiledesk-whatsapp_test",
25
- exchange: "tiledesk-whatsapp_test"
30
+ topic: this.JOB_TOPIC_EXCHANGE,
31
+ exchange: this.JOB_TOPIC_EXCHANGE
26
32
  });
27
33
  }
28
34