Fix jwt-token

This commit is contained in:
2025-08-28 11:40:04 +02:00
parent f54a763ebb
commit 5919794408
6 changed files with 421 additions and 21 deletions

View File

@@ -1,6 +1,7 @@
const twilio = require('twilio');
const { AlertRule, AlertLog, User, Device, DroneDetection } = require('../models');
const { Op } = require('sequelize');
const { getDroneTypeInfo } = require('../utils/droneTypes');
class AlertService {
constructor() {
@@ -56,33 +57,28 @@ class AlertService {
actionRequired = false;
}
// Adjust threat level based on drone type (if classified)
const droneTypes = {
0: 'Consumer/Hobby',
1: 'Orlan/Military', // Orlan drones - highest threat
2: 'Professional/Commercial',
3: 'Racing/High-speed',
4: 'Unknown/Custom'
};
// Get drone type information using our comprehensive mapping
const droneTypeInfo = getDroneTypeInfo(droneType);
// CRITICAL: Orlan drones (type 1) - ALWAYS CRITICAL regardless of distance
if (droneType === 1) {
// Adjust threat level based on drone type and category
if (droneTypeInfo.threat_level === 'critical' || droneTypeInfo.category.includes('Military')) {
// Military/Combat drones - ALWAYS CRITICAL regardless of distance
threatLevel = 'critical';
description = 'CRITICAL THREAT: ORLAN MILITARY DRONE DETECTED - IMMEDIATE RESPONSE REQUIRED';
description = `CRITICAL THREAT: ${droneTypeInfo.name.toUpperCase()} DETECTED - IMMEDIATE RESPONSE REQUIRED`;
actionRequired = true;
console.log(`🚨 ORLAN DRONE DETECTED - Force escalating to CRITICAL threat level (RSSI: ${rssi})`);
} else if (droneType === 2) {
// Professional/Commercial drone - escalate threat
console.log(`🚨 MILITARY DRONE DETECTED: ${droneTypeInfo.name} - Force escalating to CRITICAL threat level (RSSI: ${rssi})`);
} else if (droneTypeInfo.threat_level === 'high' || droneTypeInfo.category.includes('Professional')) {
// Professional/Commercial drone - escalate threat one level
if (threatLevel === 'low') threatLevel = 'medium';
if (threatLevel === 'medium') threatLevel = 'high';
if (threatLevel === 'high') threatLevel = 'critical';
description += ' - PROFESSIONAL/COMMERCIAL DRONE DETECTED';
description += ` - ${droneTypeInfo.name.toUpperCase()} DETECTED`;
actionRequired = true;
} else if (droneType === 3) {
} else if (droneTypeInfo.category.includes('Racing')) {
// Racing/Fast drone - escalate if close
if (rssi >= -55 && threatLevel !== 'critical') {
threatLevel = 'high';
description += ' - HIGH-SPEED DRONE DETECTED';
description += ` - HIGH-SPEED ${droneTypeInfo.name.toUpperCase()} DETECTED`;
actionRequired = true;
}
}
@@ -91,7 +87,9 @@ class AlertService {
level: threatLevel,
estimatedDistance: Math.round(estimatedDistance),
rssi,
droneType: droneTypes[droneType] || 'Unknown',
droneType: droneTypeInfo.name,
droneCategory: droneTypeInfo.category,
threatLevel: droneTypeInfo.threat_level,
description,
requiresImmediateAction: actionRequired,
priority: threatLevel === 'critical' ? 1 : threatLevel === 'high' ? 2 : threatLevel === 'medium' ? 3 : 4