mirror of
https://codeberg.org/rimu/pyfedi
synced 2025-01-23 19:36:56 -08:00
Exclude blocked instances from linked instances in federated_instances response
This commit is contained in:
parent
57191c2c23
commit
e2d3f6d23d
1 changed files with 6 additions and 5 deletions
|
@ -206,17 +206,18 @@ def lemmy_federated_instances():
|
|||
linked = []
|
||||
allowed = []
|
||||
blocked = []
|
||||
for instance in AllowedInstances.query.all():
|
||||
allowed.append({"id": instance.id, "domain": instance.domain, "published": utcnow(), "updated": utcnow()})
|
||||
for instance in BannedInstances.query.all():
|
||||
blocked.append({"id": instance.id, "domain": instance.domain, "published": utcnow(), "updated": utcnow()})
|
||||
for instance in instances:
|
||||
instance_data = {"id": instance.id, "domain": instance.domain, "published": instance.created_at.isoformat(), "updated": instance.updated_at.isoformat()}
|
||||
if instance.software:
|
||||
instance_data['software'] = instance.software
|
||||
if instance.version:
|
||||
instance_data['version'] = instance.version
|
||||
if not any(blocked_instance.get('domain') == instance.domain for blocked_instance in blocked):
|
||||
linked.append(instance_data)
|
||||
for instance in AllowedInstances.query.all():
|
||||
allowed.append({"id": instance.id, "domain": instance.domain, "published": utcnow(), "updated": utcnow()})
|
||||
for instance in BannedInstances.query.all():
|
||||
blocked.append({"id": instance.id, "domain": instance.domain, "published": utcnow(), "updated": utcnow()})
|
||||
return jsonify({
|
||||
"federated_instances": {
|
||||
"linked": linked,
|
||||
|
|
Loading…
Add table
Reference in a new issue