mirror of
https://codeberg.org/rimu/pyfedi
synced 2025-01-23 19:36:56 -08:00
Process Undo/Follow requests from remote actors to local actors
This commit is contained in:
parent
f7cfd1f92b
commit
d2a99e08b4
1 changed files with 19 additions and 2 deletions
|
@ -1217,7 +1217,13 @@ def user_inbox(actor):
|
|||
else:
|
||||
process_user_follow_request.delay(request_json, activity_log.id, actor.id)
|
||||
return ''
|
||||
# todo: undo/follow
|
||||
if ('type' in request_json and request_json['type'] == 'Undo' and
|
||||
'object' in request_json and request_json['object']['type'] == 'Follow'):
|
||||
if current_app.debug:
|
||||
process_user_undo_follow_request(request_json, activity_log.id, actor.id)
|
||||
else:
|
||||
process_user_undo_follow_request.delay(request_json, activity_log.id, actor.id)
|
||||
return ''
|
||||
except VerificationError:
|
||||
activity_log.result = 'failure'
|
||||
activity_log.exception_message = 'Could not verify signature'
|
||||
|
@ -1271,6 +1277,17 @@ def process_user_follow_request(request_json, activitypublog_id, remote_user_id)
|
|||
db.session.commit()
|
||||
|
||||
|
||||
def process_user_undo_follow_request(request_json, activitypublog_id, remote_user_id):
|
||||
activity_log = ActivityPubLog.query.get(activitypublog_id)
|
||||
local_user_ap_id = request_json['object']['object']
|
||||
local_user = find_actor_or_create(local_user_ap_id, create_if_not_found=False)
|
||||
remote_user = User.query.get(remote_user_id)
|
||||
if local_user:
|
||||
db.session.query(UserFollower).filter_by(local_user_id=local_user.id, remote_user_id=remote_user.id).delete()
|
||||
activity_log.result = 'success'
|
||||
db.session.commit()
|
||||
|
||||
|
||||
@bp.route('/c/<actor>/inbox', methods=['GET', 'POST'])
|
||||
def community_inbox(actor):
|
||||
return shared_inbox()
|
||||
|
|
Loading…
Add table
Reference in a new issue