properly set create_id and announce_id in community outbox

This commit is contained in:
rimu 2024-03-09 19:13:15 +13:00
parent 3dff7ef2e7
commit 6408432da6

View file

@ -115,13 +115,16 @@ def send_activity(sender: User, host: str, content: str):
def post_to_activity(post: Post, community: Community): def post_to_activity(post: Post, community: Community):
# local PieFed posts do not have a create or announce id
create_id = post.ap_create_id if post.ap_create_id else f"https://{current_app.config['SERVER_NAME']}/activities/create/{gibberish(15)}"
announce_id = post.ap_announce_id if post.ap_announce_id else f"https://{current_app.config['SERVER_NAME']}/activities/announce/{gibberish(15)}"
activity_data = { activity_data = {
"actor": f"https://{current_app.config['SERVER_NAME']}/c/{community.name}", "actor": f"https://{current_app.config['SERVER_NAME']}/c/{community.name}",
"to": [ "to": [
"https://www.w3.org/ns/activitystreams#Public" "https://www.w3.org/ns/activitystreams#Public"
], ],
"object": { "object": {
"id": f"https://{current_app.config['SERVER_NAME']}/activities/create/{post.ap_create_id}", "id": create_id,
"actor": f"https://{current_app.config['SERVER_NAME']}/u/{post.author.user_name}", "actor": f"https://{current_app.config['SERVER_NAME']}/u/{post.author.user_name}",
"to": [ "to": [
"https://www.w3.org/ns/activitystreams#Public" "https://www.w3.org/ns/activitystreams#Public"
@ -159,7 +162,7 @@ def post_to_activity(post: Post, community: Community):
f"https://{current_app.config['SERVER_NAME']}/c/{community.name}/followers" f"https://{current_app.config['SERVER_NAME']}/c/{community.name}/followers"
], ],
"type": "Announce", "type": "Announce",
"id": f"https://{current_app.config['SERVER_NAME']}/activities/announce/{post.ap_announce_id}" "id": announce_id
} }
if post.edited_at is not None: if post.edited_at is not None:
activity_data["object"]["object"]["updated"] = ap_datetime(post.edited_at) activity_data["object"]["object"]["updated"] = ap_datetime(post.edited_at)