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