mirror of
https://codeberg.org/rimu/pyfedi
synced 2025-01-23 19:36:56 -08:00
moderators endpoint
This commit is contained in:
parent
f8a5f0872b
commit
7395494477
1 changed files with 21 additions and 0 deletions
|
@ -859,6 +859,27 @@ def community_outbox(actor):
|
|||
return jsonify(community_data)
|
||||
|
||||
|
||||
@bp.route('/c/<actor>/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'<br><br>'.join(INBOX), status=200)
|
||||
|
|
Loading…
Reference in a new issue