From 7395494477e04fbffdcdbe6eb814ec29f3c2a45a Mon Sep 17 00:00:00 2001 From: rimu <3310831+rimu@users.noreply.github.com> Date: Sun, 26 Nov 2023 23:20:51 +1300 Subject: [PATCH] moderators endpoint --- app/activitypub/routes.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/app/activitypub/routes.py b/app/activitypub/routes.py index 274c8bd3..defeeac2 100644 --- a/app/activitypub/routes.py +++ b/app/activitypub/routes.py @@ -859,6 +859,27 @@ def community_outbox(actor): return jsonify(community_data) +@bp.route('/c//moderators', methods=['GET']) +def community_moderators(actor): + actor = actor.strip() + community = Community.query.filter_by(name=actor, banned=False, ap_id=None).first() + if community is not None: + moderator_ids = community.moderators() + moderators = User.query.filter(User.id.in_([mod.user_id for mod in moderator_ids])).all() + community_data = { + "@context": default_context(), + "type": "OrderedCollection", + "id": f"https://{current_app.config['SERVER_NAME']}/c/{actor}/moderators", + "totalItems": len(moderators), + "orderedItems": [] + } + + for moderator in moderators: + community_data['orderedItems'].append(moderator.ap_profile_id) + + return jsonify(community_data) + + @bp.route('/inspect') def inspect(): return Response(b'

'.join(INBOX), status=200)