Do not notify when a device's vendor is first deduced

Treat an empty->non-empty vendor transition as not a change, so first
deducing a vendor for a device that previously had none no longer raises
a "vendor changed" notification.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
rzuasti
2026-05-29 14:20:20 -04:00
co-authored by Claude Opus 4.7
parent 561fbdb548
commit ef420ad360
2 changed files with 6 additions and 5 deletions
+1 -1
View File
@@ -12,7 +12,7 @@
- [x] Add a data set (json) to store maps from vendors -> device type; modify the device creation so that it uses it automatically - [x] Add a data set (json) to store maps from vendors -> device type; modify the device creation so that it uses it automatically
- [x] Add an mDNS/Bonjour scanner - [x] Add an mDNS/Bonjour scanner
- [x] Extract the select_interface method and interface logic from ARP scanner to a centralized utility file - [x] Extract the select_interface method and interface logic from ARP scanner to a centralized utility file
- [ ] Figure out if we can univocally identify devices that mask their MAC address (like apple) - [x] Figure out if we can univocally identify devices that mask their MAC address (like apple)
- [ ] Add the scanner that triggered the event to the device_events table - [ ] Add the scanner that triggered the event to the device_events table
## Frontend ## Frontend
+5 -4
View File
@@ -26,9 +26,10 @@ fn display_name(device: &Device) -> &str {
// Whether a re-sighting represents a real vendor change. A scanner that cannot deduce a vendor // Whether a re-sighting represents a real vendor change. A scanner that cannot deduce a vendor
// reports an empty string; that is not a change (db::devices::update keeps the known vendor), so // reports an empty string; that is not a change (db::devices::update keeps the known vendor), so
// it must not raise a "vendor changed" notification either. // it must not raise a "vendor changed" notification either. Likewise, first deducing a vendor for a
// device that previously had none is not a change worth notifying about.
fn vendor_changed(existing: &str, new: &str) -> bool { fn vendor_changed(existing: &str, new: &str) -> bool {
!new.is_empty() && existing != new !existing.is_empty() && !new.is_empty() && existing != new
} }
// Private helper function to deliver messages // Private helper function to deliver messages
@@ -216,7 +217,7 @@ mod tests {
} }
#[test] #[test]
fn newly_deduced_vendor_from_empty_is_a_change() { fn newly_deduced_vendor_from_empty_is_not_a_change() {
assert!(vendor_changed("", "Apple, Inc.")); assert!(!vendor_changed("", "Apple, Inc."));
} }
} }