@peopl-health/nexus 4.1.0 → 4.1.1

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.
@@ -136,13 +136,13 @@ class TwilioProvider extends MessageProvider {
136
136
  result = await this.twilioClient.messages.create(sends[i]);
137
137
  } catch (twilioErr) {
138
138
  await recordDeliveryAttempt({
139
- messageData, messageId: pending?._id, kind,
139
+ messageData, messageId: pending?._id, kind, body: sends[i].body || null,
140
140
  errorSource: 'twilio_sync',
141
141
  errorCode: twilioErr.code, errorMessage: twilioErr.message
142
142
  });
143
143
  throw twilioErr;
144
144
  }
145
- await recordDeliveryAttempt({ messageData, messageId: pending?._id, twilioResult: result, kind });
145
+ await recordDeliveryAttempt({ messageData, messageId: pending?._id, twilioResult: result, kind, body: sends[i].body || null });
146
146
  if (i < sends.length - 1) await new Promise(r => setTimeout(r, 100));
147
147
  }
148
148
 
@@ -4,7 +4,7 @@ const { Message } = require('../models/messageModel');
4
4
  const { DeliveryAttempt } = require('../models/deliveryAttemptModel');
5
5
 
6
6
  async function recordDeliveryAttempt({
7
- messageData = null, messageId = null, twilioResult = null, kind,
7
+ messageData = null, messageId = null, twilioResult = null, kind, body = null,
8
8
  errorSource = null, errorCode = null, errorMessage = null
9
9
  }) {
10
10
  const sid = twilioResult?.sid || null;
@@ -30,6 +30,7 @@ async function recordDeliveryAttempt({
30
30
  kind,
31
31
  twilioSid: sid,
32
32
  contentSid: messageData?.contentSid || null,
33
+ body,
33
34
  status,
34
35
  errorSource,
35
36
  errorCode,
@@ -148,7 +148,8 @@ class TemplateApprovalJob extends BaseJob {
148
148
  messageData: { contentSid: templateSid },
149
149
  messageId: message._id,
150
150
  twilioResult: { sid: recoveryMessageId, status: sendResult?.status },
151
- kind: 'recovery_template'
151
+ kind: 'recovery_template',
152
+ body: message.body
152
153
  });
153
154
 
154
155
  provider.deleteTemplate(templateSid).catch((deleteErr) =>
@@ -17,6 +17,7 @@ const deliveryAttemptSchema = new mongoose.Schema({
17
17
  },
18
18
  twilioSid: { type: String, default: null },
19
19
  contentSid: { type: String, default: null },
20
+ body: { type: String, default: null },
20
21
  status: {
21
22
  type: String,
22
23
  enum: STATUS_VALUES,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@peopl-health/nexus",
3
- "version": "4.1.0",
3
+ "version": "4.1.1",
4
4
  "description": "Core messaging and assistant library for WhatsApp communication platforms",
5
5
  "keywords": [
6
6
  "whatsapp",