@tiledesk/tiledesk-whatsapp-connector 0.1.11 → 0.1.12
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 +7 -3
- package/package.json +1 -1
- package/tiledesk/TiledeskWhatsapp.js +8 -3
- package/tmp/example-file.txt +1 -0
- package/tmp/media-1y8xpl.jpeg +0 -0
- package/tmp/media-1y8xpv.jpeg +0 -0
- package/tmp/media-1y8xqd.jpeg +0 -0
- package/tmp/media-1y8xr4.jpeg +0 -0
- package/tmp/media-1y8xty.jpeg +0 -0
- package/tmp/media-1y8xvp.jpeg +0 -0
- package/tmp/media-1y8xx5.jpeg +0 -0
- package/tmp/media-1y8y0g.jpeg +0 -0
- package/tmp/media-1y8y4x.jpeg +0 -0
- package/tmp/media-1y8y5k.jpeg +0 -0
- package/tmp/media-1y8ya4.jpeg +0 -0
- package/tmp/media-1y8ya7.jpeg +0 -0
- package/tmp/media-1y8yek.jpeg +0 -0
- package/tmp/media-1y8yfg.jpeg +0 -0
- package/tmp/media-1y8ygr.jpeg +0 -0
- package/tmp/media-1y8yh4.jpeg +0 -0
- package/tmp/media-1y8yi1.jpeg +0 -0
- package/tmp/media-1y8yid.jpeg +0 -0
- package/tmp/media-1y8yks.jpeg +0 -0
- package/tmp/media-1y8ym4.mp4 +0 -0
- package/tmp/media-1y8yqe.jpeg +0 -0
- package/tmp/media-1y8yuv.jpeg +0 -0
- package/tmp/media-1y8yv9.jpeg +0 -0
package/index.js
CHANGED
|
@@ -452,8 +452,9 @@ router.post("/webhook/:project_id", async (req, res) => {
|
|
|
452
452
|
|
|
453
453
|
const filename = await util.downloadMedia(media.id);
|
|
454
454
|
console.log("File position: ", filename);
|
|
455
|
+
let file_path = path.join(__dirname, 'tmp', filename);
|
|
455
456
|
|
|
456
|
-
const image_url = await util.uploadMedia(
|
|
457
|
+
const image_url = await util.uploadMedia(file_path, "images");
|
|
457
458
|
console.log("image_url: ", image_url)
|
|
458
459
|
|
|
459
460
|
tiledeskJsonMessage = tlr.toTiledesk(whatsappChannelMessage, firstname, image_url);
|
|
@@ -465,8 +466,10 @@ router.post("/webhook/:project_id", async (req, res) => {
|
|
|
465
466
|
|
|
466
467
|
const filename = await util.downloadMedia(media.id);
|
|
467
468
|
console.log("File position: ", filename);
|
|
469
|
+
let file_path = path.join(__dirname, 'tmp', filename);
|
|
468
470
|
|
|
469
|
-
|
|
471
|
+
|
|
472
|
+
const media_url = await util.uploadMedia(file_path, "files");
|
|
470
473
|
console.log("image_url: ", media_url)
|
|
471
474
|
|
|
472
475
|
tiledeskJsonMessage = tlr.toTiledesk(whatsappChannelMessage, firstname, media_url);
|
|
@@ -477,8 +480,9 @@ router.post("/webhook/:project_id", async (req, res) => {
|
|
|
477
480
|
|
|
478
481
|
const filename = await util.downloadMedia(media.id);
|
|
479
482
|
console.log("File position: ", filename);
|
|
483
|
+
let file_path = path.join(__dirname, 'tmp', filename);
|
|
480
484
|
|
|
481
|
-
const media_url = await util.uploadMedia(
|
|
485
|
+
const media_url = await util.uploadMedia(file_path, "files");
|
|
482
486
|
console.log("image_url: ", media_url)
|
|
483
487
|
|
|
484
488
|
tiledeskJsonMessage = tlr.toTiledesk(whatsappChannelMessage, firstname, media_url);
|
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
const axios = require("axios").default;
|
|
2
2
|
const fs = require('fs');
|
|
3
3
|
const FormData = require('form-data');
|
|
4
|
+
const path = require('path');
|
|
4
5
|
|
|
5
6
|
class TiledeskWhatsapp {
|
|
6
7
|
|
|
@@ -74,7 +75,7 @@ class TiledeskWhatsapp {
|
|
|
74
75
|
'Authorization': "Bearer " + this.token
|
|
75
76
|
}
|
|
76
77
|
}).then(async (response) => {
|
|
77
|
-
console.log("response: ", response.data)
|
|
78
|
+
console.log("response 1: ", response.data)
|
|
78
79
|
|
|
79
80
|
let download_url = response.data.url;
|
|
80
81
|
let mime_type = response.data.mime_type;
|
|
@@ -82,7 +83,10 @@ class TiledeskWhatsapp {
|
|
|
82
83
|
let tid = this.getId();
|
|
83
84
|
let type = "media-" + tid + "." + extension;
|
|
84
85
|
|
|
85
|
-
|
|
86
|
+
let example_path = path.join(__dirname, '..', 'tmp', type);
|
|
87
|
+
console.log("read file: ", example_path)
|
|
88
|
+
|
|
89
|
+
const writeStream = fs.createWriteStream(example_path);
|
|
86
90
|
console.log("[Tiledesk Whatsapp] Downloading file...");
|
|
87
91
|
|
|
88
92
|
return await axios({
|
|
@@ -94,6 +98,7 @@ class TiledeskWhatsapp {
|
|
|
94
98
|
responseType: 'stream'
|
|
95
99
|
}).then((response) => {
|
|
96
100
|
|
|
101
|
+
console.log("response 2: ", response.data)
|
|
97
102
|
return new Promise((resolve, reject) => {
|
|
98
103
|
response.data.pipe(writeStream);
|
|
99
104
|
let error = null;
|
|
@@ -106,7 +111,7 @@ class TiledeskWhatsapp {
|
|
|
106
111
|
writeStream.on('close', () => {
|
|
107
112
|
if (!error) {
|
|
108
113
|
console.log("[Tiledesk Whatsapp] Download completed")
|
|
109
|
-
resolve(
|
|
114
|
+
resolve(type);
|
|
110
115
|
}
|
|
111
116
|
})
|
|
112
117
|
})
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Hello world!
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|