Link to activitypub actor in individual html post

merge-requests/30/head
Bob Mottram 2024-11-16 13:00:29 +00:00
parent eaa8e2ec67
commit 633a2d1e22
2 changed files with 21 additions and 2 deletions

View File

@ -15,6 +15,8 @@ from utils import get_instance_url
from utils import data_dir
from utils import save_json
from utils import remove_id_ending
from utils import has_object_dict
from utils import get_attributed_to
def login_headers(self, file_format: str, length: int,
@ -175,11 +177,26 @@ def set_html_post_headers(self, length: int, cookie: str,
if post_json_object.get('id'):
# Discover activitypub version of the html post
# https://swicg.github.io/activitypub-html-discovery/#http-link-header
# link to the activitypub post
post_id = remove_id_ending(post_json_object['id'])
ap_link = \
ap_post_link = \
'<' + post_id + '>; rel="alternate"; ' + \
'type="application/activity+json"'
self.send_header('Link', ap_link)
self.send_header('Link', ap_post_link)
# https://swicg.github.io/
# activitypub-html-discovery/#http-link-header-1
# link to the author's actor
obj = post_json_object
if has_object_dict(post_json_object):
obj = post_json_object['object']
if obj.get('attributedTo'):
actor = get_attributed_to(obj['attributedTo'])
if actor:
ap_author_link = \
'<' + actor + '>; rel="author"; ' + \
'type="application/activity+json"'
self.send_header('Link', ap_author_link)
self.end_headers()

View File

@ -3291,6 +3291,8 @@ def html_individual_post(recent_posts_cache: {}, max_recent_posts: int,
metadata_str += \
' <link rel="alternate" type="application/activity+json" ' + \
'href="' + post_id + '" />\n'
# https://swicg.github.io/
# activitypub-html-discovery/#discovering-author-html
# link to the author's actor
if obj.get('attributedTo'):
actor = get_attributed_to(obj['attributedTo'])