Fix jwt-token
This commit is contained in:
@@ -7,6 +7,12 @@ const AlertService = require('../services/alertService');
|
||||
const DroneTrackingService = require('../services/droneTrackingService');
|
||||
const { getDroneTypeInfo, getDroneTypeName } = require('../utils/droneTypes');
|
||||
|
||||
// Configuration for debugging and data storage
|
||||
const DEBUG_CONFIG = {
|
||||
storeNoneDetections: process.env.STORE_NONE_DETECTIONS === 'true', // Store drone_type 0 for debugging
|
||||
logAllDetections: process.env.LOG_ALL_DETECTIONS === 'true' // Log all detections including type 0
|
||||
};
|
||||
|
||||
// Initialize services
|
||||
const alertService = new AlertService();
|
||||
const droneTracker = new DroneTrackingService();
|
||||
@@ -250,6 +256,26 @@ async function handleDetection(req, res) {
|
||||
});
|
||||
}
|
||||
|
||||
// Handle drone type 0 (None) - should not trigger alarms or be stored as detection
|
||||
if (detectionData.drone_type === 0) {
|
||||
if (DEBUG_CONFIG.logAllDetections) {
|
||||
console.log(`🔍 Debug: Drone type 0 (None) received from device ${detectionData.device_id}`);
|
||||
}
|
||||
|
||||
if (!DEBUG_CONFIG.storeNoneDetections) {
|
||||
// Don't store in database, just acknowledge receipt
|
||||
return res.status(200).json({
|
||||
success: true,
|
||||
message: 'Heartbeat received (no detection)',
|
||||
stored: false,
|
||||
debug: DEBUG_CONFIG.logAllDetections
|
||||
});
|
||||
}
|
||||
|
||||
// If debugging enabled, store but mark as debug data
|
||||
console.log(`🐛 Debug mode: Storing drone type 0 detection for debugging`);
|
||||
}
|
||||
|
||||
// Create detection record
|
||||
const detection = await DroneDetection.create({
|
||||
...detectionData,
|
||||
|
||||
Reference in New Issue
Block a user