Fix jwt-token

This commit is contained in:
2025-09-09 19:54:42 +02:00
parent 23e144aec1
commit 447ac39fc1

View File

@@ -124,30 +124,27 @@ class DeviceHealthService {
async handleOfflineDevices(offlineDevices) {
for (const device of offlineDevices) {
try {
// Find all active alert rules that monitor device offline events
// Find all active alert rules that could apply to device offline events
// For now, we'll look for rules that monitor specific devices or all devices
const deviceOfflineRules = await AlertRule.findAll({
where: {
is_active: true,
[Op.or]: [
// Rules specifically for device offline monitoring
{ conditions: { device_offline: true } },
// Rules that include this specific device
{
[Op.and]: [
{ conditions: { device_ids: { [Op.contains]: [device.id] } } },
{ conditions: { device_offline: true } }
]
}
// Rules that monitor all devices (device_ids is null)
{ device_ids: null },
// Rules that specifically include this device
{ device_ids: { [Op.contains]: [device.id] } }
]
}
});
if (deviceOfflineRules.length === 0) {
console.log(`⚠️ No offline alert rules configured for device ${device.id} (${device.name})`);
console.log(`⚠️ No alert rules configured for device ${device.id} (${device.name})`);
continue;
}
// Trigger alerts for each matching rule
// For device offline events, we'll create a special alert
// since the current AlertRule model doesn't have specific device offline fields
for (const rule of deviceOfflineRules) {
await this.triggerDeviceOfflineAlert(rule, device);
}
@@ -171,13 +168,10 @@ class DeviceHealthService {
where: {
is_active: true,
[Op.or]: [
{ conditions: { device_offline: true } },
{
[Op.and]: [
{ conditions: { device_ids: { [Op.contains]: [device.id] } } },
{ conditions: { device_offline: true } }
]
}
// Rules that monitor all devices (device_ids is null)
{ device_ids: null },
// Rules that specifically include this device
{ device_ids: { [Op.contains]: [device.id] } }
]
}
});