Fix jwt-token
This commit is contained in:
@@ -246,11 +246,53 @@ class DeviceHealthService {
|
||||
}
|
||||
} catch (channelError) {
|
||||
console.error(`❌ Failed to send ${channel} alert for offline device ${device.id}:`, channelError);
|
||||
|
||||
// Log the failed alert attempt to alert logs for audit purposes
|
||||
try {
|
||||
const AlertLog = require('../models/AlertLog');
|
||||
await AlertLog.create({
|
||||
alert_rule_id: rule ? rule.id : null,
|
||||
detection_id: null,
|
||||
alert_type: channel,
|
||||
recipient: channel === 'sms' ? rule?.sms_phone_number :
|
||||
channel === 'email' ? (rule?.email || rule?.user?.email) :
|
||||
channel === 'webhook' ? rule?.webhook_url : 'unknown',
|
||||
message: `Device offline alert failed for ${device.name}`,
|
||||
status: 'failed',
|
||||
sent_at: new Date(),
|
||||
external_id: null,
|
||||
priority: rule?.priority || 'medium',
|
||||
error_message: `Device health service error: ${channelError.message}`,
|
||||
alert_event_id: null
|
||||
});
|
||||
} catch (logError) {
|
||||
console.error(`❌ Failed to log alert failure:`, logError.message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
console.error(`❌ Error triggering offline alert for device ${device.id}:`, error);
|
||||
|
||||
// Log the general failure to alert logs for audit purposes
|
||||
try {
|
||||
const AlertLog = require('../models/AlertLog');
|
||||
await AlertLog.create({
|
||||
alert_rule_id: rule ? rule.id : null,
|
||||
detection_id: null,
|
||||
alert_type: 'system',
|
||||
recipient: 'system',
|
||||
message: `Failed to process device offline alert for ${device.name}`,
|
||||
status: 'failed',
|
||||
sent_at: new Date(),
|
||||
external_id: null,
|
||||
priority: 'high',
|
||||
error_message: `Device health service error: ${error.message}`,
|
||||
alert_event_id: null
|
||||
});
|
||||
} catch (logError) {
|
||||
console.error(`❌ Failed to log system alert failure:`, logError.message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -306,11 +348,53 @@ class DeviceHealthService {
|
||||
}
|
||||
} catch (channelError) {
|
||||
console.error(`❌ Failed to send ${channel} recovery alert for device ${device.id}:`, channelError);
|
||||
|
||||
// Log the failed alert attempt to alert logs for audit purposes
|
||||
try {
|
||||
const AlertLog = require('../models/AlertLog');
|
||||
await AlertLog.create({
|
||||
alert_rule_id: rule ? rule.id : null,
|
||||
detection_id: null,
|
||||
alert_type: channel,
|
||||
recipient: channel === 'sms' ? rule?.sms_phone_number :
|
||||
channel === 'email' ? (rule?.email || rule?.user?.email) :
|
||||
channel === 'webhook' ? rule?.webhook_url : 'unknown',
|
||||
message: `Device recovery alert failed for ${device.name}`,
|
||||
status: 'failed',
|
||||
sent_at: new Date(),
|
||||
external_id: null,
|
||||
priority: rule?.priority || 'medium',
|
||||
error_message: `Device health service recovery error: ${channelError.message}`,
|
||||
alert_event_id: null
|
||||
});
|
||||
} catch (logError) {
|
||||
console.error(`❌ Failed to log recovery alert failure:`, logError.message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
console.error(`❌ Error triggering recovery alert for device ${device.id}:`, error);
|
||||
|
||||
// Log the general failure to alert logs for audit purposes
|
||||
try {
|
||||
const AlertLog = require('../models/AlertLog');
|
||||
await AlertLog.create({
|
||||
alert_rule_id: rule ? rule.id : null,
|
||||
detection_id: null,
|
||||
alert_type: 'system',
|
||||
recipient: 'system',
|
||||
message: `Failed to process device recovery alert for ${device.name}`,
|
||||
status: 'failed',
|
||||
sent_at: new Date(),
|
||||
external_id: null,
|
||||
priority: 'high',
|
||||
error_message: `Device health service recovery error: ${error.message}`,
|
||||
alert_event_id: null
|
||||
});
|
||||
} catch (logError) {
|
||||
console.error(`❌ Failed to log system recovery alert failure:`, logError.message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user