Fix instance name in get_bans and get_reports methods

This commit is contained in:
Théophile Diot 2024-01-25 14:55:11 +01:00
parent 17ae0acbbe
commit 12714a7702
No known key found for this signature in database
GPG key ID: 248FEA4BAE400D06

View file

@ -313,14 +313,14 @@ class Instances:
resp, instance_bans = instance.bans()
if not resp:
return []
return instance_bans[instance.name].get("data", [])
return instance_bans[instance.name if instance.name != "local" else "127.0.0.1"].get("data", [])
bans: List[dict[str, Any]] = []
for instance in self.get_instances():
resp, instance_bans = instance.bans()
if not resp:
continue
bans.extend(instance_bans[instance.name].get("data", []))
bans.extend(instance_bans[instance.name if instance.name != "local" else "127.0.0.1"].get("data", []))
bans.sort(key=lambda x: x["exp"])
@ -352,14 +352,14 @@ class Instances:
resp, instance_reports = instance.reports()
if not resp:
return []
return instance_reports[instance.name].get("msg", [])
return instance_reports[instance.name if instance.name != "local" else "127.0.0.1"].get("msg", [])
reports: List[dict[str, Any]] = []
for instance in self.get_instances():
resp, instance_reports = instance.reports()
if not resp:
continue
reports.extend(instance_reports[instance.name].get("msg", []))
reports.extend(instance_reports[instance.name if instance.name != "local" else "127.0.0.1"].get("msg", []))
reports.sort(key=lambda x: x["date"], reverse=True)