mirror of https://gitlab.com/bashrc2/epicyon
Link to activitypub actor in individual html post
parent
eaa8e2ec67
commit
633a2d1e22
|
@ -15,6 +15,8 @@ from utils import get_instance_url
|
||||||
from utils import data_dir
|
from utils import data_dir
|
||||||
from utils import save_json
|
from utils import save_json
|
||||||
from utils import remove_id_ending
|
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,
|
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'):
|
if post_json_object.get('id'):
|
||||||
# Discover activitypub version of the html post
|
# Discover activitypub version of the html post
|
||||||
# https://swicg.github.io/activitypub-html-discovery/#http-link-header
|
# https://swicg.github.io/activitypub-html-discovery/#http-link-header
|
||||||
|
# link to the activitypub post
|
||||||
post_id = remove_id_ending(post_json_object['id'])
|
post_id = remove_id_ending(post_json_object['id'])
|
||||||
ap_link = \
|
ap_post_link = \
|
||||||
'<' + post_id + '>; rel="alternate"; ' + \
|
'<' + post_id + '>; rel="alternate"; ' + \
|
||||||
'type="application/activity+json"'
|
'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()
|
self.end_headers()
|
||||||
|
|
||||||
|
|
|
@ -3291,6 +3291,8 @@ def html_individual_post(recent_posts_cache: {}, max_recent_posts: int,
|
||||||
metadata_str += \
|
metadata_str += \
|
||||||
' <link rel="alternate" type="application/activity+json" ' + \
|
' <link rel="alternate" type="application/activity+json" ' + \
|
||||||
'href="' + post_id + '" />\n'
|
'href="' + post_id + '" />\n'
|
||||||
|
# https://swicg.github.io/
|
||||||
|
# activitypub-html-discovery/#discovering-author-html
|
||||||
# link to the author's actor
|
# link to the author's actor
|
||||||
if obj.get('attributedTo'):
|
if obj.get('attributedTo'):
|
||||||
actor = get_attributed_to(obj['attributedTo'])
|
actor = get_attributed_to(obj['attributedTo'])
|
||||||
|
|
Loading…
Reference in New Issue