diff --git a/app/activitypub/routes.py b/app/activitypub/routes.py index 34b0b022..70d018aa 100644 --- a/app/activitypub/routes.py +++ b/app/activitypub/routes.py @@ -969,6 +969,16 @@ def process_inbox_request(request_json, activitypublog_id, ip_address): activity_log.exception_message = 'Edit attempt denied' else: activity_log.exception_message = 'PostReply not found' + elif request_json['object']['type'] == 'Video': # PeerTube: editing a video (PT doesn't seem to Announce these) + post = Post.query.filter_by(ap_id=request_json['object']['id']).first() + if post: + if can_edit(request_json['actor'], post): + update_post_from_activity(post, request_json) + activity_log.result = 'success' + else: + activity_log.exception_message = 'Edit attempt denied' + else: + activity_log.exception_message = 'Post not found' elif request_json['type'] == 'Delete': if isinstance(request_json['object'], str): ap_id = request_json['object'] # lemmy diff --git a/app/activitypub/util.py b/app/activitypub/util.py index 97668f70..9147e28f 100644 --- a/app/activitypub/util.py +++ b/app/activitypub/util.py @@ -1839,6 +1839,10 @@ def update_post_from_activity(post: Post, request_json: dict): old_url = post.url old_image_id = post.image_id post.url = '' + if request_json['object']['type'] == 'Video': + post.type = POST_TYPE_VIDEO + # PeerTube URL isn't going to change, so set to old_url to prevent this function changing type or icon + post.url = old_url if 'attachment' in request_json['object'] and len(request_json['object']['attachment']) > 0 and \ 'type' in request_json['object']['attachment'][0]: if request_json['object']['attachment'][0]['type'] == 'Link':