Fix jwt-token
This commit is contained in:
@@ -40,7 +40,7 @@ module.exports = (sequelize) => {
|
||||
comment: 'Whether the device is approved to send data'
|
||||
},
|
||||
tenant_id: {
|
||||
type: DataTypes.INTEGER,
|
||||
type: DataTypes.UUID,
|
||||
allowNull: true,
|
||||
references: {
|
||||
model: 'tenants',
|
||||
|
||||
@@ -60,24 +60,37 @@ class AlertService {
|
||||
// Get drone type information using our comprehensive mapping
|
||||
const droneTypeInfo = getDroneTypeInfo(droneType);
|
||||
|
||||
// Store original distance-based assessment
|
||||
const distanceBasedThreat = threatLevel;
|
||||
|
||||
// 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: ${droneTypeInfo.name.toUpperCase()} DETECTED - IMMEDIATE RESPONSE REQUIRED`;
|
||||
actionRequired = true;
|
||||
console.log(`🚨 MILITARY DRONE DETECTED: ${droneTypeInfo.name} - Force escalating to CRITICAL threat level (RSSI: ${rssi})`);
|
||||
if (droneTypeInfo.category.includes('Military') && droneTypeInfo.name !== 'Unknown') {
|
||||
// Special handling for known military drones at very far distances
|
||||
// If it's a recognized military drone at long range, escalate to critical
|
||||
if (rssi < -80 && (droneTypeInfo.name === 'Orlan' || droneTypeInfo.name === 'Zala' || droneTypeInfo.name === 'Eleron')) {
|
||||
threatLevel = 'critical';
|
||||
description = `CRITICAL THREAT: ${droneTypeInfo.name.toUpperCase()} DETECTED - IMMEDIATE RESPONSE REQUIRED`;
|
||||
actionRequired = true;
|
||||
console.log(`🚨 MILITARY DRONE DETECTED: ${droneTypeInfo.name} - Force escalating to CRITICAL at long range (RSSI: ${rssi})`);
|
||||
} else {
|
||||
// For closer military drones, preserve distance-based assessment but add annotation
|
||||
description += ` - ${droneTypeInfo.name.toUpperCase()} MILITARY DRONE DETECTED`;
|
||||
console.log(`🚨 MILITARY DRONE DETECTED: ${droneTypeInfo.name} - Using distance-based threat level: ${threatLevel} (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';
|
||||
// Professional/Commercial drone - escalate threat one level from distance-based
|
||||
if (distanceBasedThreat === 'monitoring') threatLevel = 'low';
|
||||
else if (distanceBasedThreat === 'low') threatLevel = 'medium';
|
||||
else if (distanceBasedThreat === 'medium') threatLevel = 'high';
|
||||
|
||||
description += ` - ${droneTypeInfo.name.toUpperCase()} DETECTED`;
|
||||
actionRequired = true;
|
||||
actionRequired = (threatLevel !== 'low' && threatLevel !== 'monitoring');
|
||||
} else if (droneTypeInfo.category.includes('Racing')) {
|
||||
// Racing/Fast drone - escalate if close
|
||||
if (rssi >= -55 && threatLevel !== 'critical') {
|
||||
threatLevel = 'high';
|
||||
if (rssi >= -55) {
|
||||
if (distanceBasedThreat === 'monitoring') threatLevel = 'low';
|
||||
else if (distanceBasedThreat === 'low') threatLevel = 'medium';
|
||||
else if (distanceBasedThreat === 'medium') threatLevel = 'high';
|
||||
description += ` - HIGH-SPEED ${droneTypeInfo.name.toUpperCase()} DETECTED`;
|
||||
actionRequired = true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user