Fix jwt-token

This commit is contained in:
2025-08-18 06:14:28 +02:00
parent c8c1cd95dd
commit c0d1fff02f
3 changed files with 15 additions and 6 deletions

View File

@@ -99,6 +99,11 @@ module.exports = (sequelize) => {
defaultValue: 'medium',
comment: 'Alert priority level'
},
min_threat_level: {
type: DataTypes.ENUM('monitoring', 'low', 'medium', 'high', 'critical'),
allowNull: true,
comment: 'Minimum threat level required to trigger alert'
},
created_at: {
type: DataTypes.DATE,
defaultValue: DataTypes.NOW

View File

@@ -89,6 +89,7 @@ async function seedDatabase() {
device_ids: [1], // Arlanda detector only
min_rssi: -85, // Alert on any detection
priority: 'critical',
min_threat_level: 'critical', // Only alert on critical threats
alert_channels: ['sms'],
sms_phone_number: '0736419592',
cooldown_period: 300, // 5 minutes between alerts
@@ -103,6 +104,7 @@ async function seedDatabase() {
device_ids: [2], // Muskö detector only
min_rssi: -85, // Alert on any detection
priority: 'critical',
min_threat_level: 'critical', // Only alert on critical threats
alert_channels: ['sms'],
sms_phone_number: '0739999999',
cooldown_period: 300, // 5 minutes between alerts
@@ -117,6 +119,7 @@ async function seedDatabase() {
device_ids: [3], // Royal Castle detector only
min_rssi: -85, // Alert on any detection
priority: 'critical',
min_threat_level: 'critical', // Only alert on critical threats
alert_channels: ['sms'],
sms_phone_number: '0739999999',
cooldown_period: 300, // 5 minutes between alerts

View File

@@ -338,14 +338,14 @@ class AlertService {
break;
case 'email':
if (rule.actions.email && user.email) {
alertLog = await this.sendEmailAlert(user.email, message, rule, detection, threatAssessment);
if (rule.alert_channels.includes('email') && (rule.email || user.email)) {
alertLog = await this.sendEmailAlert(rule.email || user.email, message, rule, detection, threatAssessment);
}
break;
case 'webhook':
if (rule.actions.webhook_url) {
alertLog = await this.sendWebhookAlert(rule.actions.webhook_url, detection, device, rule, threatAssessment);
if (rule.alert_channels.includes('webhook') && rule.webhook_url) {
alertLog = await this.sendWebhookAlert(rule.webhook_url, detection, device, rule, threatAssessment);
}
break;
@@ -365,8 +365,9 @@ class AlertService {
alert_rule_id: rule.id,
detection_id: detection.id,
alert_type: channel,
recipient: channel === 'sms' ? user.phone_number :
channel === 'email' ? user.email : rule.webhook_url,
recipient: channel === 'sms' ? (rule.sms_phone_number || 'SMS_CONFIGURED') :
channel === 'email' ? (rule.email || user.email || 'EMAIL_CONFIGURED') :
(rule.webhook_url || 'WEBHOOK_CONFIGURED'),
message: message,
status: 'failed',
error_message: channelError.message,