@peopl-health/nexus 4.2.14 → 4.2.16
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.
|
@@ -144,7 +144,7 @@ class TwilioProvider extends MessageProvider {
|
|
|
144
144
|
provider: 'twilio',
|
|
145
145
|
status: result.status,
|
|
146
146
|
result,
|
|
147
|
-
finalize: { sid: chunks ? null : result.sid, status: result.status?.toLowerCase() || null }
|
|
147
|
+
finalize: { sid: chunks ? null : result.sid, status: result.status?.toLowerCase() || null, body: contentSid ? messageData.body : null }
|
|
148
148
|
};
|
|
149
149
|
}
|
|
150
150
|
|
|
@@ -267,7 +267,7 @@ class NexusMessaging {
|
|
|
267
267
|
await this.messageStorage.finalizePendingMessage(parentId, result.finalize.sid, {
|
|
268
268
|
status: result.finalize.status,
|
|
269
269
|
updatedAt: new Date()
|
|
270
|
-
});
|
|
270
|
+
}, { body: result.finalize.body });
|
|
271
271
|
}
|
|
272
272
|
|
|
273
273
|
if (this.messageStorage && !providerStores) {
|
|
@@ -57,13 +57,20 @@ class MongoStorage {
|
|
|
57
57
|
return doc;
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
-
async finalizePendingMessage(docId, sid, statusInfo = null) {
|
|
60
|
+
async finalizePendingMessage(docId, sid, statusInfo = null, extras = null) {
|
|
61
61
|
const set = {};
|
|
62
62
|
if (statusInfo) {
|
|
63
63
|
for (const [k, v] of Object.entries(statusInfo)) set[`statusInfo.${k}`] = v;
|
|
64
64
|
}
|
|
65
|
+
if (extras?.body) set.body = extras.body;
|
|
65
66
|
if (Object.keys(set).length) {
|
|
66
|
-
await Message.
|
|
67
|
+
const doc = await Message.findOneAndUpdate({ _id: docId }, { $set: set }, { new: true });
|
|
68
|
+
if (extras?.body && doc?.numero) {
|
|
69
|
+
await Thread.updateOne(
|
|
70
|
+
{ code: doc.numero, lastMessageBody: '' },
|
|
71
|
+
{ $set: { lastMessageBody: extras.body } }
|
|
72
|
+
);
|
|
73
|
+
}
|
|
67
74
|
}
|
|
68
75
|
if (sid) {
|
|
69
76
|
await Message.updateOne(
|