@peopl-health/nexus 3.5.13 → 3.5.15

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.
@@ -770,7 +770,7 @@ const getReviewStatusController = async (req, res) => {
770
770
 
771
771
  res.json({
772
772
  success: true,
773
- threads: threads.map(t => ({ ...t.toObject(), code: maskSensitiveValue(t.code) })),
773
+ threads: threads.map(t => t.toObject()),
774
774
  pagination: { page, limit, total, totalPages: Math.ceil(total / limit) }
775
775
  });
776
776
  } catch (error) {
@@ -1,4 +1,4 @@
1
- const { Historial_Clinico_ID } = require('../config/airtableConfig');
1
+ const { Historial_Clinico_ID, Symptoms_ID } = require('../config/airtableConfig');
2
2
 
3
3
  const { logger } = require('../utils/logger');
4
4
  const { parseDate } = require('../utils/dateUtils');
@@ -27,11 +27,18 @@ const toMap = (arr, keyFn, valFn) => arr.reduce((m, item) => {
27
27
  }, {});
28
28
 
29
29
  const fetchConversationData = async (filter, skip, limit) => {
30
+ let triageIds = [];
31
+ if (filter === 'triage-last-month') {
32
+ const triageRecords = await getRecordByFilter(Symptoms_ID, 'estado_general', 'TRUE()', 'complete_triage_last_month', ['whatsapp_id']);
33
+ triageIds = (triageRecords || []).map(r => r.whatsapp_id).filter(Boolean);
34
+ }
35
+
30
36
  const filterMap = {
31
37
  unread: { ...BASE_MATCH, ...UNREAD_MATCH },
32
38
  recent: { ...BASE_MATCH, createdAt: { $gt: new Date(Date.now() - 86400000) } },
33
39
  'no-response': BASE_MATCH,
34
40
  'pending-review': BASE_MATCH,
41
+ 'triage-last-month': { ...BASE_MATCH, numero: { $in: triageIds } },
35
42
  all: BASE_MATCH
36
43
  };
37
44
  const filterConditions = filterMap[filter] || BASE_MATCH;
@@ -42,13 +42,14 @@ class MongoStorage {
42
42
  await insertMessage(values);
43
43
  logger.info('[MongoStorage] Message stored');
44
44
 
45
- const chatId = messageData.from || messageData.From;
46
- const messageId = messageData.id || messageData.message_id;
45
+ const chatId = messageData.from;
46
+ const messageId = messageData.id || messageData.messageId;
47
47
 
48
48
  if (chatId && messageId) {
49
49
  safeEmit(getStatusEventBus(), 'message:new', createEvent('message:new', {
50
50
  messageId,
51
51
  from: chatId,
52
+ code: messageData.fromMe ? messageData.code : chatId,
52
53
  body: messageData.body || messageData.message || '',
53
54
  media: messageData.media || null,
54
55
  type: messageData.interactive ? 'interactive' : messageData.media ? 'media' : 'message'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@peopl-health/nexus",
3
- "version": "3.5.13",
3
+ "version": "3.5.15",
4
4
  "description": "Core messaging and assistant library for WhatsApp communication platforms",
5
5
  "keywords": [
6
6
  "whatsapp",