@tiledesk/tiledesk-whatsapp-connector 0.1.63 → 0.1.65

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
@@ -742,6 +742,11 @@ router.post("/tiledesk", async (req, res) => {
742
742
  return res.sendStatus(200);
743
743
  }
744
744
 
745
+ if (attributes && attributes.subtype === "private") {
746
+ winston.verbose("(wab) Skip subtype (private)");
747
+ return res.sendStatus(200);
748
+ }
749
+
745
750
  if (attributes && attributes.subtype === "info/support") {
746
751
  winston.verbose("(wab) Skip subtype: " + attributes.subtype);
747
752
  return res.sendStatus(200);
@@ -1612,29 +1617,37 @@ async function startApp(settings, callback) {
1612
1617
  winston.info("(wab) JOB_TOPIC_EXCHANGE is present");
1613
1618
  }
1614
1619
 
1615
- let LOG_MONGODB_URL;
1616
- if (!settings.LOG_MONGODB_URL) {
1617
- LOG_MONGODB_URL = settings.MONGODB_URL;
1618
- } else {
1619
- LOG_MONGODB_URL = settings.LOG_MONGODB_URL;
1620
+ // For test only
1621
+ if (settings.LOG_MONGODB_URL) {
1622
+ /**
1623
+ * Connect with a different Database
1624
+ */
1625
+ // mongoose
1626
+ // .connect(settings.LOG_MONGODB_URL)
1627
+ // .then(() => {
1628
+ // winston.info("Mongoose DB Connected");
1629
+ // })
1630
+ // .catch((err) => {
1631
+ // winston.error("(Mongoose) Unable to connect with MongoDB ", err);
1632
+ // });
1620
1633
  }
1621
1634
 
1622
- mongoose
1623
- .connect(LOG_MONGODB_URL)
1624
- .then(() => {
1625
- winston.info("Mongoose DB Connected");
1635
+ if (settings.dbconnection) {
1636
+ db.reuseConnection(settings.dbconnection, () => {
1637
+ winston.info("(wab) KVBaseMongo reused exsisting db connection");
1638
+ if (callback) {
1639
+ callback(null);
1640
+ }
1626
1641
  })
1627
- .catch((err) => {
1628
- winston.error("(Mongoose) Unable to connect with MongoDB ", err);
1642
+ } else {
1643
+ db.connect(settings.MONGODB_URL, () => {
1644
+ winston.info("(wab) KVBaseMongo successfully connected.");
1645
+
1646
+ if (callback) {
1647
+ callback(null);
1648
+ }
1629
1649
  });
1630
-
1631
- db.connect(settings.MONGODB_URL, () => {
1632
- winston.info("(wab) KVBaseMongo successfully connected.");
1633
-
1634
- if (callback) {
1635
- callback(null);
1636
- }
1637
- });
1650
+ }
1638
1651
 
1639
1652
  api.startRoute(
1640
1653
  {