@tiledesk/tiledesk-whatsapp-connector 0.1.5 → 0.1.6

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
@@ -42,7 +42,7 @@ router.use(bodyParser.urlencoded({ extended: true }));
42
42
  var API_URL = null;
43
43
  var GRAPH_URL = null;
44
44
  var BASE_URL = null;
45
- var log = false;
45
+ var log = true;
46
46
 
47
47
  const db = new KVBaseMongo(kvbase_collection);
48
48
  /*
@@ -165,9 +165,9 @@ router.post('/update', async (req, res) => {
165
165
  subscription_id: settings.subscriptionId,
166
166
  }
167
167
  if (log) {
168
- console.log("Replacements: ", replacements);
168
+ console.log("Replacements: ", replacements);
169
169
  }
170
-
170
+
171
171
  var html = template(replacements);
172
172
  res.send(html);
173
173
  })
@@ -192,9 +192,9 @@ router.post('/update', async (req, res) => {
192
192
  tdClient.subscribe(subscription_info).then((data) => {
193
193
  let subscription = data;
194
194
  if (log) {
195
- console.log("\nSubscription: ", subscription)
195
+ console.log("\nSubscription: ", subscription)
196
196
  }
197
-
197
+
198
198
  let settings = {
199
199
  project_id: projectId,
200
200
  token: token,
@@ -223,9 +223,9 @@ router.post('/update', async (req, res) => {
223
223
  subscription_id: settings.subscriptionId,
224
224
  }
225
225
  if (log) {
226
- console.log("Replacements: ", replacements);
226
+ console.log("Replacements: ", replacements);
227
227
  }
228
-
228
+
229
229
  var html = template(replacements);
230
230
  res.send(html);
231
231
  })
@@ -240,7 +240,7 @@ router.post('/update', async (req, res) => {
240
240
  router.post('/disconnect', async (req, res) => {
241
241
  console.log("\n/disconnect")
242
242
  if (log) {
243
- console.log("/disconnect body: ", req.body)
243
+ console.log("/disconnect body: ", req.body)
244
244
  }
245
245
 
246
246
  let projectId = req.body.project_id;
@@ -277,9 +277,9 @@ router.post('/disconnect', async (req, res) => {
277
277
  proxy_url: proxy_url,
278
278
  }
279
279
  if (log) {
280
- console.log("Replacements: ", replacements);
280
+ console.log("Replacements: ", replacements);
281
281
  }
282
-
282
+
283
283
  var html = template(replacements);
284
284
  res.send(html);
285
285
  })
@@ -487,7 +487,7 @@ router.post("/webhook/:project_id", async (req, res) => {
487
487
  // tdClient.getRequests
488
488
  const tdChannel = new TiledeskChannel({ settings: settings, API_URL: API_URL })
489
489
  const response = await tdChannel.send(tiledeskJsonMessage, message_info);
490
- if (log) {
490
+ if (log) {
491
491
  console.log("Send response: ", response)
492
492
  }
493
493
 
@@ -550,7 +550,7 @@ function startApp(settings, callback) {
550
550
  if (!settings.MONGODB_URL) {
551
551
  throw new Error("settings.MONGODB_URL is mandatory");
552
552
  }
553
-
553
+
554
554
  if (!settings.API_URL) {
555
555
  throw new Error("settings.API_URL is mandatory");
556
556
  } else {
@@ -586,11 +586,6 @@ function startApp(settings, callback) {
586
586
 
587
587
  function readHTMLFile(templateName, callback) {
588
588
  console.log("Reading file: ", templateName)
589
- console.log("appRoot: ", appRoot)
590
- let file = appRoot + '/template' + templateName;
591
- console.log("file: ", file);
592
- console.log("*** appRoot: ", appRoot.toString());
593
- console.log("type: ", typeof(appRoot))
594
589
  fs.readFile(__dirname + '/template' + templateName, { encoding: 'utf-8' },
595
590
  function(err, html) {
596
591
  if (err) {
@@ -602,4 +597,4 @@ function readHTMLFile(templateName, callback) {
602
597
  })
603
598
  }
604
599
 
605
- module.exports = { router: router, startApp: startApp};
600
+ module.exports = { router: router, startApp: startApp };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tiledesk/tiledesk-whatsapp-connector",
3
- "version": "0.1.5",
3
+ "version": "0.1.6",
4
4
  "description": "Tiledesk Whatsapp connector",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -32,7 +32,7 @@ class TiledeskChannel {
32
32
  throw new Error('config.API_URL is mandatory');
33
33
  }
34
34
 
35
- this.log = false;
35
+ this.log = true;
36
36
  if (config.log) {
37
37
  this.log = config.log;
38
38
  }
@@ -104,8 +104,10 @@ class TiledeskChannel {
104
104
  let request_id;
105
105
  if (response.data.requests[0]) {
106
106
  request_id = response.data.requests[0].request_id;
107
+ console.log("Old request id: ", request_id);
107
108
  } else {
108
109
  request_id = new_request_id;
110
+ console.log("New request id: ", request_id);
109
111
  }
110
112
 
111
113
  if (this.log) {