@tiledesk/tiledesk-whatsapp-connector 0.1.59 → 0.1.61
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 +23 -25
- package/package.json +1 -1
- package/template/detail.html +10 -11
- package/tiledesk/TiledeskChannel.js +21 -1
package/index.js
CHANGED
|
@@ -495,9 +495,9 @@ router.get("/direct/tiledesk", async (req, res) => {
|
|
|
495
495
|
.then((response) => {
|
|
496
496
|
winston.verbose(
|
|
497
497
|
"(wab) Message sent to WhatsApp! " +
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
498
|
+
response.status +
|
|
499
|
+
" " +
|
|
500
|
+
response.statusText
|
|
501
501
|
);
|
|
502
502
|
})
|
|
503
503
|
.catch((err) => {
|
|
@@ -592,9 +592,9 @@ router.post("/tiledesk/broadcast", async (req, res) => {
|
|
|
592
592
|
.then((response) => {
|
|
593
593
|
winston.verbose(
|
|
594
594
|
"(wab) Message sent to WhatsApp! " +
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
595
|
+
response.status +
|
|
596
|
+
" " +
|
|
597
|
+
response.statusText
|
|
598
598
|
);
|
|
599
599
|
messages_sent += 1;
|
|
600
600
|
i += 1;
|
|
@@ -853,9 +853,9 @@ router.post("/tiledesk", async (req, res) => {
|
|
|
853
853
|
.then((response) => {
|
|
854
854
|
winston.verbose(
|
|
855
855
|
"(wab) Message sent to WhatsApp! " +
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
856
|
+
response.status +
|
|
857
|
+
" " +
|
|
858
|
+
response.statusText
|
|
859
859
|
);
|
|
860
860
|
i += 1;
|
|
861
861
|
if (i < commands.length) {
|
|
@@ -905,9 +905,9 @@ router.post("/tiledesk", async (req, res) => {
|
|
|
905
905
|
.then((response) => {
|
|
906
906
|
winston.verbose(
|
|
907
907
|
"(wab) Message sent to WhatsApp! " +
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
908
|
+
response.status +
|
|
909
|
+
" " +
|
|
910
|
+
response.statusText
|
|
911
911
|
);
|
|
912
912
|
})
|
|
913
913
|
.catch((err) => {
|
|
@@ -978,7 +978,7 @@ router.post("/webhook/:project_id", async (req, res) => {
|
|
|
978
978
|
let settings = await db.get(CONTENT_KEY);
|
|
979
979
|
winston.debug("(wab) settings: ", settings);
|
|
980
980
|
*/
|
|
981
|
-
|
|
981
|
+
|
|
982
982
|
if (!settings) {
|
|
983
983
|
winston.verbose("(wab) No settings found. Exit..");
|
|
984
984
|
return res.sendStatus(200);
|
|
@@ -1139,8 +1139,8 @@ router.post("/webhook/:project_id", async (req, res) => {
|
|
|
1139
1139
|
if (!filename) {
|
|
1140
1140
|
winston.debug(
|
|
1141
1141
|
"(wab) Unable to download media with id " +
|
|
1142
|
-
|
|
1143
|
-
|
|
1142
|
+
media.id +
|
|
1143
|
+
". Message not sent."
|
|
1144
1144
|
);
|
|
1145
1145
|
return res
|
|
1146
1146
|
.status(500)
|
|
@@ -1165,8 +1165,8 @@ router.post("/webhook/:project_id", async (req, res) => {
|
|
|
1165
1165
|
if (!filename) {
|
|
1166
1166
|
winston.debug(
|
|
1167
1167
|
"(wab) Unable to download media with id " +
|
|
1168
|
-
|
|
1169
|
-
|
|
1168
|
+
media.id +
|
|
1169
|
+
". Message not sent."
|
|
1170
1170
|
);
|
|
1171
1171
|
return res
|
|
1172
1172
|
.status(500)
|
|
@@ -1191,8 +1191,8 @@ router.post("/webhook/:project_id", async (req, res) => {
|
|
|
1191
1191
|
if (!filename) {
|
|
1192
1192
|
winston.debug(
|
|
1193
1193
|
"(wab) Unable to download media with id " +
|
|
1194
|
-
|
|
1195
|
-
|
|
1194
|
+
media.id +
|
|
1195
|
+
". Message not sent."
|
|
1196
1196
|
);
|
|
1197
1197
|
return res
|
|
1198
1198
|
.status(500)
|
|
@@ -1217,8 +1217,8 @@ router.post("/webhook/:project_id", async (req, res) => {
|
|
|
1217
1217
|
if (!filename) {
|
|
1218
1218
|
winston.debug(
|
|
1219
1219
|
"(wab) Unable to download media with id " +
|
|
1220
|
-
|
|
1221
|
-
|
|
1220
|
+
media.id +
|
|
1221
|
+
". Message not sent."
|
|
1222
1222
|
);
|
|
1223
1223
|
return res
|
|
1224
1224
|
.status(500)
|
|
@@ -1284,7 +1284,7 @@ router.post("/webhook/:project_id", async (req, res) => {
|
|
|
1284
1284
|
let settings = await db.get(CONTENT_KEY);
|
|
1285
1285
|
winston.debug("(wab) settings: ", settings);
|
|
1286
1286
|
*/
|
|
1287
|
-
|
|
1287
|
+
|
|
1288
1288
|
const tdClient = new TiledeskClient({
|
|
1289
1289
|
projectId: project_id,
|
|
1290
1290
|
token: settings.token,
|
|
@@ -1605,9 +1605,7 @@ async function startApp(settings, callback) {
|
|
|
1605
1605
|
}
|
|
1606
1606
|
|
|
1607
1607
|
if (!settings.JOB_TOPIC_EXCHANGE) {
|
|
1608
|
-
winston.
|
|
1609
|
-
"(wab) JOB_TOPIC_EXCHANGE should be present. Using default value"
|
|
1610
|
-
);
|
|
1608
|
+
winston.info("(wab) JOB_TOPIC_EXCHANGE should be present. Using default value");
|
|
1611
1609
|
JOB_TOPIC_EXCHANGE = "tiledesk-whatsapp";
|
|
1612
1610
|
} else {
|
|
1613
1611
|
JOB_TOPIC_EXCHANGE = settings.JOB_TOPIC_EXCHANGE;
|
package/package.json
CHANGED
package/template/detail.html
CHANGED
|
@@ -216,35 +216,34 @@
|
|
|
216
216
|
|
|
217
217
|
<div style="width: 100%; display: flex; flex-direction: row; justify-content: space-between; margin-bottom: 15px;">
|
|
218
218
|
<div>
|
|
219
|
-
<p
|
|
219
|
+
<p>Bug fixes and performance improvements</p>
|
|
220
220
|
</div>
|
|
221
|
-
<p style="font-size: 12px; color: #676767; margin-bottom: 0px;">Version <b>0.1.
|
|
221
|
+
<p style="font-size: 12px; color: #676767; margin-bottom: 0px;">Version <b>0.1.61</b></p>
|
|
222
222
|
</div>
|
|
223
223
|
|
|
224
|
-
|
|
225
224
|
<div style="width: 100%; display: flex; flex-direction: row; justify-content: space-between; margin-bottom: 15px;">
|
|
226
225
|
<div>
|
|
227
|
-
<p>Added Messages Logs for WhatsApp broadcast</p>
|
|
228
|
-
<p>Added Queue Manager for Whatsapp broadcast</p>
|
|
229
226
|
<p>Bug fixes and performance improvements</p>
|
|
230
227
|
</div>
|
|
231
|
-
<p style="font-size: 12px; color: #676767; margin-bottom: 0px;">Version <b>0.1.
|
|
228
|
+
<p style="font-size: 12px; color: #676767; margin-bottom: 0px;">Version <b>0.1.60</b></p>
|
|
232
229
|
</div>
|
|
233
|
-
|
|
230
|
+
|
|
234
231
|
<div style="width: 100%; display: flex; flex-direction: row; justify-content: space-between; margin-bottom: 15px;">
|
|
235
232
|
<div>
|
|
236
|
-
<p>
|
|
233
|
+
<p style="margin-bottom: 0px">Added Meta message forwarding</p>
|
|
237
234
|
</div>
|
|
238
|
-
<p style="font-size: 12px; color: #676767; margin-bottom: 0px;">Version <b>0.1.
|
|
235
|
+
<p style="font-size: 12px; color: #676767; margin-bottom: 0px;">Version <b>0.1.59</b></p>
|
|
239
236
|
</div>
|
|
240
237
|
|
|
238
|
+
|
|
241
239
|
<div style="width: 100%; display: flex; flex-direction: row; justify-content: space-between; margin-bottom: 15px;">
|
|
242
240
|
<div>
|
|
241
|
+
<p>Added Messages Logs for WhatsApp broadcast</p>
|
|
242
|
+
<p>Added Queue Manager for Whatsapp broadcast</p>
|
|
243
243
|
<p>Bug fixes and performance improvements</p>
|
|
244
244
|
</div>
|
|
245
|
-
<p style="font-size: 12px; color: #676767; margin-bottom: 0px;">Version <b>0.1.
|
|
245
|
+
<p style="font-size: 12px; color: #676767; margin-bottom: 0px;">Version <b>0.1.55</b></p>
|
|
246
246
|
</div>
|
|
247
|
-
|
|
248
247
|
|
|
249
248
|
<hr style="margin-top: 50px; margin-bottom: 20px">
|
|
250
249
|
|
|
@@ -81,6 +81,7 @@ class TiledeskChannel {
|
|
|
81
81
|
}
|
|
82
82
|
|
|
83
83
|
var customToken = jwt.sign(payload, this.settings.secret);
|
|
84
|
+
console.log("\n\ncustomToken: ", customToken)
|
|
84
85
|
|
|
85
86
|
return await axios({
|
|
86
87
|
url: this.API_URL + "/auth/signinWithCustomToken",
|
|
@@ -93,7 +94,8 @@ class TiledeskChannel {
|
|
|
93
94
|
}).then((response) => {
|
|
94
95
|
|
|
95
96
|
let token = response.data.token;
|
|
96
|
-
|
|
97
|
+
token = this.fixToken(token);
|
|
98
|
+
|
|
97
99
|
return axios({
|
|
98
100
|
url: this.API_URL + `/${this.settings.project_id}/requests/me?channel=${messageInfo.channel}`,
|
|
99
101
|
headers: {
|
|
@@ -198,7 +200,9 @@ class TiledeskChannel {
|
|
|
198
200
|
data: {},
|
|
199
201
|
method: 'POST'
|
|
200
202
|
}).then((response) => {
|
|
203
|
+
|
|
201
204
|
let token = response.data.token;
|
|
205
|
+
token = this.fixToken(token);
|
|
202
206
|
|
|
203
207
|
return axios({
|
|
204
208
|
url: this.API_URL + `/${this.settings.project_id}/requests/${new_request_id}/messages`,
|
|
@@ -269,6 +273,22 @@ class TiledeskChannel {
|
|
|
269
273
|
}
|
|
270
274
|
})
|
|
271
275
|
}
|
|
276
|
+
|
|
277
|
+
fixToken(token) {
|
|
278
|
+
|
|
279
|
+
let index = token.lastIndexOf("JWT ");
|
|
280
|
+
let new_token = token.substring(index + 4);
|
|
281
|
+
|
|
282
|
+
return 'JWT ' + new_token;
|
|
283
|
+
|
|
284
|
+
/*
|
|
285
|
+
if (token.startsWith('JWT ')) {
|
|
286
|
+
return token
|
|
287
|
+
} else {
|
|
288
|
+
return 'JWT ' + token
|
|
289
|
+
}
|
|
290
|
+
*/
|
|
291
|
+
}
|
|
272
292
|
|
|
273
293
|
}
|
|
274
294
|
|