Fix jwt-token
This commit is contained in:
@@ -99,6 +99,11 @@ module.exports = (sequelize) => {
|
|||||||
defaultValue: 'medium',
|
defaultValue: 'medium',
|
||||||
comment: 'Alert priority level'
|
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: {
|
created_at: {
|
||||||
type: DataTypes.DATE,
|
type: DataTypes.DATE,
|
||||||
defaultValue: DataTypes.NOW
|
defaultValue: DataTypes.NOW
|
||||||
|
|||||||
@@ -89,6 +89,7 @@ async function seedDatabase() {
|
|||||||
device_ids: [1], // Arlanda detector only
|
device_ids: [1], // Arlanda detector only
|
||||||
min_rssi: -85, // Alert on any detection
|
min_rssi: -85, // Alert on any detection
|
||||||
priority: 'critical',
|
priority: 'critical',
|
||||||
|
min_threat_level: 'critical', // Only alert on critical threats
|
||||||
alert_channels: ['sms'],
|
alert_channels: ['sms'],
|
||||||
sms_phone_number: '0736419592',
|
sms_phone_number: '0736419592',
|
||||||
cooldown_period: 300, // 5 minutes between alerts
|
cooldown_period: 300, // 5 minutes between alerts
|
||||||
@@ -103,6 +104,7 @@ async function seedDatabase() {
|
|||||||
device_ids: [2], // Muskö detector only
|
device_ids: [2], // Muskö detector only
|
||||||
min_rssi: -85, // Alert on any detection
|
min_rssi: -85, // Alert on any detection
|
||||||
priority: 'critical',
|
priority: 'critical',
|
||||||
|
min_threat_level: 'critical', // Only alert on critical threats
|
||||||
alert_channels: ['sms'],
|
alert_channels: ['sms'],
|
||||||
sms_phone_number: '0739999999',
|
sms_phone_number: '0739999999',
|
||||||
cooldown_period: 300, // 5 minutes between alerts
|
cooldown_period: 300, // 5 minutes between alerts
|
||||||
@@ -117,6 +119,7 @@ async function seedDatabase() {
|
|||||||
device_ids: [3], // Royal Castle detector only
|
device_ids: [3], // Royal Castle detector only
|
||||||
min_rssi: -85, // Alert on any detection
|
min_rssi: -85, // Alert on any detection
|
||||||
priority: 'critical',
|
priority: 'critical',
|
||||||
|
min_threat_level: 'critical', // Only alert on critical threats
|
||||||
alert_channels: ['sms'],
|
alert_channels: ['sms'],
|
||||||
sms_phone_number: '0739999999',
|
sms_phone_number: '0739999999',
|
||||||
cooldown_period: 300, // 5 minutes between alerts
|
cooldown_period: 300, // 5 minutes between alerts
|
||||||
|
|||||||
@@ -338,14 +338,14 @@ class AlertService {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'email':
|
case 'email':
|
||||||
if (rule.actions.email && user.email) {
|
if (rule.alert_channels.includes('email') && (rule.email || user.email)) {
|
||||||
alertLog = await this.sendEmailAlert(user.email, message, rule, detection, threatAssessment);
|
alertLog = await this.sendEmailAlert(rule.email || user.email, message, rule, detection, threatAssessment);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'webhook':
|
case 'webhook':
|
||||||
if (rule.actions.webhook_url) {
|
if (rule.alert_channels.includes('webhook') && rule.webhook_url) {
|
||||||
alertLog = await this.sendWebhookAlert(rule.actions.webhook_url, detection, device, rule, threatAssessment);
|
alertLog = await this.sendWebhookAlert(rule.webhook_url, detection, device, rule, threatAssessment);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -365,8 +365,9 @@ class AlertService {
|
|||||||
alert_rule_id: rule.id,
|
alert_rule_id: rule.id,
|
||||||
detection_id: detection.id,
|
detection_id: detection.id,
|
||||||
alert_type: channel,
|
alert_type: channel,
|
||||||
recipient: channel === 'sms' ? user.phone_number :
|
recipient: channel === 'sms' ? (rule.sms_phone_number || 'SMS_CONFIGURED') :
|
||||||
channel === 'email' ? user.email : rule.webhook_url,
|
channel === 'email' ? (rule.email || user.email || 'EMAIL_CONFIGURED') :
|
||||||
|
(rule.webhook_url || 'WEBHOOK_CONFIGURED'),
|
||||||
message: message,
|
message: message,
|
||||||
status: 'failed',
|
status: 'failed',
|
||||||
error_message: channelError.message,
|
error_message: channelError.message,
|
||||||
|
|||||||
Reference in New Issue
Block a user