mirror of
https://codeberg.org/rimu/pyfedi
synced 2025-01-23 19:36:56 -08:00
Respond to /u/actor/followers URL
This commit is contained in:
parent
b374e3031b
commit
e7ebce679a
1 changed files with 24 additions and 0 deletions
|
@ -1252,6 +1252,7 @@ def process_user_follow_request(request_json, activitypublog_id, remote_user_id)
|
||||||
if not existing_follower:
|
if not existing_follower:
|
||||||
auto_accept = not local_user.ap_manually_approves_followers
|
auto_accept = not local_user.ap_manually_approves_followers
|
||||||
new_follower = UserFollower(local_user_id=local_user.id, remote_user_id=remote_user.id, is_accepted=auto_accept)
|
new_follower = UserFollower(local_user_id=local_user.id, remote_user_id=remote_user.id, is_accepted=auto_accept)
|
||||||
|
local_user.ap_followers_url = local_user.ap_public_url + '/followers'
|
||||||
db.session.add(new_follower)
|
db.session.add(new_follower)
|
||||||
accept = {
|
accept = {
|
||||||
"@context": default_context(),
|
"@context": default_context(),
|
||||||
|
@ -1319,6 +1320,29 @@ def community_followers(actor):
|
||||||
abort(404)
|
abort(404)
|
||||||
|
|
||||||
|
|
||||||
|
@bp.route('/u/<actor>/followers', methods=['GET'])
|
||||||
|
def user_followers(actor):
|
||||||
|
actor = actor.strip()
|
||||||
|
user = User.query.filter_by(user_name=actor, banned=False, ap_id=None).first()
|
||||||
|
if user is not None and user.ap_followers_url:
|
||||||
|
followers = User.query.join(UserFollower, User.id == UserFollower.remote_user_id).filter(UserFollower.local_user_id == user.id).all()
|
||||||
|
items = []
|
||||||
|
for f in followers:
|
||||||
|
items.append(f.ap_public_url)
|
||||||
|
result = {
|
||||||
|
"@context": default_context(),
|
||||||
|
"id": user.ap_followers_url,
|
||||||
|
"type": "Collection",
|
||||||
|
"totalItems": len(items),
|
||||||
|
"items": items
|
||||||
|
}
|
||||||
|
resp = jsonify(result)
|
||||||
|
resp.content_type = 'application/activity+json'
|
||||||
|
return resp
|
||||||
|
else:
|
||||||
|
abort(404)
|
||||||
|
|
||||||
|
|
||||||
@bp.route('/comment/<int:comment_id>', methods=['GET'])
|
@bp.route('/comment/<int:comment_id>', methods=['GET'])
|
||||||
def comment_ap(comment_id):
|
def comment_ap(comment_id):
|
||||||
if is_activitypub_request():
|
if is_activitypub_request():
|
||||||
|
|
Loading…
Add table
Reference in a new issue