@peopl-health/nexus 4.2.9 → 4.2.10
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.
|
@@ -6,6 +6,8 @@ const { recordDeliveryAttempt } = require('./deliveryAttemptHelper');
|
|
|
6
6
|
|
|
7
7
|
const getMessaging = () => require('../core/NexusMessaging');
|
|
8
8
|
|
|
9
|
+
const TEMPLATE_BODY_LIMIT = 1024;
|
|
10
|
+
|
|
9
11
|
async function triggerTemplateRecovery(messageDoc, { source = 'reactive', messageSid = null } = {}) {
|
|
10
12
|
try {
|
|
11
13
|
if (!messageDoc?.body || !messageDoc?.numero || !messageDoc?._id) return;
|
|
@@ -45,12 +47,16 @@ async function triggerTemplateRecovery(messageDoc, { source = 'reactive', messag
|
|
|
45
47
|
|
|
46
48
|
let twilioContent;
|
|
47
49
|
let setupErr = null;
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
50
|
+
if (messageDoc.body.length > TEMPLATE_BODY_LIMIT) {
|
|
51
|
+
setupErr = new Error(`Body exceeds ${TEMPLATE_BODY_LIMIT}-char template limit (${messageDoc.body.length})`);
|
|
52
|
+
} else {
|
|
53
|
+
try {
|
|
54
|
+
twilioContent = await template.save();
|
|
55
|
+
const approvalName = `${templateName}_${Date.now()}`.toLowerCase().replace(/[^a-z0-9_]/g, '_');
|
|
56
|
+
await provider.submitForApproval(twilioContent.sid, approvalName, 'UTILITY');
|
|
57
|
+
} catch (err) {
|
|
58
|
+
setupErr = err;
|
|
59
|
+
}
|
|
54
60
|
}
|
|
55
61
|
|
|
56
62
|
await recordDeliveryAttempt({
|