From 1b7f6b234cd00f9896d53829279d9efa7dfb3fe1 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Sat, 14 Sep 2024 17:40:11 +0100 Subject: [PATCH] Include security within @context to indicate ld-signed activities --- acceptreject.py | 5 ++- announce.py | 15 +++++++-- blocking.py | 8 +++-- bookmarks.py | 25 +++++++++++--- conversation.py | 10 ++++-- daemon_get.py | 6 ++-- daemon_get_buttons_announce.py | 5 ++- daemon_get_buttons_like.py | 10 ++++-- daemon_get_buttons_reaction.py | 10 ++++-- daemon_get_post.py | 15 +++++---- daemon_post_confirm.py | 5 ++- daemon_post_remove.py | 5 ++- delete.py | 5 ++- follow.py | 28 ++++++++++++---- followerSync.py | 5 ++- happening.py | 10 ++++-- like.py | 20 +++++++++--- media.py | 1 + person.py | 5 ++- pgp.py | 5 ++- posts.py | 60 +++++++++++++++++++++++++++------- reaction.py | 20 +++++++++--- relationships.py | 20 +++++++++--- shares.py | 30 +++++++++++++---- tests.py | 27 +++++++++++---- utils.py | 5 ++- webapp_search.py | 5 ++- webapp_utils.py | 3 +- 28 files changed, 287 insertions(+), 81 deletions(-) diff --git a/acceptreject.py b/acceptreject.py index 12cb10497..77289088f 100644 --- a/acceptreject.py +++ b/acceptreject.py @@ -48,7 +48,10 @@ def _create_accept_reject(federation_list: [], domain = get_full_domain(domain, port) new_accept = { - "@context": "https://www.w3.org/ns/activitystreams", + "@context": [ + 'https://www.w3.org/ns/activitystreams', + 'https://w3id.org/security/v1' + ], 'type': accept_type, 'actor': local_actor_url(http_prefix, nickname, domain), 'to': [to_url], diff --git a/announce.py b/announce.py index e9ac9c330..a658e3e62 100644 --- a/announce.py +++ b/announce.py @@ -191,7 +191,10 @@ def create_announce(session, base_dir: str, federation_list: [], atom_uri_str = local_actor_url(http_prefix, nickname, full_domain) + \ '/statuses/' + status_number new_announce = { - "@context": "https://www.w3.org/ns/activitystreams", + "@context": [ + 'https://www.w3.org/ns/activitystreams', + 'https://w3id.org/security/v1' + ], 'actor': local_actor_url(http_prefix, nickname, full_domain), 'atomUri': atom_uri_str, 'cc': [], @@ -296,7 +299,10 @@ def send_announce_via_server(base_dir: str, session, status_number, published = get_status_number() new_announce_id = actor_str + '/statuses/' + status_number new_announce_json = { - "@context": "https://www.w3.org/ns/activitystreams", + "@context": [ + 'https://www.w3.org/ns/activitystreams', + 'https://w3id.org/security/v1' + ], 'actor': actor_str, 'atomUri': new_announce_id, 'cc': [cc_url], @@ -387,7 +393,10 @@ def send_undo_announce_via_server(base_dir: str, session, status_number, _ = get_status_number() unannounce_json = { - '@context': 'https://www.w3.org/ns/activitystreams', + "@context": [ + 'https://www.w3.org/ns/activitystreams', + 'https://w3id.org/security/v1' + ], 'id': actor + '/statuses/' + str(status_number) + '/undo', 'type': 'Undo', 'actor': actor, diff --git a/blocking.py b/blocking.py index 5e26159f1..7087e1437 100644 --- a/blocking.py +++ b/blocking.py @@ -133,7 +133,8 @@ def blocked_timeline_json(actor: str, page_number: int, items_per_page: int, result_json = { "@context": [ - "https://www.w3.org/ns/activitystreams", + 'https://www.w3.org/ns/activitystreams', + 'https://w3id.org/security/v1', "https://purl.archive.org/socialweb/blocked" ], "id": actor + '?page=' + str(page_number), @@ -1247,7 +1248,10 @@ def mute_post(base_dir: str, nickname: str, domain: str, port: int, if debug: print('DEBUG: Adding initial mute to ' + post_id) ignores_json = { - "@context": "https://www.w3.org/ns/activitystreams", + "@context": [ + 'https://www.w3.org/ns/activitystreams', + 'https://w3id.org/security/v1' + ], 'id': post_id, 'type': 'Collection', "totalItems": 1, diff --git a/bookmarks.py b/bookmarks.py index 0d1c7440f..b387464c8 100644 --- a/bookmarks.py +++ b/bookmarks.py @@ -205,7 +205,10 @@ def update_bookmarks_collection(recent_posts_cache: {}, if debug: print('DEBUG: Adding initial bookmarks to ' + object_url) bookmarks_json = { - "@context": "https://www.w3.org/ns/activitystreams", + "@context": [ + 'https://www.w3.org/ns/activitystreams', + 'https://w3id.org/security/v1' + ], 'id': object_url, 'type': 'Collection', "totalItems": 1, @@ -283,7 +286,10 @@ def bookmark_post(recent_posts_cache: {}, full_domain = get_full_domain(domain, port) new_bookmark_json = { - "@context": "https://www.w3.org/ns/activitystreams", + "@context": [ + 'https://www.w3.org/ns/activitystreams', + 'https://w3id.org/security/v1' + ], 'type': 'Bookmark', 'actor': local_actor_url(http_prefix, nickname, full_domain), 'object': object_url @@ -337,7 +343,10 @@ def undo_bookmark_post(recent_posts_cache: {}, full_domain = get_full_domain(domain, port) new_undo_bookmark_json = { - "@context": "https://www.w3.org/ns/activitystreams", + "@context": [ + 'https://www.w3.org/ns/activitystreams', + 'https://w3id.org/security/v1' + ], 'type': 'Undo', 'actor': local_actor_url(http_prefix, nickname, full_domain), 'object': { @@ -397,7 +406,10 @@ def send_bookmark_via_server(base_dir: str, session, actor = local_actor_url(http_prefix, nickname, domain_full) new_bookmark_json = { - "@context": "https://www.w3.org/ns/activitystreams", + "@context": [ + 'https://www.w3.org/ns/activitystreams', + 'https://w3id.org/security/v1' + ], "type": "Add", "actor": actor, "to": [actor], @@ -490,7 +502,10 @@ def send_undo_bookmark_via_server(base_dir: str, session, actor = local_actor_url(http_prefix, nickname, domain_full) new_bookmark_json = { - "@context": "https://www.w3.org/ns/activitystreams", + "@context": [ + 'https://www.w3.org/ns/activitystreams', + 'https://w3id.org/security/v1' + ], "type": "Remove", "actor": actor, "to": [actor], diff --git a/conversation.py b/conversation.py index 0d542bbb5..906b34f23 100644 --- a/conversation.py +++ b/conversation.py @@ -227,7 +227,10 @@ def _get_replies_to_post(post_json_object: {}, if not isinstance(item['cc'], list): continue wrapped_post = { - "@context": "https://www.w3.org/ns/activitystreams", + "@context": [ + 'https://www.w3.org/ns/activitystreams', + 'https://w3id.org/security/v1' + ], 'id': item['id'] + '/activity', 'type': 'Create', 'actor': attrib_str, @@ -343,7 +346,10 @@ def download_conversation_posts(authorized: bool, session, if not isinstance(post_json_object['cc'], list): break wrapped_post = { - "@context": "https://www.w3.org/ns/activitystreams", + "@context": [ + 'https://www.w3.org/ns/activitystreams', + 'https://w3id.org/security/v1' + ], 'id': post_json_object['id'] + '/activity', 'type': 'Create', 'actor': attrib_str, diff --git a/daemon_get.py b/daemon_get.py index 5a233bf41..544828c37 100644 --- a/daemon_get.py +++ b/daemon_get.py @@ -919,7 +919,8 @@ def daemon_http_get(self) -> None: actor += '/blocked' blocked_json = { "@context": [ - "https://www.w3.org/ns/activitystreams", + 'https://www.w3.org/ns/activitystreams', + 'https://w3id.org/security/v1', "https://purl.archive.org/socialweb/blocked" ], "id": actor, @@ -979,7 +980,8 @@ def daemon_http_get(self) -> None: actor += '/pendingFollowers' pending_json = { "@context": [ - "https://www.w3.org/ns/activitystreams" + 'https://www.w3.org/ns/activitystreams', + 'https://w3id.org/security/v1' ], "id": actor, "type": "OrderedCollection", diff --git a/daemon_get_buttons_announce.py b/daemon_get_buttons_announce.py index 06b07ebe0..8a27720c3 100644 --- a/daemon_get_buttons_announce.py +++ b/daemon_get_buttons_announce.py @@ -363,7 +363,10 @@ def announce_button_undo(self, calling_domain: str, path: str, '/users/' + self.post_to_nickname un_repeat_to_str = 'https://www.w3.org/ns/activitystreams#Public' new_undo_announce = { - "@context": "https://www.w3.org/ns/activitystreams", + "@context": [ + 'https://www.w3.org/ns/activitystreams', + 'https://w3id.org/security/v1' + ], 'actor': undo_announce_actor, 'type': 'Undo', 'cc': [undo_announce_actor + '/followers'], diff --git a/daemon_get_buttons_like.py b/daemon_get_buttons_like.py index e851ae5d4..c86f99a5d 100644 --- a/daemon_get_buttons_like.py +++ b/daemon_get_buttons_like.py @@ -155,7 +155,10 @@ def like_button(self, calling_domain: str, path: str, liked_post_filename = None like_json = { - "@context": "https://www.w3.org/ns/activitystreams", + "@context": [ + 'https://www.w3.org/ns/activitystreams', + 'https://w3id.org/security/v1' + ], 'type': 'Like', 'actor': like_actor, 'to': [actor_liked], @@ -409,7 +412,10 @@ def like_button_undo(self, calling_domain: str, path: str, liked_post_filename = None undo_like_json = { - "@context": "https://www.w3.org/ns/activitystreams", + "@context": [ + 'https://www.w3.org/ns/activitystreams', + 'https://w3id.org/security/v1' + ], 'type': 'Undo', 'actor': undo_actor, 'to': [actor_liked], diff --git a/daemon_get_buttons_reaction.py b/daemon_get_buttons_reaction.py index 89a5d5a48..c5cdf4350 100644 --- a/daemon_get_buttons_reaction.py +++ b/daemon_get_buttons_reaction.py @@ -177,7 +177,10 @@ def reaction_button(self, calling_domain: str, path: str, reaction_post_filename = None reaction_json = { - "@context": "https://www.w3.org/ns/activitystreams", + "@context": [ + 'https://www.w3.org/ns/activitystreams', + 'https://w3id.org/security/v1' + ], 'type': 'EmojiReact', 'actor': reaction_actor, 'to': [actor_reaction], @@ -457,7 +460,10 @@ def reaction_button_undo(self, calling_domain: str, path: str, reaction_post_filename = None undo_reaction_json = { - "@context": "https://www.w3.org/ns/activitystreams", + "@context": [ + 'https://www.w3.org/ns/activitystreams', + 'https://w3id.org/security/v1' + ], 'type': 'Undo', 'actor': undo_actor, 'to': [actor_reaction], diff --git a/daemon_get_post.py b/daemon_get_post.py index ca5114ce5..939f52e3c 100644 --- a/daemon_get_post.py +++ b/daemon_get_post.py @@ -928,9 +928,6 @@ def show_replies_to_post(self, authorized: bool, if not os.path.isfile(post_replies_filename): # There are no replies, # so show empty collection - context_str = \ - 'https://www.w3.org/ns/activitystreams' - first_str = \ local_actor_url(http_prefix, nickname, domain_full) + \ '/statuses/' + status_number + '/replies?page=true' @@ -944,7 +941,10 @@ def show_replies_to_post(self, authorized: bool, '/statuses/' + status_number + '/replies?page=true' replies_json = { - '@context': context_str, + "@context": [ + 'https://www.w3.org/ns/activitystreams', + 'https://w3id.org/security/v1' + ], 'first': first_str, 'id': id_str, 'last': last_str, @@ -1031,8 +1031,6 @@ def show_replies_to_post(self, authorized: bool, # replies exist. Itterate through the # text file containing message ids - context_str = 'https://www.w3.org/ns/activitystreams' - id_str = \ local_actor_url(http_prefix, nickname, domain_full) + \ '/statuses/' + status_number + '?page=true' @@ -1042,7 +1040,10 @@ def show_replies_to_post(self, authorized: bool, '/statuses/' + status_number replies_json = { - '@context': context_str, + "@context": [ + 'https://www.w3.org/ns/activitystreams', + 'https://w3id.org/security/v1' + ], 'id': id_str, 'orderedItems': [ ], diff --git a/daemon_post_confirm.py b/daemon_post_confirm.py index 70d345325..afb360cee 100644 --- a/daemon_post_confirm.py +++ b/daemon_post_confirm.py @@ -103,7 +103,10 @@ def unfollow_confirm(self, calling_domain: str, cookie: str, status_number, _ = get_status_number() follow_id = follow_actor + '/statuses/' + str(status_number) unfollow_json = { - '@context': 'https://www.w3.org/ns/activitystreams', + "@context": [ + 'https://www.w3.org/ns/activitystreams', + 'https://w3id.org/security/v1' + ], 'id': follow_id + '/undo', 'type': 'Undo', 'actor': follow_actor, diff --git a/daemon_post_remove.py b/daemon_post_remove.py index 1dd270921..105a103b1 100644 --- a/daemon_post_remove.py +++ b/daemon_post_remove.py @@ -380,7 +380,10 @@ def receive_remove_post(self, calling_domain: str, cookie: str, remove_post_actor ] delete_json = { - "@context": "https://www.w3.org/ns/activitystreams", + "@context": [ + 'https://www.w3.org/ns/activitystreams', + 'https://w3id.org/security/v1' + ], 'actor': remove_post_actor, 'object': remove_message_id, 'to': to_list, diff --git a/delete.py b/delete.py index ebd612507..3a6976599 100644 --- a/delete.py +++ b/delete.py @@ -51,7 +51,10 @@ def send_delete_via_server(base_dir: str, session, cc_url = actor + '/followers' new_delete_json = { - "@context": "https://www.w3.org/ns/activitystreams", + "@context": [ + 'https://www.w3.org/ns/activitystreams', + 'https://w3id.org/security/v1' + ], 'actor': actor, 'cc': [cc_url], 'object': delete_object_url, diff --git a/follow.py b/follow.py index 6d85b800d..eb9491fa8 100644 --- a/follow.py +++ b/follow.py @@ -514,7 +514,10 @@ def get_following_feed(base_dir: str, domain: str, port: int, path: str, total_str = \ _get_no_of_follows(base_dir, nickname, domain) following = { - '@context': 'https://www.w3.org/ns/activitystreams', + "@context": [ + 'https://www.w3.org/ns/activitystreams', + 'https://w3id.org/security/v1' + ], 'first': first_str, 'id': id_str, 'totalItems': total_str, @@ -532,7 +535,10 @@ def get_following_feed(base_dir: str, domain: str, port: int, path: str, part_of_str = \ local_actor_url(http_prefix, nickname, domain) + '/' + follow_file following = { - '@context': 'https://www.w3.org/ns/activitystreams', + "@context": [ + 'https://www.w3.org/ns/activitystreams', + 'https://w3id.org/security/v1' + ], 'id': id_str, 'orderedItems': [], 'partOf': part_of_str, @@ -990,7 +996,10 @@ def send_follow_request(session, base_dir: str, unfollowed_filename) new_follow_json = { - '@context': 'https://www.w3.org/ns/activitystreams', + "@context": [ + 'https://www.w3.org/ns/activitystreams', + 'https://w3id.org/security/v1' + ], 'id': follow_actor + '/statuses/' + str(status_number), 'type': 'Follow', 'actor': follow_actor, @@ -1052,7 +1061,10 @@ def send_follow_request_via_server(base_dir: str, session, status_number, _ = get_status_number() new_follow_json = { - '@context': 'https://www.w3.org/ns/activitystreams', + "@context": [ + 'https://www.w3.org/ns/activitystreams', + 'https://w3id.org/security/v1' + ], 'id': follow_actor + '/statuses/' + str(status_number), 'type': 'Follow', 'actor': follow_actor, @@ -1145,7 +1157,10 @@ def send_unfollow_request_via_server(base_dir: str, session, status_number, _ = get_status_number() unfollow_json = { - '@context': 'https://www.w3.org/ns/activitystreams', + "@context": [ + 'https://www.w3.org/ns/activitystreams', + 'https://w3id.org/security/v1' + ], 'id': follow_actor + '/statuses/' + str(status_number) + '/undo', 'type': 'Undo', 'actor': follow_actor, @@ -1587,7 +1602,8 @@ def pending_followers_timeline_json(actor: str, base_dir: str, """ result_json = { "@context": [ - "https://www.w3.org/ns/activitystreams" + 'https://www.w3.org/ns/activitystreams', + 'https://w3id.org/security/v1' ], "id": actor, "type": "OrderedCollection", diff --git a/followerSync.py b/followerSync.py index 65ee653c6..8d4f461a0 100644 --- a/followerSync.py +++ b/followerSync.py @@ -98,7 +98,10 @@ def _get_followers_sync_json(base_dir: str, id_str = http_prefix + '://' + domain_full + \ '/users/' + nickname + '/followers?domain=' + search_domain sync_json = { - '@context': 'https://www.w3.org/ns/activitystreams', + "@context": [ + 'https://www.w3.org/ns/activitystreams', + 'https://w3id.org/security/v1' + ], 'id': id_str, 'orderedItems': sync_list, 'type': 'OrderedCollection' diff --git a/happening.py b/happening.py index e5d31cf53..42cd1d14e 100644 --- a/happening.py +++ b/happening.py @@ -1035,7 +1035,10 @@ def _dav_store_event(base_dir: str, nickname: str, domain: str, "type": "Mention" }, { - "@context": "https://www.w3.org/ns/activitystreams", + "@context": [ + 'https://www.w3.org/ns/activitystreams', + 'https://w3id.org/security/v1' + ], "type": "Event", "name": content, "startTime": start_time, @@ -1056,7 +1059,10 @@ def _dav_store_event(base_dir: str, nickname: str, domain: str, } if location: event_json['object']['tag'].append({ - "@context": "https://www.w3.org/ns/activitystreams", + "@context": [ + 'https://www.w3.org/ns/activitystreams', + 'https://w3id.org/security/v1' + ], "type": "Place", "name": location }) diff --git a/like.py b/like.py index 7386eda89..8f705227a 100644 --- a/like.py +++ b/like.py @@ -94,7 +94,10 @@ def _create_like(recent_posts_cache: {}, full_domain = get_full_domain(domain, port) new_like_json = { - "@context": "https://www.w3.org/ns/activitystreams", + "@context": [ + 'https://www.w3.org/ns/activitystreams', + 'https://w3id.org/security/v1' + ], 'type': 'Like', 'actor': local_actor_url(http_prefix, nickname, full_domain), 'object': object_url @@ -208,7 +211,10 @@ def send_like_via_server(base_dir: str, session, actor = local_actor_url(http_prefix, from_nickname, from_domain_full) new_like_json = { - "@context": "https://www.w3.org/ns/activitystreams", + "@context": [ + 'https://www.w3.org/ns/activitystreams', + 'https://w3id.org/security/v1' + ], 'type': 'Like', 'actor': actor, 'object': like_url @@ -293,7 +299,10 @@ def send_undo_like_via_server(base_dir: str, session, actor = local_actor_url(http_prefix, from_nickname, from_domain_full) new_undo_like_json = { - "@context": "https://www.w3.org/ns/activitystreams", + "@context": [ + 'https://www.w3.org/ns/activitystreams', + 'https://w3id.org/security/v1' + ], 'type': 'Undo', 'actor': actor, 'object': { @@ -470,7 +479,10 @@ def update_likes_collection(recent_posts_cache: {}, if debug: print('DEBUG: Adding initial like to ' + object_url) likes_json = { - "@context": "https://www.w3.org/ns/activitystreams", + "@context": [ + 'https://www.w3.org/ns/activitystreams', + 'https://w3id.org/security/v1' + ], 'id': object_url, 'type': 'Collection', "totalItems": 1, diff --git a/media.py b/media.py index 2a456427e..74b2ed3e9 100644 --- a/media.py +++ b/media.py @@ -637,6 +637,7 @@ def attach_media(base_dir: str, http_prefix: str, if content_license_url or creator: attachment_json['@context'] = [ 'https://www.w3.org/ns/activitystreams', + 'https://w3id.org/security/v1', {'schema': 'https://schema.org#'} ] if content_license_url: diff --git a/person.py b/person.py index df5bd31e6..25a77bbd1 100644 --- a/person.py +++ b/person.py @@ -358,7 +358,10 @@ def get_actor_move_json(actor_json: {}) -> {}: return None pub_number, _ = get_status_number() return { - "@context": "https://www.w3.org/ns/activitystreams", + "@context": [ + 'https://www.w3.org/ns/activitystreams', + 'https://w3id.org/security/v1' + ], "id": actor_json['id'] + '#moved/' + pub_number, "type": "Move", "actor": actor_json['id'], diff --git a/pgp.py b/pgp.py index 24da45dea..1696b5365 100644 --- a/pgp.py +++ b/pgp.py @@ -643,7 +643,10 @@ def pgp_public_key_upload(base_dir: str, session, # create an actor update status_number, _ = get_status_number() actor_update = { - '@context': 'https://www.w3.org/ns/activitystreams', + "@context": [ + 'https://www.w3.org/ns/activitystreams', + 'https://w3id.org/security/v1' + ], 'id': actor + '#updates/' + status_number, 'type': 'Update', 'actor': actor, diff --git a/posts.py b/posts.py index 295814caa..c8dcf8c78 100644 --- a/posts.py +++ b/posts.py @@ -1513,7 +1513,10 @@ def _create_post_place_and_time(event_date: str, end_date: str, end_date_str = event_date_str if not schedule_post and not event_uuid: tags.append({ - "@context": "https://www.w3.org/ns/activitystreams", + "@context": [ + 'https://www.w3.org/ns/activitystreams', + 'https://w3id.org/security/v1' + ], "type": "Event", "name": event_name, "startTime": event_date_str, @@ -1526,7 +1529,10 @@ def _create_post_place_and_time(event_date: str, end_date: str, geocoords_from_map_link(location, 'openstreetmap.org') if latitude and longitude: tags.append({ - "@context": "https://www.w3.org/ns/activitystreams", + "@context": [ + 'https://www.w3.org/ns/activitystreams', + 'https://w3id.org/security/v1' + ], "type": "Place", "name": location, "latitude": latitude, @@ -1534,7 +1540,10 @@ def _create_post_place_and_time(event_date: str, end_date: str, }) else: tags.append({ - "@context": "https://www.w3.org/ns/activitystreams", + "@context": [ + 'https://www.w3.org/ns/activitystreams', + 'https://w3id.org/security/v1' + ], "type": "Place", "name": location }) @@ -1912,7 +1921,10 @@ def outbox_message_create_wrap(http_prefix: str, if message_json.get('cc'): cc_list = message_json['cc'] new_post = { - "@context": "https://www.w3.org/ns/activitystreams", + "@context": [ + 'https://www.w3.org/ns/activitystreams', + 'https://w3id.org/security/v1' + ], 'id': new_post_id + '/activity', 'type': 'Create', 'actor': local_actor_url(http_prefix, nickname, domain), @@ -4391,7 +4403,10 @@ def create_moderation(base_dir: str, nickname: str, domain: str, port: int, page_str = '?page=' + str(page_number) box_url = local_actor_url(http_prefix, nickname, domain) + '/' + boxname box_header = { - '@context': 'https://www.w3.org/ns/activitystreams', + "@context": [ + 'https://www.w3.org/ns/activitystreams', + 'https://w3id.org/security/v1' + ], 'first': box_url + '?page=true', 'id': box_url, 'last': box_url + '?page=true', @@ -4399,7 +4414,10 @@ def create_moderation(base_dir: str, nickname: str, domain: str, port: int, 'type': 'OrderedCollection' } box_items = { - '@context': 'https://www.w3.org/ns/activitystreams', + "@context": [ + 'https://www.w3.org/ns/activitystreams', + 'https://w3id.org/security/v1' + ], 'id': box_url + page_str, 'orderedItems': [ ], @@ -4859,7 +4877,10 @@ def _create_box_indexed(recent_posts_cache: {}, 'unable to convert page number to string') box_url = local_actor_url(http_prefix, nickname, domain) + '/' + boxname box_header = { - '@context': 'https://www.w3.org/ns/activitystreams', + "@context": [ + 'https://www.w3.org/ns/activitystreams', + 'https://w3id.org/security/v1' + ], 'first': box_url + '?page=true', 'id': box_url, 'last': box_url + '?page=true', @@ -4867,7 +4888,10 @@ def _create_box_indexed(recent_posts_cache: {}, 'type': 'OrderedCollection' } box_items = { - '@context': 'https://www.w3.org/ns/activitystreams', + "@context": [ + 'https://www.w3.org/ns/activitystreams', + 'https://w3id.org/security/v1' + ], 'id': box_url + page_str, 'orderedItems': [ ], @@ -6385,7 +6409,10 @@ def send_block_via_server(base_dir: str, session, cc_url = block_actor + '/followers' new_block_json = { - "@context": "https://www.w3.org/ns/activitystreams", + "@context": [ + 'https://www.w3.org/ns/activitystreams', + 'https://w3id.org/security/v1' + ], 'type': 'Block', 'actor': block_actor, 'object': blocked_url, @@ -6472,7 +6499,10 @@ def send_mute_via_server(base_dir: str, session, handle = replace_users_with_at(actor) new_mute_json = { - "@context": "https://www.w3.org/ns/activitystreams", + "@context": [ + 'https://www.w3.org/ns/activitystreams', + 'https://w3id.org/security/v1' + ], 'type': 'Ignore', 'actor': actor, 'to': [actor], @@ -6555,7 +6585,10 @@ def send_undo_mute_via_server(base_dir: str, session, handle = replace_users_with_at(actor) undo_mute_json = { - "@context": "https://www.w3.org/ns/activitystreams", + "@context": [ + 'https://www.w3.org/ns/activitystreams', + 'https://w3id.org/security/v1' + ], 'type': 'Undo', 'actor': actor, 'to': [actor], @@ -6645,7 +6678,10 @@ def send_undo_block_via_server(base_dir: str, session, cc_url = block_actor + '/followers' new_block_json = { - "@context": "https://www.w3.org/ns/activitystreams", + "@context": [ + 'https://www.w3.org/ns/activitystreams', + 'https://w3id.org/security/v1' + ], 'type': 'Undo', 'actor': block_actor, 'object': { diff --git a/reaction.py b/reaction.py index 564939712..41f32ac1f 100644 --- a/reaction.py +++ b/reaction.py @@ -92,7 +92,10 @@ def _reactionpost(recent_posts_cache: {}, full_domain = get_full_domain(domain, port) new_reaction_json = { - "@context": "https://www.w3.org/ns/activitystreams", + "@context": [ + 'https://www.w3.org/ns/activitystreams', + 'https://w3id.org/security/v1' + ], 'type': 'EmojiReact', 'actor': local_actor_url(http_prefix, nickname, full_domain), 'object': object_url, @@ -216,7 +219,10 @@ def send_reaction_via_server(base_dir: str, session, actor = local_actor_url(http_prefix, from_nickname, from_domain_full) new_reaction_json = { - "@context": "https://www.w3.org/ns/activitystreams", + "@context": [ + 'https://www.w3.org/ns/activitystreams', + 'https://w3id.org/security/v1' + ], 'type': 'EmojiReact', 'actor': actor, 'object': reaction_url, @@ -304,7 +310,10 @@ def send_undo_reaction_via_server(base_dir: str, session, actor = local_actor_url(http_prefix, from_nickname, from_domain_full) new_undo_reaction_json = { - "@context": "https://www.w3.org/ns/activitystreams", + "@context": [ + 'https://www.w3.org/ns/activitystreams', + 'https://w3id.org/security/v1' + ], 'type': 'Undo', 'actor': actor, 'object': { @@ -550,7 +559,10 @@ def update_reaction_collection(recent_posts_cache: {}, if debug: print('DEBUG: Adding initial emoji reaction to ' + object_url) reactions_json = { - "@context": "https://www.w3.org/ns/activitystreams", + "@context": [ + 'https://www.w3.org/ns/activitystreams', + 'https://w3id.org/security/v1' + ], 'id': object_url, 'type': 'Collection', "totalItems": 1, diff --git a/relationships.py b/relationships.py index 9948addea..77c07026d 100644 --- a/relationships.py +++ b/relationships.py @@ -128,7 +128,10 @@ def get_moved_feed(base_dir: str, domain: str, port: int, path: str, local_actor_url(http_prefix, nickname, domain) + '/moved' total_str = str(len(lines.items())) following = { - '@context': 'https://www.w3.org/ns/activitystreams', + "@context": [ + 'https://www.w3.org/ns/activitystreams', + 'https://w3id.org/security/v1' + ], 'first': first_str, 'id': id_str, 'orderedItems': [], @@ -147,7 +150,10 @@ def get_moved_feed(base_dir: str, domain: str, port: int, path: str, part_of_str = \ local_actor_url(http_prefix, nickname, domain) + '/moved' following = { - '@context': 'https://www.w3.org/ns/activitystreams', + "@context": [ + 'https://www.w3.org/ns/activitystreams', + 'https://w3id.org/security/v1' + ], 'id': id_str, 'orderedItems': [], 'partOf': part_of_str, @@ -432,7 +438,10 @@ def get_inactive_feed(base_dir: str, domain: str, port: int, path: str, local_actor_url(http_prefix, nickname, domain) + '/inactive' total_str = str(len(lines)) following = { - '@context': 'https://www.w3.org/ns/activitystreams', + "@context": [ + 'https://www.w3.org/ns/activitystreams', + 'https://w3id.org/security/v1' + ], 'first': first_str, 'id': id_str, 'orderedItems': [], @@ -451,7 +460,10 @@ def get_inactive_feed(base_dir: str, domain: str, port: int, path: str, part_of_str = \ local_actor_url(http_prefix, nickname, domain) + '/inactive' following = { - '@context': 'https://www.w3.org/ns/activitystreams', + "@context": [ + 'https://www.w3.org/ns/activitystreams', + 'https://w3id.org/security/v1' + ], 'id': id_str, 'orderedItems': [], 'partOf': part_of_str, diff --git a/shares.py b/shares.py index 71e9dc81b..9aaa75d51 100644 --- a/shares.py +++ b/shares.py @@ -568,7 +568,10 @@ def get_shares_feed_for_person(base_dir: str, no_of_shares = len(shares_json.items()) id_str = local_actor_url(http_prefix, nickname, domain) shares = { - '@context': 'https://www.w3.org/ns/activitystreams', + "@context": [ + 'https://www.w3.org/ns/activitystreams', + 'https://w3id.org/security/v1' + ], 'first': id_str + '/' + shares_file_type + '?page=1', 'id': id_str + '/' + shares_file_type, 'totalItems': str(no_of_shares), @@ -582,7 +585,10 @@ def get_shares_feed_for_person(base_dir: str, next_page_number = int(page_number + 1) id_str = local_actor_url(http_prefix, nickname, domain) shares = { - '@context': 'https://www.w3.org/ns/activitystreams', + "@context": [ + 'https://www.w3.org/ns/activitystreams', + 'https://w3id.org/security/v1' + ], 'id': id_str + '/' + shares_file_type + '?page=' + str(page_number), 'orderedItems': [], 'partOf': id_str + '/' + shares_file_type, @@ -650,7 +656,10 @@ def send_share_via_server(base_dir, session, cc_url = actor + '/followers' new_share_json = { - "@context": "https://www.w3.org/ns/activitystreams", + "@context": [ + 'https://www.w3.org/ns/activitystreams', + 'https://w3id.org/security/v1' + ], 'type': 'Add', 'actor': actor, 'target': actor + '/shares', @@ -764,7 +773,10 @@ def send_undo_share_via_server(base_dir: str, session, cc_url = actor + '/followers' undo_share_json = { - "@context": "https://www.w3.org/ns/activitystreams", + "@context": [ + 'https://www.w3.org/ns/activitystreams', + 'https://w3id.org/security/v1' + ], 'type': 'Remove', 'actor': actor, 'target': actor + '/shares', @@ -873,7 +885,10 @@ def send_wanted_via_server(base_dir, session, cc_url = actor + '/followers' new_share_json = { - "@context": "https://www.w3.org/ns/activitystreams", + "@context": [ + 'https://www.w3.org/ns/activitystreams', + 'https://w3id.org/security/v1' + ], 'type': 'Add', 'actor': actor, 'target': actor + '/wanted', @@ -987,7 +1002,10 @@ def send_undo_wanted_via_server(base_dir: str, session, cc_url = actor + '/followers' undo_share_json = { - "@context": "https://www.w3.org/ns/activitystreams", + "@context": [ + 'https://www.w3.org/ns/activitystreams', + 'https://w3id.org/security/v1' + ], 'type': 'Remove', 'actor': actor, 'target': actor + '/wanted', diff --git a/tests.py b/tests.py index 0c3981015..5e14d88b2 100644 --- a/tests.py +++ b/tests.py @@ -4147,7 +4147,10 @@ def _test_jsonld(): print("test_jsonld") jld_document = { - "@context": "https://www.w3.org/ns/activitystreams", + "@context": [ + 'https://www.w3.org/ns/activitystreams', + 'https://w3id.org/security/v1' + ], "actor": "https://somesite.net/users/gerbil", "description": "My json document", "numberField": 83582, @@ -4209,7 +4212,10 @@ def _test_jsonld(): assert not verify_json_signature(signed_document, public_key_pem) jld_document2 = { - "@context": "https://www.w3.org/ns/activitystreams", + "@context": [ + 'https://www.w3.org/ns/activitystreams', + 'https://w3id.org/security/v1' + ], "actor": "https://somesite.net/users/gerbil", "description": "Another json document", "numberField": 13353, @@ -8525,11 +8531,18 @@ def _test_book_link(base_dir: str): id_str = actor + '/generatednote/63472854' published = '2024-01-01T10:30:00.2+00:00' post_json_object = { - '@context': 'https://www.w3.org/ns/activitystreams', - 'attachment': [{'@context': 'https://www.w3.org/ns/activitystreams', - 'name': title, - 'type': 'Document', - 'url': image_url}], + "@context": [ + 'https://www.w3.org/ns/activitystreams', + 'https://w3id.org/security/v1' + ], + 'attachment': [{ + "@context": [ + 'https://www.w3.org/ns/activitystreams', + 'https://w3id.org/security/v1' + ], + 'name': title, + 'type': 'Document', + 'url': image_url}], 'attributedTo': actor, 'cc': [actor + '/followers'], 'content': content, diff --git a/utils.py b/utils.py index c4fcbab20..447120863 100644 --- a/utils.py +++ b/utils.py @@ -3302,7 +3302,10 @@ def update_announce_collection(recent_posts_cache: {}, print('DEBUG: Adding initial shares (announcements) to ' + post_url) announcements_json = { - "@context": "https://www.w3.org/ns/activitystreams", + "@context": [ + 'https://www.w3.org/ns/activitystreams', + 'https://w3id.org/security/v1' + ], 'id': post_url, 'type': 'Collection', "totalItems": 1, diff --git a/webapp_search.py b/webapp_search.py index 51f9150b0..6623e7b03 100644 --- a/webapp_search.py +++ b/webapp_search.py @@ -1440,7 +1440,10 @@ def hashtag_search_json(nickname: str, domain: str, port: int, url = http_prefix + '://' + domain_full + '/tags/' + \ hashtag + '?page=' + str(page_number) hashtag_json = { - '@context': 'https://www.w3.org/ns/activitystreams', + "@context": [ + 'https://www.w3.org/ns/activitystreams', + 'https://w3id.org/security/v1' + ], 'id': url, 'orderedItems': [], 'totalItems': 0, diff --git a/webapp_utils.py b/webapp_utils.py index 1f31eb1d7..204959fb8 100644 --- a/webapp_utils.py +++ b/webapp_utils.py @@ -625,7 +625,8 @@ def get_shares_collection(actor: str, page_number: int, items_per_page: int, result_json = { "@context": [ - "https://www.w3.org/ns/activitystreams" + 'https://www.w3.org/ns/activitystreams', + 'https://w3id.org/security/v1' ], "id": actor + '?page=' + str(page_number), "type": "OrderedCollection",