@peopl-health/nexus 3.8.17 → 3.8.19
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.
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
const { logger } = require('../utils/logger');
|
|
2
|
+
const { createEvent, safeEmit } = require('../utils/eventUtils');
|
|
2
3
|
|
|
3
4
|
const { validateAndAdaptBox } = require('../helpers/dashboardHelper');
|
|
4
5
|
|
|
5
6
|
const { getAllBoxes, getStatsById, updateBox, getDailyTrend } = require('../services/dashboardService');
|
|
6
7
|
|
|
8
|
+
const { getEventBus: getStatusEventBus } = require('../core/NexusMessaging');
|
|
9
|
+
|
|
7
10
|
const getDashboardController = async (req, res) => {
|
|
8
11
|
try {
|
|
9
12
|
const force = req.query.force === 'true';
|
|
@@ -42,7 +45,12 @@ const updateDashboardControllerById = async (req, res) => {
|
|
|
42
45
|
|
|
43
46
|
res.json({ success: true, message: 'Box updated', id: box.id });
|
|
44
47
|
|
|
45
|
-
await updateBox(box.id, box);
|
|
48
|
+
const updatedBox = await updateBox(box.id, box);
|
|
49
|
+
|
|
50
|
+
safeEmit(getStatusEventBus(), 'dashboard:updated', createEvent('dashboard:updated', {
|
|
51
|
+
...updatedBox
|
|
52
|
+
}));
|
|
53
|
+
|
|
46
54
|
} catch (error) {
|
|
47
55
|
logger.error('[DashboardController] Error updating dashboard:', { error: error.message, id: req.params?.id });
|
|
48
56
|
}
|
|
@@ -34,7 +34,7 @@ async function updateMessageStatus(messageSid, status, errorCode = null, errorMe
|
|
|
34
34
|
logger.warn('[MessageStatus] Message not found', { messageSid });
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
if (updated && status
|
|
37
|
+
if (updated && (status == 'failed' || status == 'undelivered')) {
|
|
38
38
|
addLinkedRecord(
|
|
39
39
|
Monitoreo_ID,
|
|
40
40
|
'undelivered_messages',
|
|
@@ -42,7 +42,8 @@ async function updateMessageStatus(messageSid, status, errorCode = null, errorMe
|
|
|
42
42
|
whatsapp_id: updated.numero,
|
|
43
43
|
error_code: errorCode || null,
|
|
44
44
|
status,
|
|
45
|
-
date: updated.timestamp
|
|
45
|
+
date: updated.timestamp,
|
|
46
|
+
message_id: updated.message_id
|
|
46
47
|
},
|
|
47
48
|
{
|
|
48
49
|
referenceTable: 'message_monitor',
|