@tiledesk/tiledesk-whatsapp-connector 0.1.13 → 0.1.14
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/package.json
CHANGED
|
@@ -39,6 +39,7 @@ describe('Test Translator\n', function() {
|
|
|
39
39
|
recipient: 'support-group-62c3f10152dc7400352bab0d-86a2293e-wab-104777398965560-393484506627',
|
|
40
40
|
metadata: {
|
|
41
41
|
src: 'https://fakeimageurl.com/',
|
|
42
|
+
type: 'image/png'
|
|
42
43
|
},
|
|
43
44
|
attributes: {
|
|
44
45
|
userFullname: 'John Doe'
|
|
@@ -69,7 +70,8 @@ describe('Test Translator\n', function() {
|
|
|
69
70
|
type: 'video',
|
|
70
71
|
recipient: 'support-group-62c3f10152dc7400352bab0d-86a2293e-wab-104777398965560-393484506627',
|
|
71
72
|
metadata: {
|
|
72
|
-
src: 'https://fakevideourl.com/'
|
|
73
|
+
src: 'https://fakevideourl.com/',
|
|
74
|
+
type: 'video/mp4'
|
|
73
75
|
},
|
|
74
76
|
attributes: {
|
|
75
77
|
userFullname: 'John Doe'
|
|
@@ -100,7 +102,9 @@ describe('Test Translator\n', function() {
|
|
|
100
102
|
type: 'application',
|
|
101
103
|
recipient: 'support-group-62c3f10152dc7400352bab0d-86a2293e-wab-104777398965560-393484506627',
|
|
102
104
|
metadata: {
|
|
103
|
-
src: 'https://fakedocumenturl.com/'
|
|
105
|
+
src: 'https://fakedocumenturl.com/',
|
|
106
|
+
name: "Document name",
|
|
107
|
+
type: 'application/pdf'
|
|
104
108
|
},
|
|
105
109
|
attributes: {
|
|
106
110
|
userFullname: 'John Doe'
|
|
@@ -117,7 +121,7 @@ describe('Test Translator\n', function() {
|
|
|
117
121
|
assert(!whatsappJsonMessage.text);
|
|
118
122
|
assert(whatsappJsonMessage.document);
|
|
119
123
|
assert(whatsappJsonMessage.document.link === tiledeskChannelMessage.metadata.src);
|
|
120
|
-
assert(whatsappJsonMessage.document.caption === tiledeskChannelMessage.
|
|
124
|
+
assert(whatsappJsonMessage.document.caption === tiledeskChannelMessage.metadata.name);
|
|
121
125
|
if (log) {
|
|
122
126
|
console.log("(test) whatsappJsonMessage: ", whatsappJsonMessage);
|
|
123
127
|
}
|
|
@@ -63,7 +63,7 @@ class TiledeskWhatsappTranslator {
|
|
|
63
63
|
|
|
64
64
|
if (tiledeskChannelMessage.metadata) {
|
|
65
65
|
|
|
66
|
-
if (tiledeskChannelMessage.type.startsWith('image')) {
|
|
66
|
+
if (tiledeskChannelMessage.metadata.type.startsWith('image')) {
|
|
67
67
|
//if (tiledeskChannelMessage.metadata.type.startsWith('image/')) {
|
|
68
68
|
var imgUrl = tiledeskChannelMessage.metadata.src;
|
|
69
69
|
whatsapp_message.type = 'image'
|
|
@@ -71,9 +71,9 @@ class TiledeskWhatsappTranslator {
|
|
|
71
71
|
link: imgUrl,
|
|
72
72
|
caption: text
|
|
73
73
|
}
|
|
74
|
-
}
|
|
74
|
+
}
|
|
75
75
|
|
|
76
|
-
if (tiledeskChannelMessage.type.startsWith('video')) {
|
|
76
|
+
else if (tiledeskChannelMessage.metadata.type.startsWith('video')) {
|
|
77
77
|
//if (tiledeskChannelMessage.metadata.type.startsWith('video/')) {
|
|
78
78
|
var videoUrl = tiledeskChannelMessage.metadata.src;
|
|
79
79
|
whatsapp_message.type = 'document'
|
|
@@ -90,16 +90,21 @@ class TiledeskWhatsappTranslator {
|
|
|
90
90
|
*/
|
|
91
91
|
}
|
|
92
92
|
|
|
93
|
-
if (tiledeskChannelMessage.type.startsWith('application')) {
|
|
93
|
+
else if (tiledeskChannelMessage.metadata.type.startsWith('application')) {
|
|
94
94
|
//if (tiledeskChannelMessage.metadata.type.startsWith('application/')) {
|
|
95
95
|
var doc = tiledeskChannelMessage.metadata.src;
|
|
96
96
|
whatsapp_message.type = 'document'
|
|
97
97
|
whatsapp_message.document = {
|
|
98
98
|
link: doc,
|
|
99
|
-
caption:
|
|
99
|
+
caption: tiledeskChannelMessage.metadata.name
|
|
100
100
|
}
|
|
101
101
|
}
|
|
102
102
|
|
|
103
|
+
else {
|
|
104
|
+
console.log("file type not supported")
|
|
105
|
+
return null
|
|
106
|
+
}
|
|
107
|
+
|
|
103
108
|
if (this.log) {
|
|
104
109
|
console.log("[Translator] whatsapp message: ", whatsapp_message)
|
|
105
110
|
}
|
|
@@ -299,7 +304,15 @@ class TiledeskWhatsappTranslator {
|
|
|
299
304
|
|
|
300
305
|
} else {
|
|
301
306
|
// Skip message - non si deve fare qui!
|
|
302
|
-
|
|
307
|
+
whatsapp_message.text = { body: text };
|
|
308
|
+
|
|
309
|
+
if (this.log) {
|
|
310
|
+
console.log("[Translator] whatsapp message: ", whatsapp_message)
|
|
311
|
+
}
|
|
312
|
+
return whatsapp_message;
|
|
313
|
+
|
|
314
|
+
|
|
315
|
+
//return null
|
|
303
316
|
}
|
|
304
317
|
}
|
|
305
318
|
|