From 6cc74999868f435c9a22c9c9456dbd8e43fbbb17 Mon Sep 17 00:00:00 2001 From: freamon Date: Thu, 23 Jan 2025 06:13:38 +0000 Subject: [PATCH] bugfix for adding mods to newly fetched community --- app/community/util.py | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/app/community/util.py b/app/community/util.py index f190f90f..5e7482d4 100644 --- a/app/community/util.py +++ b/app/community/util.py @@ -107,19 +107,19 @@ def retrieve_mods_and_backfill(community_id: int, server, name, community_json=N else: new_membership = CommunityMember(community_id=community.id, user_id=mod.id, is_moderator=True) db.session.add(new_membership) - elif community.ap_moderators_url: - mods_data = remote_object_to_json(community.ap_moderators_url) - if mods_data and mods_data['type'] == 'OrderedCollection' and 'orderedItems' in mods_data: - for actor in mods_data['orderedItems']: - sleep(0.5) - mod = find_actor_or_create(actor) - if mod: - existing_membership = CommunityMember.query.filter_by(community_id=community.id, user_id=mod.id).first() - if existing_membership: - existing_membership.is_moderator = True - else: - new_membership = CommunityMember(community_id=community.id, user_id=mod.id, is_moderator=True) - db.session.add(new_membership) + elif community.ap_moderators_url: + mods_data = remote_object_to_json(community.ap_moderators_url) + if mods_data and mods_data['type'] == 'OrderedCollection' and 'orderedItems' in mods_data: + for actor in mods_data['orderedItems']: + sleep(0.5) + mod = find_actor_or_create(actor) + if mod: + existing_membership = CommunityMember.query.filter_by(community_id=community.id, user_id=mod.id).first() + if existing_membership: + existing_membership.is_moderator = True + else: + new_membership = CommunityMember(community_id=community.id, user_id=mod.id, is_moderator=True) + db.session.add(new_membership) if is_peertube: community.restricted_to_mods = True db.session.commit()