api/alfred: Keep old hood if empty field is sent

This suppresses hood change events if hood is lost due to
disconnection.

Normally, disconnects should be indicated by other events like
online/offline.

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
This commit is contained in:
Adrian Schmutzler 2018-11-30 18:25:56 +01:00
parent fae6e858b7
commit 49cefe2767
1 changed files with 6 additions and 2 deletions

View File

@ -94,10 +94,14 @@ def import_nodewatcher_xml(mysql, mac, xml, banned, hoodsv2, netifdict, hoodsdic
oldtime = olddata["sys_time"].timestamp()
if not (newtime > oldtime or newtime < (oldtime - 3600)):
return
# Keep hood if not set (V2 only, "" != None)
if router_update["hood"] == "":
router_update["hood"] = olddata["hood"]
else:
delete_router(mysql,router_id)
# keep hood up to date
# keep hood up to date (extremely rare case where no olddata but no hood)
if router_update["hood"] == "":
router_update["hood"] = "NoHood"
if not router_update["hood"]: