From 44f26077731c93c3e20bee89811a746f37046bca Mon Sep 17 00:00:00 2001 From: Alexander Borg Date: Mon, 15 Sep 2025 13:50:59 +0200 Subject: [PATCH] Fix jwt-token --- server/services/alertService.js | 9 +++++++-- server/tests/setup.js | 19 ++++++++++++++++++- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/server/services/alertService.js b/server/services/alertService.js index 7b7283c..f420f5e 100644 --- a/server/services/alertService.js +++ b/server/services/alertService.js @@ -61,11 +61,16 @@ class AlertService { const droneTypeInfo = getDroneTypeInfo(droneType); // Adjust threat level based on drone type and category - if (droneType === 2) { // Orlan - always critical regardless of distance + if (droneType === 2 && rssi >= -70) { // Orlan - escalate to critical only if within medium range or closer threatLevel = 'critical'; description = `CRITICAL THREAT: ${droneTypeInfo.name.toUpperCase()} DETECTED - IMMEDIATE RESPONSE REQUIRED`; actionRequired = true; - console.log(`🚨 ORLAN DRONE DETECTED: ${droneTypeInfo.name} - Force escalating to CRITICAL threat level (RSSI: ${rssi})`); + console.log(`🚨 ORLAN DRONE DETECTED: ${droneTypeInfo.name} - Escalating to CRITICAL threat level (RSSI: ${rssi})`); + } else if (droneType === 2) { // Orlan at long range - still high priority but not critical + if (threatLevel === 'low' || threatLevel === 'monitoring') threatLevel = 'medium'; + if (threatLevel === 'medium') threatLevel = 'high'; + description += ` - ${droneTypeInfo.name.toUpperCase()} DETECTED AT LONG RANGE`; + actionRequired = true; } else if (droneTypeInfo.threat_level === 'high' || droneTypeInfo.category.includes('Professional')) { // Professional/Commercial drone - escalate threat one level only if close enough if (rssi >= -70) { // Only escalate if medium distance or closer diff --git a/server/tests/setup.js b/server/tests/setup.js index ff62c89..1d0ccb7 100644 --- a/server/tests/setup.js +++ b/server/tests/setup.js @@ -108,7 +108,24 @@ async function teardownTestEnvironment() { */ async function cleanDatabase() { if (sequelize) { - await sequelize.sync({ force: true }); + try { + // Disable foreign key checks temporarily + await sequelize.query('PRAGMA foreign_keys = OFF'); + + // Force sync with drop and recreate + await sequelize.sync({ force: true }); + + // Re-enable foreign key checks + await sequelize.query('PRAGMA foreign_keys = ON'); + + // Reset test counter to ensure fresh unique IDs + testCounter = 0; + + console.log('✅ Database cleaned successfully'); + } catch (error) { + console.error('❌ Database cleanup failed:', error.message); + throw error; + } } }