Include security within @context to indicate ld-signed activities

main
Bob Mottram 2024-09-14 17:40:11 +01:00
parent 4ad92bb6d8
commit 1b7f6b234c
28 changed files with 287 additions and 81 deletions

View File

@ -48,7 +48,10 @@ def _create_accept_reject(federation_list: [],
domain = get_full_domain(domain, port) domain = get_full_domain(domain, port)
new_accept = { new_accept = {
"@context": "https://www.w3.org/ns/activitystreams", "@context": [
'https://www.w3.org/ns/activitystreams',
'https://w3id.org/security/v1'
],
'type': accept_type, 'type': accept_type,
'actor': local_actor_url(http_prefix, nickname, domain), 'actor': local_actor_url(http_prefix, nickname, domain),
'to': [to_url], 'to': [to_url],

View File

@ -191,7 +191,10 @@ def create_announce(session, base_dir: str, federation_list: [],
atom_uri_str = local_actor_url(http_prefix, nickname, full_domain) + \ atom_uri_str = local_actor_url(http_prefix, nickname, full_domain) + \
'/statuses/' + status_number '/statuses/' + status_number
new_announce = { 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), 'actor': local_actor_url(http_prefix, nickname, full_domain),
'atomUri': atom_uri_str, 'atomUri': atom_uri_str,
'cc': [], 'cc': [],
@ -296,7 +299,10 @@ def send_announce_via_server(base_dir: str, session,
status_number, published = get_status_number() status_number, published = get_status_number()
new_announce_id = actor_str + '/statuses/' + status_number new_announce_id = actor_str + '/statuses/' + status_number
new_announce_json = { 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, 'actor': actor_str,
'atomUri': new_announce_id, 'atomUri': new_announce_id,
'cc': [cc_url], 'cc': [cc_url],
@ -387,7 +393,10 @@ def send_undo_announce_via_server(base_dir: str, session,
status_number, _ = get_status_number() status_number, _ = get_status_number()
unannounce_json = { 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', 'id': actor + '/statuses/' + str(status_number) + '/undo',
'type': 'Undo', 'type': 'Undo',
'actor': actor, 'actor': actor,

View File

@ -133,7 +133,8 @@ def blocked_timeline_json(actor: str, page_number: int, items_per_page: int,
result_json = { result_json = {
"@context": [ "@context": [
"https://www.w3.org/ns/activitystreams", 'https://www.w3.org/ns/activitystreams',
'https://w3id.org/security/v1',
"https://purl.archive.org/socialweb/blocked" "https://purl.archive.org/socialweb/blocked"
], ],
"id": actor + '?page=' + str(page_number), "id": actor + '?page=' + str(page_number),
@ -1247,7 +1248,10 @@ def mute_post(base_dir: str, nickname: str, domain: str, port: int,
if debug: if debug:
print('DEBUG: Adding initial mute to ' + post_id) print('DEBUG: Adding initial mute to ' + post_id)
ignores_json = { ignores_json = {
"@context": "https://www.w3.org/ns/activitystreams", "@context": [
'https://www.w3.org/ns/activitystreams',
'https://w3id.org/security/v1'
],
'id': post_id, 'id': post_id,
'type': 'Collection', 'type': 'Collection',
"totalItems": 1, "totalItems": 1,

View File

@ -205,7 +205,10 @@ def update_bookmarks_collection(recent_posts_cache: {},
if debug: if debug:
print('DEBUG: Adding initial bookmarks to ' + object_url) print('DEBUG: Adding initial bookmarks to ' + object_url)
bookmarks_json = { bookmarks_json = {
"@context": "https://www.w3.org/ns/activitystreams", "@context": [
'https://www.w3.org/ns/activitystreams',
'https://w3id.org/security/v1'
],
'id': object_url, 'id': object_url,
'type': 'Collection', 'type': 'Collection',
"totalItems": 1, "totalItems": 1,
@ -283,7 +286,10 @@ def bookmark_post(recent_posts_cache: {},
full_domain = get_full_domain(domain, port) full_domain = get_full_domain(domain, port)
new_bookmark_json = { new_bookmark_json = {
"@context": "https://www.w3.org/ns/activitystreams", "@context": [
'https://www.w3.org/ns/activitystreams',
'https://w3id.org/security/v1'
],
'type': 'Bookmark', 'type': 'Bookmark',
'actor': local_actor_url(http_prefix, nickname, full_domain), 'actor': local_actor_url(http_prefix, nickname, full_domain),
'object': object_url 'object': object_url
@ -337,7 +343,10 @@ def undo_bookmark_post(recent_posts_cache: {},
full_domain = get_full_domain(domain, port) full_domain = get_full_domain(domain, port)
new_undo_bookmark_json = { 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', 'type': 'Undo',
'actor': local_actor_url(http_prefix, nickname, full_domain), 'actor': local_actor_url(http_prefix, nickname, full_domain),
'object': { 'object': {
@ -397,7 +406,10 @@ def send_bookmark_via_server(base_dir: str, session,
actor = local_actor_url(http_prefix, nickname, domain_full) actor = local_actor_url(http_prefix, nickname, domain_full)
new_bookmark_json = { new_bookmark_json = {
"@context": "https://www.w3.org/ns/activitystreams", "@context": [
'https://www.w3.org/ns/activitystreams',
'https://w3id.org/security/v1'
],
"type": "Add", "type": "Add",
"actor": actor, "actor": actor,
"to": [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) actor = local_actor_url(http_prefix, nickname, domain_full)
new_bookmark_json = { new_bookmark_json = {
"@context": "https://www.w3.org/ns/activitystreams", "@context": [
'https://www.w3.org/ns/activitystreams',
'https://w3id.org/security/v1'
],
"type": "Remove", "type": "Remove",
"actor": actor, "actor": actor,
"to": [actor], "to": [actor],

View File

@ -227,7 +227,10 @@ def _get_replies_to_post(post_json_object: {},
if not isinstance(item['cc'], list): if not isinstance(item['cc'], list):
continue continue
wrapped_post = { 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', 'id': item['id'] + '/activity',
'type': 'Create', 'type': 'Create',
'actor': attrib_str, 'actor': attrib_str,
@ -343,7 +346,10 @@ def download_conversation_posts(authorized: bool, session,
if not isinstance(post_json_object['cc'], list): if not isinstance(post_json_object['cc'], list):
break break
wrapped_post = { 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', 'id': post_json_object['id'] + '/activity',
'type': 'Create', 'type': 'Create',
'actor': attrib_str, 'actor': attrib_str,

View File

@ -919,7 +919,8 @@ def daemon_http_get(self) -> None:
actor += '/blocked' actor += '/blocked'
blocked_json = { blocked_json = {
"@context": [ "@context": [
"https://www.w3.org/ns/activitystreams", 'https://www.w3.org/ns/activitystreams',
'https://w3id.org/security/v1',
"https://purl.archive.org/socialweb/blocked" "https://purl.archive.org/socialweb/blocked"
], ],
"id": actor, "id": actor,
@ -979,7 +980,8 @@ def daemon_http_get(self) -> None:
actor += '/pendingFollowers' actor += '/pendingFollowers'
pending_json = { pending_json = {
"@context": [ "@context": [
"https://www.w3.org/ns/activitystreams" 'https://www.w3.org/ns/activitystreams',
'https://w3id.org/security/v1'
], ],
"id": actor, "id": actor,
"type": "OrderedCollection", "type": "OrderedCollection",

View File

@ -363,7 +363,10 @@ def announce_button_undo(self, calling_domain: str, path: str,
'/users/' + self.post_to_nickname '/users/' + self.post_to_nickname
un_repeat_to_str = 'https://www.w3.org/ns/activitystreams#Public' un_repeat_to_str = 'https://www.w3.org/ns/activitystreams#Public'
new_undo_announce = { 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, 'actor': undo_announce_actor,
'type': 'Undo', 'type': 'Undo',
'cc': [undo_announce_actor + '/followers'], 'cc': [undo_announce_actor + '/followers'],

View File

@ -155,7 +155,10 @@ def like_button(self, calling_domain: str, path: str,
liked_post_filename = None liked_post_filename = None
like_json = { like_json = {
"@context": "https://www.w3.org/ns/activitystreams", "@context": [
'https://www.w3.org/ns/activitystreams',
'https://w3id.org/security/v1'
],
'type': 'Like', 'type': 'Like',
'actor': like_actor, 'actor': like_actor,
'to': [actor_liked], 'to': [actor_liked],
@ -409,7 +412,10 @@ def like_button_undo(self, calling_domain: str, path: str,
liked_post_filename = None liked_post_filename = None
undo_like_json = { undo_like_json = {
"@context": "https://www.w3.org/ns/activitystreams", "@context": [
'https://www.w3.org/ns/activitystreams',
'https://w3id.org/security/v1'
],
'type': 'Undo', 'type': 'Undo',
'actor': undo_actor, 'actor': undo_actor,
'to': [actor_liked], 'to': [actor_liked],

View File

@ -177,7 +177,10 @@ def reaction_button(self, calling_domain: str, path: str,
reaction_post_filename = None reaction_post_filename = None
reaction_json = { reaction_json = {
"@context": "https://www.w3.org/ns/activitystreams", "@context": [
'https://www.w3.org/ns/activitystreams',
'https://w3id.org/security/v1'
],
'type': 'EmojiReact', 'type': 'EmojiReact',
'actor': reaction_actor, 'actor': reaction_actor,
'to': [actor_reaction], 'to': [actor_reaction],
@ -457,7 +460,10 @@ def reaction_button_undo(self, calling_domain: str, path: str,
reaction_post_filename = None reaction_post_filename = None
undo_reaction_json = { undo_reaction_json = {
"@context": "https://www.w3.org/ns/activitystreams", "@context": [
'https://www.w3.org/ns/activitystreams',
'https://w3id.org/security/v1'
],
'type': 'Undo', 'type': 'Undo',
'actor': undo_actor, 'actor': undo_actor,
'to': [actor_reaction], 'to': [actor_reaction],

View File

@ -928,9 +928,6 @@ def show_replies_to_post(self, authorized: bool,
if not os.path.isfile(post_replies_filename): if not os.path.isfile(post_replies_filename):
# There are no replies, # There are no replies,
# so show empty collection # so show empty collection
context_str = \
'https://www.w3.org/ns/activitystreams'
first_str = \ first_str = \
local_actor_url(http_prefix, nickname, domain_full) + \ local_actor_url(http_prefix, nickname, domain_full) + \
'/statuses/' + status_number + '/replies?page=true' '/statuses/' + status_number + '/replies?page=true'
@ -944,7 +941,10 @@ def show_replies_to_post(self, authorized: bool,
'/statuses/' + status_number + '/replies?page=true' '/statuses/' + status_number + '/replies?page=true'
replies_json = { replies_json = {
'@context': context_str, "@context": [
'https://www.w3.org/ns/activitystreams',
'https://w3id.org/security/v1'
],
'first': first_str, 'first': first_str,
'id': id_str, 'id': id_str,
'last': last_str, 'last': last_str,
@ -1031,8 +1031,6 @@ def show_replies_to_post(self, authorized: bool,
# replies exist. Itterate through the # replies exist. Itterate through the
# text file containing message ids # text file containing message ids
context_str = 'https://www.w3.org/ns/activitystreams'
id_str = \ id_str = \
local_actor_url(http_prefix, nickname, domain_full) + \ local_actor_url(http_prefix, nickname, domain_full) + \
'/statuses/' + status_number + '?page=true' '/statuses/' + status_number + '?page=true'
@ -1042,7 +1040,10 @@ def show_replies_to_post(self, authorized: bool,
'/statuses/' + status_number '/statuses/' + status_number
replies_json = { replies_json = {
'@context': context_str, "@context": [
'https://www.w3.org/ns/activitystreams',
'https://w3id.org/security/v1'
],
'id': id_str, 'id': id_str,
'orderedItems': [ 'orderedItems': [
], ],

View File

@ -103,7 +103,10 @@ def unfollow_confirm(self, calling_domain: str, cookie: str,
status_number, _ = get_status_number() status_number, _ = get_status_number()
follow_id = follow_actor + '/statuses/' + str(status_number) follow_id = follow_actor + '/statuses/' + str(status_number)
unfollow_json = { 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', 'id': follow_id + '/undo',
'type': 'Undo', 'type': 'Undo',
'actor': follow_actor, 'actor': follow_actor,

View File

@ -380,7 +380,10 @@ def receive_remove_post(self, calling_domain: str, cookie: str,
remove_post_actor remove_post_actor
] ]
delete_json = { 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, 'actor': remove_post_actor,
'object': remove_message_id, 'object': remove_message_id,
'to': to_list, 'to': to_list,

View File

@ -51,7 +51,10 @@ def send_delete_via_server(base_dir: str, session,
cc_url = actor + '/followers' cc_url = actor + '/followers'
new_delete_json = { new_delete_json = {
"@context": "https://www.w3.org/ns/activitystreams", "@context": [
'https://www.w3.org/ns/activitystreams',
'https://w3id.org/security/v1'
],
'actor': actor, 'actor': actor,
'cc': [cc_url], 'cc': [cc_url],
'object': delete_object_url, 'object': delete_object_url,

View File

@ -514,7 +514,10 @@ def get_following_feed(base_dir: str, domain: str, port: int, path: str,
total_str = \ total_str = \
_get_no_of_follows(base_dir, nickname, domain) _get_no_of_follows(base_dir, nickname, domain)
following = { following = {
'@context': 'https://www.w3.org/ns/activitystreams', "@context": [
'https://www.w3.org/ns/activitystreams',
'https://w3id.org/security/v1'
],
'first': first_str, 'first': first_str,
'id': id_str, 'id': id_str,
'totalItems': total_str, 'totalItems': total_str,
@ -532,7 +535,10 @@ def get_following_feed(base_dir: str, domain: str, port: int, path: str,
part_of_str = \ part_of_str = \
local_actor_url(http_prefix, nickname, domain) + '/' + follow_file local_actor_url(http_prefix, nickname, domain) + '/' + follow_file
following = { following = {
'@context': 'https://www.w3.org/ns/activitystreams', "@context": [
'https://www.w3.org/ns/activitystreams',
'https://w3id.org/security/v1'
],
'id': id_str, 'id': id_str,
'orderedItems': [], 'orderedItems': [],
'partOf': part_of_str, 'partOf': part_of_str,
@ -990,7 +996,10 @@ def send_follow_request(session, base_dir: str,
unfollowed_filename) unfollowed_filename)
new_follow_json = { 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), 'id': follow_actor + '/statuses/' + str(status_number),
'type': 'Follow', 'type': 'Follow',
'actor': follow_actor, 'actor': follow_actor,
@ -1052,7 +1061,10 @@ def send_follow_request_via_server(base_dir: str, session,
status_number, _ = get_status_number() status_number, _ = get_status_number()
new_follow_json = { 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), 'id': follow_actor + '/statuses/' + str(status_number),
'type': 'Follow', 'type': 'Follow',
'actor': follow_actor, 'actor': follow_actor,
@ -1145,7 +1157,10 @@ def send_unfollow_request_via_server(base_dir: str, session,
status_number, _ = get_status_number() status_number, _ = get_status_number()
unfollow_json = { 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', 'id': follow_actor + '/statuses/' + str(status_number) + '/undo',
'type': 'Undo', 'type': 'Undo',
'actor': follow_actor, 'actor': follow_actor,
@ -1587,7 +1602,8 @@ def pending_followers_timeline_json(actor: str, base_dir: str,
""" """
result_json = { result_json = {
"@context": [ "@context": [
"https://www.w3.org/ns/activitystreams" 'https://www.w3.org/ns/activitystreams',
'https://w3id.org/security/v1'
], ],
"id": actor, "id": actor,
"type": "OrderedCollection", "type": "OrderedCollection",

View File

@ -98,7 +98,10 @@ def _get_followers_sync_json(base_dir: str,
id_str = http_prefix + '://' + domain_full + \ id_str = http_prefix + '://' + domain_full + \
'/users/' + nickname + '/followers?domain=' + search_domain '/users/' + nickname + '/followers?domain=' + search_domain
sync_json = { sync_json = {
'@context': 'https://www.w3.org/ns/activitystreams', "@context": [
'https://www.w3.org/ns/activitystreams',
'https://w3id.org/security/v1'
],
'id': id_str, 'id': id_str,
'orderedItems': sync_list, 'orderedItems': sync_list,
'type': 'OrderedCollection' 'type': 'OrderedCollection'

View File

@ -1035,7 +1035,10 @@ def _dav_store_event(base_dir: str, nickname: str, domain: str,
"type": "Mention" "type": "Mention"
}, },
{ {
"@context": "https://www.w3.org/ns/activitystreams", "@context": [
'https://www.w3.org/ns/activitystreams',
'https://w3id.org/security/v1'
],
"type": "Event", "type": "Event",
"name": content, "name": content,
"startTime": start_time, "startTime": start_time,
@ -1056,7 +1059,10 @@ def _dav_store_event(base_dir: str, nickname: str, domain: str,
} }
if location: if location:
event_json['object']['tag'].append({ 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", "type": "Place",
"name": location "name": location
}) })

20
like.py
View File

@ -94,7 +94,10 @@ def _create_like(recent_posts_cache: {},
full_domain = get_full_domain(domain, port) full_domain = get_full_domain(domain, port)
new_like_json = { new_like_json = {
"@context": "https://www.w3.org/ns/activitystreams", "@context": [
'https://www.w3.org/ns/activitystreams',
'https://w3id.org/security/v1'
],
'type': 'Like', 'type': 'Like',
'actor': local_actor_url(http_prefix, nickname, full_domain), 'actor': local_actor_url(http_prefix, nickname, full_domain),
'object': object_url '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) actor = local_actor_url(http_prefix, from_nickname, from_domain_full)
new_like_json = { new_like_json = {
"@context": "https://www.w3.org/ns/activitystreams", "@context": [
'https://www.w3.org/ns/activitystreams',
'https://w3id.org/security/v1'
],
'type': 'Like', 'type': 'Like',
'actor': actor, 'actor': actor,
'object': like_url '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) actor = local_actor_url(http_prefix, from_nickname, from_domain_full)
new_undo_like_json = { 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', 'type': 'Undo',
'actor': actor, 'actor': actor,
'object': { 'object': {
@ -470,7 +479,10 @@ def update_likes_collection(recent_posts_cache: {},
if debug: if debug:
print('DEBUG: Adding initial like to ' + object_url) print('DEBUG: Adding initial like to ' + object_url)
likes_json = { likes_json = {
"@context": "https://www.w3.org/ns/activitystreams", "@context": [
'https://www.w3.org/ns/activitystreams',
'https://w3id.org/security/v1'
],
'id': object_url, 'id': object_url,
'type': 'Collection', 'type': 'Collection',
"totalItems": 1, "totalItems": 1,

View File

@ -637,6 +637,7 @@ def attach_media(base_dir: str, http_prefix: str,
if content_license_url or creator: if content_license_url or creator:
attachment_json['@context'] = [ attachment_json['@context'] = [
'https://www.w3.org/ns/activitystreams', 'https://www.w3.org/ns/activitystreams',
'https://w3id.org/security/v1',
{'schema': 'https://schema.org#'} {'schema': 'https://schema.org#'}
] ]
if content_license_url: if content_license_url:

View File

@ -358,7 +358,10 @@ def get_actor_move_json(actor_json: {}) -> {}:
return None return None
pub_number, _ = get_status_number() pub_number, _ = get_status_number()
return { 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, "id": actor_json['id'] + '#moved/' + pub_number,
"type": "Move", "type": "Move",
"actor": actor_json['id'], "actor": actor_json['id'],

5
pgp.py
View File

@ -643,7 +643,10 @@ def pgp_public_key_upload(base_dir: str, session,
# create an actor update # create an actor update
status_number, _ = get_status_number() status_number, _ = get_status_number()
actor_update = { 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, 'id': actor + '#updates/' + status_number,
'type': 'Update', 'type': 'Update',
'actor': actor, 'actor': actor,

View File

@ -1513,7 +1513,10 @@ def _create_post_place_and_time(event_date: str, end_date: str,
end_date_str = event_date_str end_date_str = event_date_str
if not schedule_post and not event_uuid: if not schedule_post and not event_uuid:
tags.append({ tags.append({
"@context": "https://www.w3.org/ns/activitystreams", "@context": [
'https://www.w3.org/ns/activitystreams',
'https://w3id.org/security/v1'
],
"type": "Event", "type": "Event",
"name": event_name, "name": event_name,
"startTime": event_date_str, "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') geocoords_from_map_link(location, 'openstreetmap.org')
if latitude and longitude: if latitude and longitude:
tags.append({ tags.append({
"@context": "https://www.w3.org/ns/activitystreams", "@context": [
'https://www.w3.org/ns/activitystreams',
'https://w3id.org/security/v1'
],
"type": "Place", "type": "Place",
"name": location, "name": location,
"latitude": latitude, "latitude": latitude,
@ -1534,7 +1540,10 @@ def _create_post_place_and_time(event_date: str, end_date: str,
}) })
else: else:
tags.append({ tags.append({
"@context": "https://www.w3.org/ns/activitystreams", "@context": [
'https://www.w3.org/ns/activitystreams',
'https://w3id.org/security/v1'
],
"type": "Place", "type": "Place",
"name": location "name": location
}) })
@ -1912,7 +1921,10 @@ def outbox_message_create_wrap(http_prefix: str,
if message_json.get('cc'): if message_json.get('cc'):
cc_list = message_json['cc'] cc_list = message_json['cc']
new_post = { 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', 'id': new_post_id + '/activity',
'type': 'Create', 'type': 'Create',
'actor': local_actor_url(http_prefix, nickname, domain), '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) page_str = '?page=' + str(page_number)
box_url = local_actor_url(http_prefix, nickname, domain) + '/' + boxname box_url = local_actor_url(http_prefix, nickname, domain) + '/' + boxname
box_header = { 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', 'first': box_url + '?page=true',
'id': box_url, 'id': box_url,
'last': box_url + '?page=true', 'last': box_url + '?page=true',
@ -4399,7 +4414,10 @@ def create_moderation(base_dir: str, nickname: str, domain: str, port: int,
'type': 'OrderedCollection' 'type': 'OrderedCollection'
} }
box_items = { 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, 'id': box_url + page_str,
'orderedItems': [ 'orderedItems': [
], ],
@ -4859,7 +4877,10 @@ def _create_box_indexed(recent_posts_cache: {},
'unable to convert page number to string') 'unable to convert page number to string')
box_url = local_actor_url(http_prefix, nickname, domain) + '/' + boxname box_url = local_actor_url(http_prefix, nickname, domain) + '/' + boxname
box_header = { 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', 'first': box_url + '?page=true',
'id': box_url, 'id': box_url,
'last': box_url + '?page=true', 'last': box_url + '?page=true',
@ -4867,7 +4888,10 @@ def _create_box_indexed(recent_posts_cache: {},
'type': 'OrderedCollection' 'type': 'OrderedCollection'
} }
box_items = { 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, 'id': box_url + page_str,
'orderedItems': [ 'orderedItems': [
], ],
@ -6385,7 +6409,10 @@ def send_block_via_server(base_dir: str, session,
cc_url = block_actor + '/followers' cc_url = block_actor + '/followers'
new_block_json = { new_block_json = {
"@context": "https://www.w3.org/ns/activitystreams", "@context": [
'https://www.w3.org/ns/activitystreams',
'https://w3id.org/security/v1'
],
'type': 'Block', 'type': 'Block',
'actor': block_actor, 'actor': block_actor,
'object': blocked_url, 'object': blocked_url,
@ -6472,7 +6499,10 @@ def send_mute_via_server(base_dir: str, session,
handle = replace_users_with_at(actor) handle = replace_users_with_at(actor)
new_mute_json = { new_mute_json = {
"@context": "https://www.w3.org/ns/activitystreams", "@context": [
'https://www.w3.org/ns/activitystreams',
'https://w3id.org/security/v1'
],
'type': 'Ignore', 'type': 'Ignore',
'actor': actor, 'actor': actor,
'to': [actor], 'to': [actor],
@ -6555,7 +6585,10 @@ def send_undo_mute_via_server(base_dir: str, session,
handle = replace_users_with_at(actor) handle = replace_users_with_at(actor)
undo_mute_json = { undo_mute_json = {
"@context": "https://www.w3.org/ns/activitystreams", "@context": [
'https://www.w3.org/ns/activitystreams',
'https://w3id.org/security/v1'
],
'type': 'Undo', 'type': 'Undo',
'actor': actor, 'actor': actor,
'to': [actor], 'to': [actor],
@ -6645,7 +6678,10 @@ def send_undo_block_via_server(base_dir: str, session,
cc_url = block_actor + '/followers' cc_url = block_actor + '/followers'
new_block_json = { new_block_json = {
"@context": "https://www.w3.org/ns/activitystreams", "@context": [
'https://www.w3.org/ns/activitystreams',
'https://w3id.org/security/v1'
],
'type': 'Undo', 'type': 'Undo',
'actor': block_actor, 'actor': block_actor,
'object': { 'object': {

View File

@ -92,7 +92,10 @@ def _reactionpost(recent_posts_cache: {},
full_domain = get_full_domain(domain, port) full_domain = get_full_domain(domain, port)
new_reaction_json = { new_reaction_json = {
"@context": "https://www.w3.org/ns/activitystreams", "@context": [
'https://www.w3.org/ns/activitystreams',
'https://w3id.org/security/v1'
],
'type': 'EmojiReact', 'type': 'EmojiReact',
'actor': local_actor_url(http_prefix, nickname, full_domain), 'actor': local_actor_url(http_prefix, nickname, full_domain),
'object': object_url, '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) actor = local_actor_url(http_prefix, from_nickname, from_domain_full)
new_reaction_json = { new_reaction_json = {
"@context": "https://www.w3.org/ns/activitystreams", "@context": [
'https://www.w3.org/ns/activitystreams',
'https://w3id.org/security/v1'
],
'type': 'EmojiReact', 'type': 'EmojiReact',
'actor': actor, 'actor': actor,
'object': reaction_url, '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) actor = local_actor_url(http_prefix, from_nickname, from_domain_full)
new_undo_reaction_json = { 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', 'type': 'Undo',
'actor': actor, 'actor': actor,
'object': { 'object': {
@ -550,7 +559,10 @@ def update_reaction_collection(recent_posts_cache: {},
if debug: if debug:
print('DEBUG: Adding initial emoji reaction to ' + object_url) print('DEBUG: Adding initial emoji reaction to ' + object_url)
reactions_json = { reactions_json = {
"@context": "https://www.w3.org/ns/activitystreams", "@context": [
'https://www.w3.org/ns/activitystreams',
'https://w3id.org/security/v1'
],
'id': object_url, 'id': object_url,
'type': 'Collection', 'type': 'Collection',
"totalItems": 1, "totalItems": 1,

View File

@ -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' local_actor_url(http_prefix, nickname, domain) + '/moved'
total_str = str(len(lines.items())) total_str = str(len(lines.items()))
following = { following = {
'@context': 'https://www.w3.org/ns/activitystreams', "@context": [
'https://www.w3.org/ns/activitystreams',
'https://w3id.org/security/v1'
],
'first': first_str, 'first': first_str,
'id': id_str, 'id': id_str,
'orderedItems': [], 'orderedItems': [],
@ -147,7 +150,10 @@ def get_moved_feed(base_dir: str, domain: str, port: int, path: str,
part_of_str = \ part_of_str = \
local_actor_url(http_prefix, nickname, domain) + '/moved' local_actor_url(http_prefix, nickname, domain) + '/moved'
following = { following = {
'@context': 'https://www.w3.org/ns/activitystreams', "@context": [
'https://www.w3.org/ns/activitystreams',
'https://w3id.org/security/v1'
],
'id': id_str, 'id': id_str,
'orderedItems': [], 'orderedItems': [],
'partOf': part_of_str, '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' local_actor_url(http_prefix, nickname, domain) + '/inactive'
total_str = str(len(lines)) total_str = str(len(lines))
following = { following = {
'@context': 'https://www.w3.org/ns/activitystreams', "@context": [
'https://www.w3.org/ns/activitystreams',
'https://w3id.org/security/v1'
],
'first': first_str, 'first': first_str,
'id': id_str, 'id': id_str,
'orderedItems': [], 'orderedItems': [],
@ -451,7 +460,10 @@ def get_inactive_feed(base_dir: str, domain: str, port: int, path: str,
part_of_str = \ part_of_str = \
local_actor_url(http_prefix, nickname, domain) + '/inactive' local_actor_url(http_prefix, nickname, domain) + '/inactive'
following = { following = {
'@context': 'https://www.w3.org/ns/activitystreams', "@context": [
'https://www.w3.org/ns/activitystreams',
'https://w3id.org/security/v1'
],
'id': id_str, 'id': id_str,
'orderedItems': [], 'orderedItems': [],
'partOf': part_of_str, 'partOf': part_of_str,

View File

@ -568,7 +568,10 @@ def get_shares_feed_for_person(base_dir: str,
no_of_shares = len(shares_json.items()) no_of_shares = len(shares_json.items())
id_str = local_actor_url(http_prefix, nickname, domain) id_str = local_actor_url(http_prefix, nickname, domain)
shares = { 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', 'first': id_str + '/' + shares_file_type + '?page=1',
'id': id_str + '/' + shares_file_type, 'id': id_str + '/' + shares_file_type,
'totalItems': str(no_of_shares), '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) next_page_number = int(page_number + 1)
id_str = local_actor_url(http_prefix, nickname, domain) id_str = local_actor_url(http_prefix, nickname, domain)
shares = { 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), 'id': id_str + '/' + shares_file_type + '?page=' + str(page_number),
'orderedItems': [], 'orderedItems': [],
'partOf': id_str + '/' + shares_file_type, 'partOf': id_str + '/' + shares_file_type,
@ -650,7 +656,10 @@ def send_share_via_server(base_dir, session,
cc_url = actor + '/followers' cc_url = actor + '/followers'
new_share_json = { new_share_json = {
"@context": "https://www.w3.org/ns/activitystreams", "@context": [
'https://www.w3.org/ns/activitystreams',
'https://w3id.org/security/v1'
],
'type': 'Add', 'type': 'Add',
'actor': actor, 'actor': actor,
'target': actor + '/shares', 'target': actor + '/shares',
@ -764,7 +773,10 @@ def send_undo_share_via_server(base_dir: str, session,
cc_url = actor + '/followers' cc_url = actor + '/followers'
undo_share_json = { undo_share_json = {
"@context": "https://www.w3.org/ns/activitystreams", "@context": [
'https://www.w3.org/ns/activitystreams',
'https://w3id.org/security/v1'
],
'type': 'Remove', 'type': 'Remove',
'actor': actor, 'actor': actor,
'target': actor + '/shares', 'target': actor + '/shares',
@ -873,7 +885,10 @@ def send_wanted_via_server(base_dir, session,
cc_url = actor + '/followers' cc_url = actor + '/followers'
new_share_json = { new_share_json = {
"@context": "https://www.w3.org/ns/activitystreams", "@context": [
'https://www.w3.org/ns/activitystreams',
'https://w3id.org/security/v1'
],
'type': 'Add', 'type': 'Add',
'actor': actor, 'actor': actor,
'target': actor + '/wanted', 'target': actor + '/wanted',
@ -987,7 +1002,10 @@ def send_undo_wanted_via_server(base_dir: str, session,
cc_url = actor + '/followers' cc_url = actor + '/followers'
undo_share_json = { undo_share_json = {
"@context": "https://www.w3.org/ns/activitystreams", "@context": [
'https://www.w3.org/ns/activitystreams',
'https://w3id.org/security/v1'
],
'type': 'Remove', 'type': 'Remove',
'actor': actor, 'actor': actor,
'target': actor + '/wanted', 'target': actor + '/wanted',

View File

@ -4147,7 +4147,10 @@ def _test_jsonld():
print("test_jsonld") print("test_jsonld")
jld_document = { 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", "actor": "https://somesite.net/users/gerbil",
"description": "My json document", "description": "My json document",
"numberField": 83582, "numberField": 83582,
@ -4209,7 +4212,10 @@ def _test_jsonld():
assert not verify_json_signature(signed_document, public_key_pem) assert not verify_json_signature(signed_document, public_key_pem)
jld_document2 = { 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", "actor": "https://somesite.net/users/gerbil",
"description": "Another json document", "description": "Another json document",
"numberField": 13353, "numberField": 13353,
@ -8525,8 +8531,15 @@ def _test_book_link(base_dir: str):
id_str = actor + '/generatednote/63472854' id_str = actor + '/generatednote/63472854'
published = '2024-01-01T10:30:00.2+00:00' published = '2024-01-01T10:30:00.2+00:00'
post_json_object = { post_json_object = {
'@context': 'https://www.w3.org/ns/activitystreams', "@context": [
'attachment': [{'@context': 'https://www.w3.org/ns/activitystreams', '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, 'name': title,
'type': 'Document', 'type': 'Document',
'url': image_url}], 'url': image_url}],

View File

@ -3302,7 +3302,10 @@ def update_announce_collection(recent_posts_cache: {},
print('DEBUG: Adding initial shares (announcements) to ' + print('DEBUG: Adding initial shares (announcements) to ' +
post_url) post_url)
announcements_json = { announcements_json = {
"@context": "https://www.w3.org/ns/activitystreams", "@context": [
'https://www.w3.org/ns/activitystreams',
'https://w3id.org/security/v1'
],
'id': post_url, 'id': post_url,
'type': 'Collection', 'type': 'Collection',
"totalItems": 1, "totalItems": 1,

View File

@ -1440,7 +1440,10 @@ def hashtag_search_json(nickname: str, domain: str, port: int,
url = http_prefix + '://' + domain_full + '/tags/' + \ url = http_prefix + '://' + domain_full + '/tags/' + \
hashtag + '?page=' + str(page_number) hashtag + '?page=' + str(page_number)
hashtag_json = { hashtag_json = {
'@context': 'https://www.w3.org/ns/activitystreams', "@context": [
'https://www.w3.org/ns/activitystreams',
'https://w3id.org/security/v1'
],
'id': url, 'id': url,
'orderedItems': [], 'orderedItems': [],
'totalItems': 0, 'totalItems': 0,

View File

@ -625,7 +625,8 @@ def get_shares_collection(actor: str, page_number: int, items_per_page: int,
result_json = { result_json = {
"@context": [ "@context": [
"https://www.w3.org/ns/activitystreams" 'https://www.w3.org/ns/activitystreams',
'https://w3id.org/security/v1'
], ],
"id": actor + '?page=' + str(page_number), "id": actor + '?page=' + str(page_number),
"type": "OrderedCollection", "type": "OrderedCollection",