PeerTube: process incoming Update/Video activity

This commit is contained in:
freamon 2024-05-26 02:00:05 +01:00
parent 2abadb183f
commit 4c1f5cad53
2 changed files with 14 additions and 0 deletions

View file

@ -969,6 +969,16 @@ def process_inbox_request(request_json, activitypublog_id, ip_address):
activity_log.exception_message = 'Edit attempt denied' activity_log.exception_message = 'Edit attempt denied'
else: else:
activity_log.exception_message = 'PostReply not found' 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': elif request_json['type'] == 'Delete':
if isinstance(request_json['object'], str): if isinstance(request_json['object'], str):
ap_id = request_json['object'] # lemmy ap_id = request_json['object'] # lemmy

View file

@ -1839,6 +1839,10 @@ def update_post_from_activity(post: Post, request_json: dict):
old_url = post.url old_url = post.url
old_image_id = post.image_id old_image_id = post.image_id
post.url = '' 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 \ if 'attachment' in request_json['object'] and len(request_json['object']['attachment']) > 0 and \
'type' in request_json['object']['attachment'][0]: 'type' in request_json['object']['attachment'][0]:
if request_json['object']['attachment'][0]['type'] == 'Link': if request_json['object']['attachment'][0]['type'] == 'Link':