mirror of
https://github.com/rzuasti/oott.git
synced 2026-07-08 19:21:54 +02:00
Record originating scanner on device events
So that consumers of the events API can tell whether a sighting came from the ARP scanner or the mDNS listener. Adds a DeviceEventScanner enum (Arp / Mdns) plumbed from each scanner's call site through to a new scanner column on device_events, exposed via the existing events endpoint and OpenAPI schema. Pre-existing rows are backfilled with 'ARP' since that was the only scanner before mDNS. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.7
parent
0e43194492
commit
d6cf9be412
@@ -2,6 +2,7 @@ use super::finder;
|
||||
use super::status;
|
||||
use crate::db;
|
||||
use crate::events;
|
||||
use crate::model::device_events::DeviceEventScanner;
|
||||
use crate::settings::get_settings;
|
||||
use chrono::Utc;
|
||||
use log::{debug, info};
|
||||
@@ -38,7 +39,12 @@ pub async fn scan() -> Result<(), Box<dyn std::error::Error>> {
|
||||
device.device_type.clone(),
|
||||
device.name.clone(),
|
||||
)?;
|
||||
events::trigger_existing_device(recorded_device, device.clone()).ok(); // Ignoring errors here, do not stop loop if notification delivery fails
|
||||
events::trigger_existing_device(
|
||||
recorded_device,
|
||||
device.clone(),
|
||||
DeviceEventScanner::Arp,
|
||||
)
|
||||
.ok(); // Ignoring errors here, do not stop loop if notification delivery fails
|
||||
}
|
||||
None => {
|
||||
// If it doesn't exist insert it
|
||||
@@ -48,7 +54,7 @@ pub async fn scan() -> Result<(), Box<dyn std::error::Error>> {
|
||||
);
|
||||
|
||||
db::devices::insert(device.clone())?;
|
||||
events::trigger_new_device(device.clone()).ok(); // Ignoring errors here, do not stop loop if notification delivery fails
|
||||
events::trigger_new_device(device.clone(), DeviceEventScanner::Arp).ok(); // Ignoring errors here, do not stop loop if notification delivery fails
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user