wingbot 3.62.0 → 3.63.0
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
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
const Router = require('../../src/Router');
|
|
2
|
+
const { compileWithState } = require('../../src/utils');
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
*
|
|
@@ -6,6 +7,7 @@ const Router = require('../../src/Router');
|
|
|
6
7
|
* @param {'any'|'image'|'audio'|'video'|'file'} params.type
|
|
7
8
|
* @param {string} params.variable
|
|
8
9
|
* @param {'array'|'string'} params.datatype
|
|
10
|
+
* @param {string} params.allowSuffixes
|
|
9
11
|
* @returns {import('../../src/Router').Middleware}
|
|
10
12
|
*/
|
|
11
13
|
module.exports = (params) => {
|
|
@@ -15,10 +17,21 @@ module.exports = (params) => {
|
|
|
15
17
|
* @param {import('../../src/Responder')} res
|
|
16
18
|
*/
|
|
17
19
|
const uploadPlugin = async (req, res) => {
|
|
20
|
+
|
|
21
|
+
const allowSuffixes = compileWithState(req, res, params.allowSuffixes)
|
|
22
|
+
.split(',')
|
|
23
|
+
.map((s) => s.toLowerCase().trim())
|
|
24
|
+
.filter((s) => !!s);
|
|
25
|
+
|
|
18
26
|
if (req.isAttachment()) {
|
|
27
|
+
const suffixOk = allowSuffixes.length === 0
|
|
28
|
+
|| req.attachments.every((a) => {
|
|
29
|
+
const [, suffix = ''] = a.payload.url.match(/\.([a-z0-9]+)(\?.+)?$/i) || [];
|
|
30
|
+
return allowSuffixes.includes(suffix.toLowerCase());
|
|
31
|
+
});
|
|
19
32
|
|
|
20
33
|
const typeOk = (!params.type || params.type === 'any')
|
|
21
|
-
|| req.attachments.every((a) => a.type === params.type);
|
|
34
|
+
|| (req.attachments.every((a) => a.type === params.type) && suffixOk);
|
|
22
35
|
|
|
23
36
|
if (!typeOk) {
|
|
24
37
|
await res.run('badType');
|
package/plugins/plugins.json
CHANGED
|
@@ -644,6 +644,11 @@
|
|
|
644
644
|
{ "value": "string", "label": "string" },
|
|
645
645
|
{ "value": "array", "label": "array of strings" }
|
|
646
646
|
]
|
|
647
|
+
},
|
|
648
|
+
{
|
|
649
|
+
"name": "allowSuffixes",
|
|
650
|
+
"label": "Allowed attachment suffixes (comma separated)",
|
|
651
|
+
"type": "text"
|
|
647
652
|
}
|
|
648
653
|
],
|
|
649
654
|
"items": [
|
|
@@ -536,69 +536,68 @@ function onInteractionHandler (
|
|
|
536
536
|
}))
|
|
537
537
|
);
|
|
538
538
|
|
|
539
|
-
if (
|
|
540
|
-
if (req.isText()) {
|
|
541
|
-
trackEvents.push({
|
|
542
|
-
type: TrackingType.TRAINING,
|
|
543
|
-
// @ts-ignore
|
|
544
|
-
lastAction,
|
|
545
|
-
category: asCategory(TrackingCategory.INTENT_DETECTION),
|
|
546
|
-
intent,
|
|
547
|
-
action,
|
|
548
|
-
label: text,
|
|
549
|
-
value: score >= ai.confidence ? 0 : 1,
|
|
550
|
-
...langsExtension
|
|
551
|
-
});
|
|
552
|
-
}
|
|
553
|
-
|
|
554
|
-
let actionCategory;
|
|
555
|
-
let label = noneAction;
|
|
556
|
-
|
|
557
|
-
if (isPassThread) {
|
|
558
|
-
actionCategory = TrackingCategory.HANDOVER_TO_BOT;
|
|
559
|
-
} else if (req.isSticker()) {
|
|
560
|
-
actionCategory = TrackingCategory.STICKER;
|
|
561
|
-
label = req.attachmentUrl(0);
|
|
562
|
-
} else if (req.isImage()) {
|
|
563
|
-
actionCategory = TrackingCategory.IMAGE;
|
|
564
|
-
label = req.attachmentUrl(0);
|
|
565
|
-
} else if (req.hasLocation()) {
|
|
566
|
-
actionCategory = TrackingCategory.LOCATION;
|
|
567
|
-
const { lat, long } = req.getLocation();
|
|
568
|
-
label = `${lat}, ${long}`;
|
|
569
|
-
} else if (isAttachment) {
|
|
570
|
-
actionCategory = TrackingCategory.ATTACHMENT;
|
|
571
|
-
label = req.attachment(0).type;
|
|
572
|
-
} else if (isText) {
|
|
573
|
-
actionCategory = TrackingCategory.TEXT;
|
|
574
|
-
label = text;
|
|
575
|
-
} else if (isQuickReply) {
|
|
576
|
-
actionCategory = TrackingCategory.QUICK_REPLY;
|
|
577
|
-
label = text;
|
|
578
|
-
} else if (req.isOptin()) {
|
|
579
|
-
actionCategory = TrackingCategory.OPT_IN;
|
|
580
|
-
} else if (req.isReferral()) {
|
|
581
|
-
actionCategory = TrackingCategory.REFERRAL;
|
|
582
|
-
} else if (isPostback) {
|
|
583
|
-
actionCategory = TrackingCategory.POSTBACK_BUTTON;
|
|
584
|
-
label = req.event.postback.title || (useExtendedScalars ? null : '(unknown)');
|
|
585
|
-
} else {
|
|
586
|
-
actionCategory = TrackingCategory.OTHER;
|
|
587
|
-
}
|
|
588
|
-
|
|
539
|
+
if (req.isText()) {
|
|
589
540
|
trackEvents.push({
|
|
590
|
-
|
|
591
|
-
|
|
541
|
+
type: TrackingType.TRAINING,
|
|
542
|
+
// @ts-ignore
|
|
592
543
|
lastAction,
|
|
593
|
-
category: asCategory(
|
|
544
|
+
category: asCategory(TrackingCategory.INTENT_DETECTION),
|
|
545
|
+
intent,
|
|
594
546
|
action,
|
|
595
|
-
label,
|
|
596
|
-
value,
|
|
597
|
-
pageCategory,
|
|
547
|
+
label: text,
|
|
548
|
+
value: score >= ai.confidence ? 0 : 1,
|
|
598
549
|
...langsExtension
|
|
599
550
|
});
|
|
600
551
|
}
|
|
601
552
|
|
|
553
|
+
let actionCategory;
|
|
554
|
+
let label = noneAction;
|
|
555
|
+
|
|
556
|
+
if (isPassThread) {
|
|
557
|
+
actionCategory = TrackingCategory.HANDOVER_TO_BOT;
|
|
558
|
+
} else if (req.isSticker()) {
|
|
559
|
+
actionCategory = TrackingCategory.STICKER;
|
|
560
|
+
label = req.attachmentUrl(0);
|
|
561
|
+
} else if (req.isImage()) {
|
|
562
|
+
actionCategory = TrackingCategory.IMAGE;
|
|
563
|
+
label = req.attachmentUrl(0);
|
|
564
|
+
} else if (req.hasLocation()) {
|
|
565
|
+
actionCategory = TrackingCategory.LOCATION;
|
|
566
|
+
const { lat, long } = req.getLocation();
|
|
567
|
+
label = `${lat}, ${long}`;
|
|
568
|
+
} else if (isAttachment) {
|
|
569
|
+
actionCategory = TrackingCategory.ATTACHMENT;
|
|
570
|
+
label = req.attachment(0).type;
|
|
571
|
+
} else if (isText) {
|
|
572
|
+
actionCategory = TrackingCategory.TEXT;
|
|
573
|
+
label = text;
|
|
574
|
+
} else if (isQuickReply) {
|
|
575
|
+
actionCategory = TrackingCategory.QUICK_REPLY;
|
|
576
|
+
label = text;
|
|
577
|
+
} else if (req.isOptin()) {
|
|
578
|
+
actionCategory = TrackingCategory.OPT_IN;
|
|
579
|
+
} else if (req.isReferral()) {
|
|
580
|
+
actionCategory = TrackingCategory.REFERRAL;
|
|
581
|
+
} else if (isPostback) {
|
|
582
|
+
actionCategory = TrackingCategory.POSTBACK_BUTTON;
|
|
583
|
+
label = req.event.postback.title || (useExtendedScalars ? null : '(unknown)');
|
|
584
|
+
} else {
|
|
585
|
+
actionCategory = TrackingCategory.OTHER;
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
trackEvents.push({
|
|
589
|
+
...(analyticsStorage.hasExtendedEvents ? actionMeta : {}),
|
|
590
|
+
type: TrackingType.CONVERSATION_EVENT,
|
|
591
|
+
lastAction,
|
|
592
|
+
category: asCategory(actionCategory),
|
|
593
|
+
action,
|
|
594
|
+
label,
|
|
595
|
+
value,
|
|
596
|
+
pageCategory,
|
|
597
|
+
nonInteractive,
|
|
598
|
+
...langsExtension
|
|
599
|
+
});
|
|
600
|
+
|
|
602
601
|
await Promise.all([
|
|
603
602
|
analyticsStorage.storeEvents(
|
|
604
603
|
pageId,
|