@tiledesk/tiledesk-whatsapp-connector 1.0.4-rc4 → 1.0.4
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 +1 -1
- package/routes/api.js +2 -106
- package/template/template_detail.html +1 -1
- package/tiledesk/KVBaseMongo.js +0 -1
- package/tiledesk/WhatsappService.js +1 -1
package/package.json
CHANGED
package/routes/api.js
CHANGED
|
@@ -252,117 +252,13 @@ router.post('/tiledesk/broadcast/csv', upload.single('uploadFile'), async (req,
|
|
|
252
252
|
settings,
|
|
253
253
|
broadcast
|
|
254
254
|
};
|
|
255
|
-
|
|
255
|
+
|
|
256
256
|
const schedulerResult = await scheduler.goSchedule(data);
|
|
257
257
|
winston.verbose("(wab) scheduler result: ", schedulerResult);
|
|
258
258
|
|
|
259
|
-
res.status(200).send({ success: true, message: "Job started. Send messages in queue." })
|
|
259
|
+
res.status(200).send({ success: true, message: "Job started. Send messages in queue.", automation_id: final_transaction_id })
|
|
260
260
|
})
|
|
261
261
|
|
|
262
|
-
|
|
263
|
-
// const parser = csv.parseString({
|
|
264
|
-
// delimiter: ";",
|
|
265
|
-
// columns: true,
|
|
266
|
-
// trim: true,
|
|
267
|
-
// skip_empty_lines: true
|
|
268
|
-
// // });
|
|
269
|
-
|
|
270
|
-
// parser.on('readable', () => {
|
|
271
|
-
// let record;
|
|
272
|
-
// while ((record = parser.read())) {
|
|
273
|
-
// console.log("-> record: ", record)
|
|
274
|
-
// records.push(record);
|
|
275
|
-
// }
|
|
276
|
-
// });
|
|
277
|
-
|
|
278
|
-
// parser.on('error', err => {
|
|
279
|
-
// return res.status(400).json({ success: false, error: 'Invalid CSV format.' });
|
|
280
|
-
// });
|
|
281
|
-
|
|
282
|
-
// parser.on('end', async () => {
|
|
283
|
-
// console.log("records: ", records)
|
|
284
|
-
// const receiver_list = records.map(row => {
|
|
285
|
-
// console.log(Object.keys(row));
|
|
286
|
-
// console.log("row: ", row);
|
|
287
|
-
// console.log("header: ", row.header_0);
|
|
288
|
-
// console.log("phone: ", row.phone_number);
|
|
289
|
-
// const phone_number = row.phone_number.startsWith('+') ? row.phone_number : `+39${row.phone_number}`;
|
|
290
|
-
// const receiver = { phone_number };
|
|
291
|
-
|
|
292
|
-
// let header_params = [];
|
|
293
|
-
// let body_params = [];
|
|
294
|
-
// let buttons_params = [];
|
|
295
|
-
|
|
296
|
-
// for (const [key, value] of Object.entries(row)) {
|
|
297
|
-
// if (!value || key === 'phone_number') continue;
|
|
298
|
-
|
|
299
|
-
// if (key.startsWith('header')) {
|
|
300
|
-
// if (value.startsWith('http')) {
|
|
301
|
-
// header_params.push({
|
|
302
|
-
// type: "IMAGE",
|
|
303
|
-
// image: { link: value }
|
|
304
|
-
// });
|
|
305
|
-
// } else {
|
|
306
|
-
// header_params.push({
|
|
307
|
-
// type: "text",
|
|
308
|
-
// text: value
|
|
309
|
-
// });
|
|
310
|
-
// }
|
|
311
|
-
// } else if (key.startsWith('body')) {
|
|
312
|
-
// body_params.push({
|
|
313
|
-
// type: "text",
|
|
314
|
-
// text: value
|
|
315
|
-
// });
|
|
316
|
-
// } else if (key.startsWith('buttons')) {
|
|
317
|
-
// buttons_params.push({
|
|
318
|
-
// type: "text",
|
|
319
|
-
// text: value
|
|
320
|
-
// });
|
|
321
|
-
// }
|
|
322
|
-
// }
|
|
323
|
-
|
|
324
|
-
// if (header_params.length) receiver.header_params = header_params;
|
|
325
|
-
// if (body_params.length) receiver.body_params = body_params;
|
|
326
|
-
// if (buttons_params.length) receiver.buttons_params = buttons_params;
|
|
327
|
-
|
|
328
|
-
// return receiver;
|
|
329
|
-
// });
|
|
330
|
-
|
|
331
|
-
// console.log("receiver_list: ", receiver_list);
|
|
332
|
-
// return res.status(200).send(receiver_list);
|
|
333
|
-
|
|
334
|
-
// const final_transaction_id = transaction_id || `automation-request-${id_project}-${Date.now()}`;
|
|
335
|
-
|
|
336
|
-
// let settings = await utils.getSettingsByProjectId(id_project);
|
|
337
|
-
// if (!settings) {
|
|
338
|
-
// settings = await utils.getSettings(id_project, null);
|
|
339
|
-
// }
|
|
340
|
-
|
|
341
|
-
// if (!settings || !settings.business_account_id) {
|
|
342
|
-
// return res.status(400).json({ success: false, error: "WhatsApp not configured or missing business_account_id." });
|
|
343
|
-
// }
|
|
344
|
-
|
|
345
|
-
// const scheduler = new Scheduler({ AMQP_MANAGER_URL, JOB_TOPIC_EXCHANGE });
|
|
346
|
-
// const data_To_scheduler = {
|
|
347
|
-
// project_id: id_project,
|
|
348
|
-
// receiver_list,
|
|
349
|
-
// phone_number_id,
|
|
350
|
-
// transaction_id: final_transaction_id,
|
|
351
|
-
// template,
|
|
352
|
-
// settings,
|
|
353
|
-
// broadcast
|
|
354
|
-
// };
|
|
355
|
-
|
|
356
|
-
// winston.debug('(wab) data_To_scheduler (CSV): ', data_To_scheduler);
|
|
357
|
-
|
|
358
|
-
// const schedulerResult = await scheduler.goSchedule(data_To_scheduler);
|
|
359
|
-
// winston.verbose('(wab) schedulerResult: ', schedulerResult);
|
|
360
|
-
|
|
361
|
-
// return res.status(200).json({ success: true, message: "CSV job started." });
|
|
362
|
-
// });
|
|
363
|
-
|
|
364
|
-
// parser.write(req.file.buffer);
|
|
365
|
-
// parser.end();
|
|
366
262
|
});
|
|
367
263
|
|
|
368
264
|
|
|
@@ -150,7 +150,7 @@
|
|
|
150
150
|
const counter = document.getElementById('counter');
|
|
151
151
|
|
|
152
152
|
let header = template.components.find(c => c.type === "HEADER");
|
|
153
|
-
|
|
153
|
+
|
|
154
154
|
sBtn_text.innerText = header.format.charAt(0) + header.format.slice(1).toLowerCase();
|
|
155
155
|
if (sBtn_text.innerText == "None") {
|
|
156
156
|
inputHeader.style.display = "none";
|
package/tiledesk/KVBaseMongo.js
CHANGED
|
@@ -70,7 +70,6 @@ class KVBaseMongo {
|
|
|
70
70
|
winston.debug("Searching on " + this.db)
|
|
71
71
|
winston.debug("Searching on Collection " + this.KV_COLLECTION)
|
|
72
72
|
|
|
73
|
-
console.log("query: ", query)
|
|
74
73
|
this.db.collection(this.KV_COLLECTION).findOne(query, function(err, doc) {
|
|
75
74
|
if (err) {
|
|
76
75
|
winston.error("Error reading mongodb value", err);
|