@tiledesk/tiledesk-whatsapp-connector 0.1.19 → 0.1.20
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 +15 -3
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -584,6 +584,10 @@ router.post("/webhook/:project_id", async (req, res) => {
|
|
|
584
584
|
|
|
585
585
|
const filename = await util.downloadMedia(media.id);
|
|
586
586
|
console.log("File position: ", filename);
|
|
587
|
+
if (!filename) {
|
|
588
|
+
console.log("Unable to download media. Message not sent.");
|
|
589
|
+
res.status(500).send({ success: false, error: "unable to download media" })
|
|
590
|
+
}
|
|
587
591
|
let file_path = path.join(__dirname, 'tmp', filename);
|
|
588
592
|
|
|
589
593
|
const image_url = await util.uploadMedia(file_path, "images");
|
|
@@ -598,6 +602,10 @@ router.post("/webhook/:project_id", async (req, res) => {
|
|
|
598
602
|
|
|
599
603
|
const filename = await util.downloadMedia(media.id);
|
|
600
604
|
console.log("File position: ", filename);
|
|
605
|
+
if (!filename) {
|
|
606
|
+
console.log("Unable to download media. Message not sent.");
|
|
607
|
+
res.status(500).send({ success: false, error: "unable to download media" })
|
|
608
|
+
}
|
|
601
609
|
let file_path = path.join(__dirname, 'tmp', filename);
|
|
602
610
|
|
|
603
611
|
|
|
@@ -612,6 +620,10 @@ router.post("/webhook/:project_id", async (req, res) => {
|
|
|
612
620
|
|
|
613
621
|
const filename = await util.downloadMedia(media.id);
|
|
614
622
|
console.log("File position: ", filename);
|
|
623
|
+
if (!filename) {
|
|
624
|
+
console.log("Unable to download media. Message not sent.");
|
|
625
|
+
res.status(500).send({ success: false, error: "unable to download media" })
|
|
626
|
+
}
|
|
615
627
|
let file_path = path.join(__dirname, 'tmp', filename);
|
|
616
628
|
|
|
617
629
|
const media_url = await util.uploadMedia(file_path, "files");
|
|
@@ -656,7 +668,7 @@ router.get("/webhook/:project_id", async (req, res) => {
|
|
|
656
668
|
let mode = req.query["hub.mode"];
|
|
657
669
|
let token = req.query["hub.verify_token"];
|
|
658
670
|
let challenge = req.query["hub.challenge"];
|
|
659
|
-
|
|
671
|
+
|
|
660
672
|
console.log("**********")
|
|
661
673
|
console.log("mode: ", mode)
|
|
662
674
|
console.log("token: ", token)
|
|
@@ -681,7 +693,7 @@ router.get("/webhook/:project_id", async (req, res) => {
|
|
|
681
693
|
if (mode && token) {
|
|
682
694
|
// Check the mode and token sent are correct
|
|
683
695
|
if (mode === "subscribe" && token === VERIFY_TOKEN) {
|
|
684
|
-
|
|
696
|
+
|
|
685
697
|
// Respond with 200 OK and challenge token from the request
|
|
686
698
|
console.log("WEBHOOK_VERIFIED");
|
|
687
699
|
res.status(200).send(challenge);
|
|
@@ -745,7 +757,7 @@ function startApp(settings, callback) {
|
|
|
745
757
|
|
|
746
758
|
db.connect(settings.MONGODB_URL, () => {
|
|
747
759
|
console.log("KVBaseMongo successfully connected.");
|
|
748
|
-
|
|
760
|
+
|
|
749
761
|
if (callback) {
|
|
750
762
|
callback();
|
|
751
763
|
}
|