@peopl-health/nexus 5.55.0-dev.8429 → 5.55.0-dev.8449

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.
@@ -181,17 +181,11 @@ function claimedAlert(alert) {
181
181
  return label && summary ? { label, summary } : null;
182
182
  }
183
183
 
184
- async function claimedText(code, messageId) {
185
- if (!messageId) return unansweredText(code);
186
- const [claimed] = await getMessages({ _id: messageId }, { limit: 1 });
187
- return claimed ? claimed.plainBody || claimed.body : unansweredText(code);
188
- }
189
-
190
- async function alertOpsForClaimedMessage({ code, alert, messageId = null }) {
184
+ async function alertOpsForClaimedMessage({ code, alert, text = null }) {
191
185
  const opsAlert = claimedAlert(alert);
192
186
  if (!code || !opsAlert) return false;
193
187
  try {
194
- return await recordPausedThreadMessage({ code, text: await claimedText(code, messageId), alert: opsAlert });
188
+ return await recordPausedThreadMessage({ code, text, alert: opsAlert });
195
189
  } catch (error) {
196
190
  logger.error('[PausedSafetyNet] Could not alert ops about a message the consumer answered', { code, error: error.message });
197
191
  return false;
@@ -572,7 +572,8 @@ class NexusMessaging {
572
572
  return this.phiProcessor.inData(
573
573
  messageData,
574
574
  this._saveMessageFn,
575
- async ({ body, _id }) => {
575
+ async ({ body }) => {
576
+ const plainText = messageData.body;
576
577
  messageData = { ...messageData, body };
577
578
  if (chatId) {
578
579
  // This is the common ingress for text, media, buttons, lists, and flows. Retire routine
@@ -592,7 +593,7 @@ class NexusMessaging {
592
593
  if (chatId && hasPreprocessingHandler()) {
593
594
  const claim = await runPreprocessingHandler({ code: chatId, context: 'incomingMessage', message: messageData });
594
595
  if (claim.handled) {
595
- if (claim.alert) await alertOpsForClaimedMessage({ code: chatId, alert: claim.alert, messageId: _id });
596
+ if (claim.alert) await alertOpsForClaimedMessage({ code: chatId, alert: claim.alert, text: plainText });
596
597
  return;
597
598
  }
598
599
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@peopl-health/nexus",
3
- "version": "5.55.0-dev.8429",
3
+ "version": "5.55.0-dev.8449",
4
4
  "description": "Core messaging and assistant library for WhatsApp communication platforms",
5
5
  "keywords": [
6
6
  "whatsapp",