From c879eb1244c0a6a1b646ac4c8753030483298e98 Mon Sep 17 00:00:00 2001 From: Nutomic Date: Thu, 9 Jan 2025 14:41:39 +0000 Subject: [PATCH] Remove unused apub audience field (fixes #5278) (#5315) * Remove unused apub audience field (fixes #5278) * fix * fix test * remove comments --- .../lemmy/activities/block/block_user.json | 1 - .../activities/block/undo_block_user.json | 2 -- .../community/add_featured_post.json | 3 +-- .../lemmy/activities/community/add_mod.json | 1 - .../lemmy/activities/community/lock_page.json | 3 +-- .../community/remove_featured_post.json | 3 +-- .../activities/community/remove_mod.json | 1 - .../activities/community/report_page.json | 1 - .../activities/community/undo_lock_page.json | 6 ++--- .../community/update_community.json | 1 - .../create_or_update/create_comment.json | 2 -- .../create_or_update/create_page.json | 2 -- .../create_or_update/update_page.json | 2 -- .../activities/deletion/delete_page.json | 1 - .../activities/deletion/remove_note.json | 1 - .../activities/deletion/undo_delete_page.json | 2 -- .../activities/deletion/undo_remove_note.json | 2 -- .../lemmy/activities/voting/dislike_page.json | 1 - .../lemmy/activities/voting/like_note.json | 1 - .../activities/voting/undo_dislike_page.json | 2 -- .../activities/voting/undo_like_note.json | 2 -- .../collections/group_featured_posts.json | 6 ++--- crates/apub/assets/lemmy/objects/comment.json | 7 +++--- crates/apub/assets/lemmy/objects/page.json | 1 - .../apub/src/activities/block/block_user.rs | 5 ++--- crates/apub/src/activities/block/mod.rs | 8 +++---- .../src/activities/block/undo_block_user.rs | 5 ++--- .../apub/src/activities/community/announce.rs | 2 +- .../activities/community/collection_add.rs | 6 ++--- .../activities/community/collection_remove.rs | 6 ++--- .../src/activities/community/lock_page.rs | 6 ++--- .../apub/src/activities/community/report.rs | 1 - .../apub/src/activities/community/update.rs | 3 +-- .../activities/create_or_update/comment.rs | 3 +-- .../src/activities/create_or_update/post.rs | 3 +-- crates/apub/src/activities/deletion/delete.rs | 1 - crates/apub/src/activities/deletion/mod.rs | 2 +- .../src/activities/deletion/undo_delete.rs | 1 - crates/apub/src/activities/mod.rs | 22 ++++++------------- crates/apub/src/activities/voting/mod.rs | 6 ++--- .../apub/src/activities/voting/undo_vote.rs | 4 +--- crates/apub/src/activities/voting/vote.rs | 4 +--- crates/apub/src/mentions.rs | 9 ++++---- crates/apub/src/objects/comment.rs | 5 ++--- crates/apub/src/objects/post.rs | 3 +-- .../protocol/activities/block/block_user.rs | 6 +---- .../activities/block/undo_block_user.rs | 5 ----- .../activities/community/collection_add.rs | 5 ----- .../activities/community/collection_remove.rs | 5 ----- .../activities/community/lock_page.rs | 9 -------- .../protocol/activities/community/report.rs | 5 ----- .../protocol/activities/community/update.rs | 5 ----- .../activities/create_or_update/note.rs | 5 ----- .../activities/create_or_update/page.rs | 5 ----- .../protocol/activities/deletion/delete.rs | 6 +---- .../activities/deletion/undo_delete.rs | 5 ----- .../protocol/activities/voting/undo_vote.rs | 5 ----- .../src/protocol/activities/voting/vote.rs | 5 ----- crates/apub/src/protocol/mod.rs | 2 -- crates/apub/src/protocol/objects/note.rs | 5 ----- crates/apub/src/protocol/objects/page.rs | 9 -------- crates/federate/src/worker.rs | 1 - 62 files changed, 49 insertions(+), 198 deletions(-) diff --git a/crates/apub/assets/lemmy/activities/block/block_user.json b/crates/apub/assets/lemmy/activities/block/block_user.json index f6d6170c32..1fd0d534e3 100644 --- a/crates/apub/assets/lemmy/activities/block/block_user.json +++ b/crates/apub/assets/lemmy/activities/block/block_user.json @@ -3,7 +3,6 @@ "to": ["https://www.w3.org/ns/activitystreams#Public"], "object": "http://ds9.lemmy.ml/u/lemmy_alpha", "cc": ["http://enterprise.lemmy.ml/c/main"], - "audience": "http://enterprise.lemmy.ml/u/main", "target": "http://enterprise.lemmy.ml/c/main", "type": "Block", "removeData": true, diff --git a/crates/apub/assets/lemmy/activities/block/undo_block_user.json b/crates/apub/assets/lemmy/activities/block/undo_block_user.json index 922b5e7779..a403a82b7d 100644 --- a/crates/apub/assets/lemmy/activities/block/undo_block_user.json +++ b/crates/apub/assets/lemmy/activities/block/undo_block_user.json @@ -6,7 +6,6 @@ "to": ["https://www.w3.org/ns/activitystreams#Public"], "object": "http://ds9.lemmy.ml/u/lemmy_alpha", "cc": ["http://enterprise.lemmy.ml/c/main"], - "audience": "http://enterprise.lemmy.ml/u/main", "target": "http://enterprise.lemmy.ml/c/main", "type": "Block", "removeData": true, @@ -15,7 +14,6 @@ "id": "http://enterprise.lemmy.ml/activities/block/726f43ab-bd0e-4ab3-89c8-627e976f553c" }, "cc": ["http://enterprise.lemmy.ml/c/main"], - "audience": "http://enterprise.lemmy.ml/u/main", "type": "Undo", "id": "http://enterprise.lemmy.ml/activities/undo/06a20ffb-3e32-42fb-8f4c-674b36d7c557" } diff --git a/crates/apub/assets/lemmy/activities/community/add_featured_post.json b/crates/apub/assets/lemmy/activities/community/add_featured_post.json index 20fe6fd354..f2f0765765 100644 --- a/crates/apub/assets/lemmy/activities/community/add_featured_post.json +++ b/crates/apub/assets/lemmy/activities/community/add_featured_post.json @@ -5,6 +5,5 @@ "type": "Add", "actor": "https://ds9.lemmy.ml/u/lemmy_alpha", "object": "https://ds9.lemmy.ml/post/2", - "target": "https://ds9.lemmy.ml/c/main/featured", - "audience": "https://ds9.lemmy.ml/c/main" + "target": "https://ds9.lemmy.ml/c/main/featured" } diff --git a/crates/apub/assets/lemmy/activities/community/add_mod.json b/crates/apub/assets/lemmy/activities/community/add_mod.json index f440cab8f5..84f1bacbbc 100644 --- a/crates/apub/assets/lemmy/activities/community/add_mod.json +++ b/crates/apub/assets/lemmy/activities/community/add_mod.json @@ -4,7 +4,6 @@ "object": "http://ds9.lemmy.ml/u/lemmy_alpha", "target": "http://enterprise.lemmy.ml/c/main/moderators", "cc": ["http://enterprise.lemmy.ml/c/main"], - "audience": "http://enterprise.lemmy.ml/u/main", "type": "Add", "id": "http://enterprise.lemmy.ml/activities/add/ec069147-77c3-447f-88c8-0ef1df10403f" } diff --git a/crates/apub/assets/lemmy/activities/community/lock_page.json b/crates/apub/assets/lemmy/activities/community/lock_page.json index b98db74025..cbf41ca62a 100644 --- a/crates/apub/assets/lemmy/activities/community/lock_page.json +++ b/crates/apub/assets/lemmy/activities/community/lock_page.json @@ -4,6 +4,5 @@ "to": ["https://www.w3.org/ns/activitystreams#Public"], "object": "http://lemmy-alpha:8541/post/2", "cc": ["http://lemmy-alpha:8541/c/main"], - "type": "Lock", - "audience": "http://lemmy-alpha:8541/c/main" + "type": "Lock" } diff --git a/crates/apub/assets/lemmy/activities/community/remove_featured_post.json b/crates/apub/assets/lemmy/activities/community/remove_featured_post.json index 4cabb95d2a..b9b84e2d13 100644 --- a/crates/apub/assets/lemmy/activities/community/remove_featured_post.json +++ b/crates/apub/assets/lemmy/activities/community/remove_featured_post.json @@ -5,6 +5,5 @@ "type": "Remove", "actor": "https://ds9.lemmy.ml/u/lemmy_alpha", "object": "https://ds9.lemmy.ml/post/2", - "target": "https://ds9.lemmy.ml/c/main/featured", - "audience": "https://ds9.lemmy.ml/c/main" + "target": "https://ds9.lemmy.ml/c/main/featured" } diff --git a/crates/apub/assets/lemmy/activities/community/remove_mod.json b/crates/apub/assets/lemmy/activities/community/remove_mod.json index 17f38078c6..1deee80580 100644 --- a/crates/apub/assets/lemmy/activities/community/remove_mod.json +++ b/crates/apub/assets/lemmy/activities/community/remove_mod.json @@ -5,6 +5,5 @@ "cc": ["http://enterprise.lemmy.ml/c/main"], "type": "Remove", "target": "http://enterprise.lemmy.ml/c/main/moderators", - "audience": "http://enterprise.lemmy.ml/u/main", "id": "http://enterprise.lemmy.ml/activities/remove/aab114f8-cfbd-4935-a5b7-e1a64603650d" } diff --git a/crates/apub/assets/lemmy/activities/community/report_page.json b/crates/apub/assets/lemmy/activities/community/report_page.json index e35a623df1..718b142e1d 100644 --- a/crates/apub/assets/lemmy/activities/community/report_page.json +++ b/crates/apub/assets/lemmy/activities/community/report_page.json @@ -1,7 +1,6 @@ { "actor": "http://ds9.lemmy.ml/u/lemmy_alpha", "to": ["http://enterprise.lemmy.ml/c/main"], - "audience": "http://enterprise.lemmy.ml/u/main", "object": "http://enterprise.lemmy.ml/post/7", "summary": "report this post", "type": "Flag", diff --git a/crates/apub/assets/lemmy/activities/community/undo_lock_page.json b/crates/apub/assets/lemmy/activities/community/undo_lock_page.json index 58c8cdbb3d..f50ef4e2a2 100644 --- a/crates/apub/assets/lemmy/activities/community/undo_lock_page.json +++ b/crates/apub/assets/lemmy/activities/community/undo_lock_page.json @@ -8,10 +8,8 @@ "object": "http://lemmy-alpha:8541/post/2", "cc": ["http://lemmy-alpha:8541/c/main"], "type": "Lock", - "id": "http://lemmy-alpha:8541/activities/lock/08b6fd3e-9ef3-4358-a987-8bb641f3e2c3", - "audience": "http://lemmy-alpha:8541/c/main" + "id": "http://lemmy-alpha:8541/activities/lock/08b6fd3e-9ef3-4358-a987-8bb641f3e2c3" }, "cc": ["http://lemmy-alpha:8541/c/main"], - "type": "Undo", - "audience": "http://lemmy-alpha:8541/c/main" + "type": "Undo" } diff --git a/crates/apub/assets/lemmy/activities/community/update_community.json b/crates/apub/assets/lemmy/activities/community/update_community.json index 604e04d45c..824cb055c1 100644 --- a/crates/apub/assets/lemmy/activities/community/update_community.json +++ b/crates/apub/assets/lemmy/activities/community/update_community.json @@ -39,7 +39,6 @@ "updated": "2021-11-01T12:23:50.151874Z" }, "cc": ["http://enterprise.lemmy.ml/c/main"], - "audience": "http://enterprise.lemmy.ml/u/main", "type": "Update", "id": "http://ds9.lemmy.ml/activities/update/d3717cf5-096d-473f-9530-5d52f9d51f5f" } diff --git a/crates/apub/assets/lemmy/activities/create_or_update/create_comment.json b/crates/apub/assets/lemmy/activities/create_or_update/create_comment.json index a12eeb51cb..de419d42ba 100644 --- a/crates/apub/assets/lemmy/activities/create_or_update/create_comment.json +++ b/crates/apub/assets/lemmy/activities/create_or_update/create_comment.json @@ -10,7 +10,6 @@ "http://enterprise.lemmy.ml/c/main", "http://ds9.lemmy.ml/u/lemmy_alpha" ], - "audience": "http://ds9.lemmy.ml/u/lemmy_alpha", "content": "hello", "mediaType": "text/html", "source": { @@ -24,7 +23,6 @@ "http://enterprise.lemmy.ml/c/main", "http://ds9.lemmy.ml/u/lemmy_alpha" ], - "audience": "http://ds9.lemmy.ml/u/lemmy_alpha", "tag": [ { "href": "http://ds9.lemmy.ml/u/lemmy_alpha", diff --git a/crates/apub/assets/lemmy/activities/create_or_update/create_page.json b/crates/apub/assets/lemmy/activities/create_or_update/create_page.json index 114c5b557b..1db8ccf967 100644 --- a/crates/apub/assets/lemmy/activities/create_or_update/create_page.json +++ b/crates/apub/assets/lemmy/activities/create_or_update/create_page.json @@ -9,7 +9,6 @@ "http://enterprise.lemmy.ml/c/main", "https://www.w3.org/ns/activitystreams#Public" ], - "audience": "https://enterprise.lemmy.ml/c/main", "name": "test post", "content": "

test body

\n", "mediaType": "text/html", @@ -31,7 +30,6 @@ "published": "2021-10-29T15:10:51.557399Z" }, "cc": ["http://enterprise.lemmy.ml/c/main"], - "audience": "https://enterprise.lemmy.ml/c/main", "type": "Create", "id": "http://ds9.lemmy.ml/activities/create/eee6a57a-622f-464d-b560-73ae1fcd3ddf" } diff --git a/crates/apub/assets/lemmy/activities/create_or_update/update_page.json b/crates/apub/assets/lemmy/activities/create_or_update/update_page.json index e9569e6f7b..fba3aa2bd7 100644 --- a/crates/apub/assets/lemmy/activities/create_or_update/update_page.json +++ b/crates/apub/assets/lemmy/activities/create_or_update/update_page.json @@ -9,7 +9,6 @@ "http://enterprise.lemmy.ml/c/main", "https://www.w3.org/ns/activitystreams#Public" ], - "audience": "https://enterprise.lemmy.ml/c/main", "name": "test post 1", "content": "

test body

\n", "mediaType": "text/html", @@ -28,7 +27,6 @@ "updated": "2021-10-29T15:11:35.976374Z" }, "cc": ["http://enterprise.lemmy.ml/c/main"], - "audience": "https://enterprise.lemmy.ml/c/main", "type": "Update", "id": "http://ds9.lemmy.ml/activities/update/ab360117-e165-4de4-b7fc-906b62c98631" } diff --git a/crates/apub/assets/lemmy/activities/deletion/delete_page.json b/crates/apub/assets/lemmy/activities/deletion/delete_page.json index d0fcdea5b5..73bcb18fad 100644 --- a/crates/apub/assets/lemmy/activities/deletion/delete_page.json +++ b/crates/apub/assets/lemmy/activities/deletion/delete_page.json @@ -3,7 +3,6 @@ "to": ["https://www.w3.org/ns/activitystreams#Public"], "object": "http://ds9.lemmy.ml/post/1", "cc": ["http://enterprise.lemmy.ml/c/main"], - "audience": "http://enterprise.lemmy.ml/u/main", "type": "Delete", "id": "http://ds9.lemmy.ml/activities/delete/f2abee48-c7bb-41d5-9e27-8775ff32db12" } diff --git a/crates/apub/assets/lemmy/activities/deletion/remove_note.json b/crates/apub/assets/lemmy/activities/deletion/remove_note.json index b0d6e5e8d1..78a3413040 100644 --- a/crates/apub/assets/lemmy/activities/deletion/remove_note.json +++ b/crates/apub/assets/lemmy/activities/deletion/remove_note.json @@ -3,7 +3,6 @@ "to": ["https://www.w3.org/ns/activitystreams#Public"], "object": "http://ds9.lemmy.ml/comment/1", "cc": ["http://enterprise.lemmy.ml/c/main"], - "audience": "http://enterprise.lemmy.ml/u/main", "type": "Delete", "summary": "bad comment", "id": "http://enterprise.lemmy.ml/activities/delete/42ca1a79-f99e-4518-a2ca-ba2df221eb5e" diff --git a/crates/apub/assets/lemmy/activities/deletion/undo_delete_page.json b/crates/apub/assets/lemmy/activities/deletion/undo_delete_page.json index dc5307d7cc..1d50739597 100644 --- a/crates/apub/assets/lemmy/activities/deletion/undo_delete_page.json +++ b/crates/apub/assets/lemmy/activities/deletion/undo_delete_page.json @@ -6,12 +6,10 @@ "to": ["https://www.w3.org/ns/activitystreams#Public"], "object": "http://ds9.lemmy.ml/post/1", "cc": ["http://enterprise.lemmy.ml/c/main"], - "audience": "http://enterprise.lemmy.ml/u/main", "type": "Delete", "id": "http://ds9.lemmy.ml/activities/delete/b13cca96-7737-41e1-9769-8fbf972b3509" }, "cc": ["http://enterprise.lemmy.ml/c/main"], - "audience": "http://enterprise.lemmy.ml/u/main", "type": "Undo", "id": "http://ds9.lemmy.ml/activities/undo/5e939cfb-b8a1-4de8-950f-9d684e9162b9" } diff --git a/crates/apub/assets/lemmy/activities/deletion/undo_remove_note.json b/crates/apub/assets/lemmy/activities/deletion/undo_remove_note.json index 4c335acca3..d8182b0334 100644 --- a/crates/apub/assets/lemmy/activities/deletion/undo_remove_note.json +++ b/crates/apub/assets/lemmy/activities/deletion/undo_remove_note.json @@ -6,13 +6,11 @@ "to": ["https://www.w3.org/ns/activitystreams#Public"], "object": "http://ds9.lemmy.ml/comment/1", "cc": ["http://enterprise.lemmy.ml/c/main"], - "audience": "http://enterprise.lemmy.ml/u/main", "type": "Delete", "summary": "bad comment", "id": "http://enterprise.lemmy.ml/activities/delete/2598435c-87a3-49cd-81f3-a44b03b7af9d" }, "cc": ["http://enterprise.lemmy.ml/c/main"], - "audience": "http://enterprise.lemmy.ml/u/main", "type": "Undo", "id": "http://enterprise.lemmy.ml/activities/undo/a850cf21-3866-4b3a-b80b-56aa00997fee" } diff --git a/crates/apub/assets/lemmy/activities/voting/dislike_page.json b/crates/apub/assets/lemmy/activities/voting/dislike_page.json index bfa12972b2..220e1c3d4e 100644 --- a/crates/apub/assets/lemmy/activities/voting/dislike_page.json +++ b/crates/apub/assets/lemmy/activities/voting/dislike_page.json @@ -1,7 +1,6 @@ { "actor": "http://enterprise.lemmy.ml/u/lemmy_beta", "object": "http://ds9.lemmy.ml/post/1", - "audience": "https://enterprise.lemmy.ml/c/tenforward", "type": "Dislike", "id": "http://enterprise.lemmy.ml/activities/dislike/64d40d40-a829-43a5-8247-1fb595b3ca1c" } diff --git a/crates/apub/assets/lemmy/activities/voting/like_note.json b/crates/apub/assets/lemmy/activities/voting/like_note.json index ffc6fccc96..a53cae113c 100644 --- a/crates/apub/assets/lemmy/activities/voting/like_note.json +++ b/crates/apub/assets/lemmy/activities/voting/like_note.json @@ -1,7 +1,6 @@ { "actor": "http://ds9.lemmy.ml/u/lemmy_alpha", "object": "http://ds9.lemmy.ml/comment/1", - "audience": "https://enterprise.lemmy.ml/c/tenforward", "type": "Like", "id": "http://ds9.lemmy.ml/activities/like/fd61d070-7382-46a9-b2b7-6bb253732877" } diff --git a/crates/apub/assets/lemmy/activities/voting/undo_dislike_page.json b/crates/apub/assets/lemmy/activities/voting/undo_dislike_page.json index d5e1982b1f..9bc1e448a1 100644 --- a/crates/apub/assets/lemmy/activities/voting/undo_dislike_page.json +++ b/crates/apub/assets/lemmy/activities/voting/undo_dislike_page.json @@ -3,11 +3,9 @@ "object": { "actor": "http://enterprise.lemmy.ml/u/lemmy_beta", "object": "http://ds9.lemmy.ml/post/1", - "audience": "https://enterprise.lemmy.ml/c/tenforward", "type": "Like", "id": "http://enterprise.lemmy.ml/activities/like/2227ab2c-79e2-4fca-a1d2-1d67dacf2457" }, - "audience": "https://enterprise.lemmy.ml/c/tenforward", "type": "Undo", "id": "http://enterprise.lemmy.ml/activities/undo/6cc6fb71-39fe-49ea-9506-f0423b101e98" } diff --git a/crates/apub/assets/lemmy/activities/voting/undo_like_note.json b/crates/apub/assets/lemmy/activities/voting/undo_like_note.json index 3619636a8d..f807623ed1 100644 --- a/crates/apub/assets/lemmy/activities/voting/undo_like_note.json +++ b/crates/apub/assets/lemmy/activities/voting/undo_like_note.json @@ -3,11 +3,9 @@ "object": { "actor": "http://ds9.lemmy.ml/u/lemmy_alpha", "object": "http://ds9.lemmy.ml/comment/1", - "audience": "https://enterprise.lemmy.ml/c/tenforward", "type": "Like", "id": "http://ds9.lemmy.ml/activities/like/efcf7ae2-dfcc-4ff4-9ce4-6adf251ff004" }, - "audience": "https://enterprise.lemmy.ml/c/tenforward", "type": "Undo", "id": "http://ds9.lemmy.ml/activities/undo/3518565c-24a7-4d9e-8e0a-f7a2f45ac618" } diff --git a/crates/apub/assets/lemmy/collections/group_featured_posts.json b/crates/apub/assets/lemmy/collections/group_featured_posts.json index 70b4d7d3ab..bc81b0dbd4 100644 --- a/crates/apub/assets/lemmy/collections/group_featured_posts.json +++ b/crates/apub/assets/lemmy/collections/group_featured_posts.json @@ -20,8 +20,7 @@ "language": { "identifier": "de", "name": "Deutsch" - }, - "audience": "https://ds9.lemmy.ml/c/main" + } }, { "type": "Page", @@ -40,8 +39,7 @@ "language": { "identifier": "de", "name": "Deutsch" - }, - "audience": "https://ds9.lemmy.ml/c/main" + } } ] } diff --git a/crates/apub/assets/lemmy/objects/comment.json b/crates/apub/assets/lemmy/objects/comment.json index 8366ebd6d8..d8282ab5c1 100644 --- a/crates/apub/assets/lemmy/objects/comment.json +++ b/crates/apub/assets/lemmy/objects/comment.json @@ -2,12 +2,11 @@ "id": "https://enterprise.lemmy.ml/comment/38741", "type": "Note", "attributedTo": "https://enterprise.lemmy.ml/u/picard", - "to": ["https://www.w3.org/ns/activitystreams#Public"], - "cc": [ + "to": [ "https://enterprise.lemmy.ml/c/tenforward", - "https://enterprise.lemmy.ml/u/picard" + "https://www.w3.org/ns/activitystreams#Public" ], - "audience": "https://enterprise.lemmy.ml/c/tenforward", + "cc": ["https://enterprise.lemmy.ml/u/picard"], "inReplyTo": "https://enterprise.lemmy.ml/post/55143", "content": "

first comment!

\n", "mediaType": "text/html", diff --git a/crates/apub/assets/lemmy/objects/page.json b/crates/apub/assets/lemmy/objects/page.json index 20af5dfd26..7c926c5d17 100644 --- a/crates/apub/assets/lemmy/objects/page.json +++ b/crates/apub/assets/lemmy/objects/page.json @@ -6,7 +6,6 @@ "https://enterprise.lemmy.ml/c/tenforward", "https://www.w3.org/ns/activitystreams#Public" ], - "audience": "https://enterprise.lemmy.ml/c/tenforward", "name": "Post title", "content": "

This is a post in the /c/tenforward community

\n", "mediaType": "text/html", diff --git a/crates/apub/src/activities/block/block_user.rs b/crates/apub/src/activities/block/block_user.rs index 14b9f9adce..258de713f5 100644 --- a/crates/apub/src/activities/block/block_user.rs +++ b/crates/apub/src/activities/block/block_user.rs @@ -1,4 +1,4 @@ -use super::to_and_audience; +use super::to; use crate::{ activities::{ block::{generate_cc, SiteOrCommunity}, @@ -54,7 +54,7 @@ impl BlockUser { expires: Option>, context: &Data, ) -> LemmyResult { - let (to, audience) = to_and_audience(target)?; + let to = to(target)?; Ok(BlockUser { actor: mod_.id().into(), to, @@ -68,7 +68,6 @@ impl BlockUser { BlockType::Block, &context.settings().get_protocol_and_hostname(), )?, - audience, end_time: expires, }) } diff --git a/crates/apub/src/activities/block/mod.rs b/crates/apub/src/activities/block/mod.rs index 550d981837..6638fa0523 100644 --- a/crates/apub/src/activities/block/mod.rs +++ b/crates/apub/src/activities/block/mod.rs @@ -208,12 +208,10 @@ pub(crate) async fn send_ban_from_community( } } -fn to_and_audience( - target: &SiteOrCommunity, -) -> LemmyResult<(Vec, Option>)> { +fn to(target: &SiteOrCommunity) -> LemmyResult> { Ok(if let SiteOrCommunity::Community(c) = target { - (vec![generate_to(c)?], Some(c.id().into())) + generate_to(c)? } else { - (vec![public()], None) + vec![public()] }) } diff --git a/crates/apub/src/activities/block/undo_block_user.rs b/crates/apub/src/activities/block/undo_block_user.rs index 55715fd303..d4d9a7a6e2 100644 --- a/crates/apub/src/activities/block/undo_block_user.rs +++ b/crates/apub/src/activities/block/undo_block_user.rs @@ -1,4 +1,4 @@ -use super::to_and_audience; +use super::to; use crate::{ activities::{ block::{generate_cc, SiteOrCommunity}, @@ -46,7 +46,7 @@ impl UndoBlockUser { context: &Data, ) -> LemmyResult<()> { let block = BlockUser::new(target, user, mod_, None, reason, None, context).await?; - let (to, audience) = to_and_audience(target)?; + let to = to(target)?; let id = generate_activity_id( UndoType::Undo, @@ -59,7 +59,6 @@ impl UndoBlockUser { cc: generate_cc(target, &mut context.pool()).await?, kind: UndoType::Undo, id: id.clone(), - audience, restore_data: Some(restore_data), }; diff --git a/crates/apub/src/activities/community/announce.rs b/crates/apub/src/activities/community/announce.rs index 9d714e304e..e63ea3b4e5 100644 --- a/crates/apub/src/activities/community/announce.rs +++ b/crates/apub/src/activities/community/announce.rs @@ -94,7 +94,7 @@ impl AnnounceActivity { generate_announce_activity_id(inner_kind, &context.settings().get_protocol_and_hostname())?; Ok(AnnounceActivity { actor: community.id().into(), - to: vec![generate_to(community)?], + to: generate_to(community)?, object: IdOrNestedObject::NestedObject(object), cc: community .followers_url diff --git a/crates/apub/src/activities/community/collection_add.rs b/crates/apub/src/activities/community/collection_add.rs index 1014229c86..c84909ac1f 100644 --- a/crates/apub/src/activities/community/collection_add.rs +++ b/crates/apub/src/activities/community/collection_add.rs @@ -54,13 +54,12 @@ impl CollectionAdd { )?; let add = CollectionAdd { actor: actor.id().into(), - to: vec![generate_to(community)?], + to: generate_to(community)?, object: added_mod.id(), target: generate_moderators_url(&community.actor_id)?.into(), cc: vec![community.id()], kind: AddType::Add, id: id.clone(), - audience: Some(community.id().into()), }; let activity = AnnouncableActivities::CollectionAdd(add); @@ -80,13 +79,12 @@ impl CollectionAdd { )?; let add = CollectionAdd { actor: actor.id().into(), - to: vec![generate_to(community)?], + to: generate_to(community)?, object: featured_post.ap_id.clone().into(), target: generate_featured_url(&community.actor_id)?.into(), cc: vec![community.id()], kind: AddType::Add, id: id.clone(), - audience: Some(community.id().into()), }; let activity = AnnouncableActivities::CollectionAdd(add); send_activity_in_community( diff --git a/crates/apub/src/activities/community/collection_remove.rs b/crates/apub/src/activities/community/collection_remove.rs index c942867039..3ffcca8537 100644 --- a/crates/apub/src/activities/community/collection_remove.rs +++ b/crates/apub/src/activities/community/collection_remove.rs @@ -49,13 +49,12 @@ impl CollectionRemove { )?; let remove = CollectionRemove { actor: actor.id().into(), - to: vec![generate_to(community)?], + to: generate_to(community)?, object: removed_mod.id(), target: generate_moderators_url(&community.actor_id)?.into(), id: id.clone(), cc: vec![community.id()], kind: RemoveType::Remove, - audience: Some(community.id().into()), }; let activity = AnnouncableActivities::CollectionRemove(remove); @@ -75,13 +74,12 @@ impl CollectionRemove { )?; let remove = CollectionRemove { actor: actor.id().into(), - to: vec![generate_to(community)?], + to: generate_to(community)?, object: featured_post.ap_id.clone().into(), target: generate_featured_url(&community.actor_id)?.into(), cc: vec![community.id()], kind: RemoveType::Remove, id: id.clone(), - audience: Some(community.id().into()), }; let activity = AnnouncableActivities::CollectionRemove(remove); send_activity_in_community( diff --git a/crates/apub/src/activities/community/lock_page.rs b/crates/apub/src/activities/community/lock_page.rs index af6a5796f0..412711c6bd 100644 --- a/crates/apub/src/activities/community/lock_page.rs +++ b/crates/apub/src/activities/community/lock_page.rs @@ -138,12 +138,11 @@ pub(crate) async fn send_lock_post( let community_id = community.actor_id.inner().clone(); let lock = LockPage { actor: actor.actor_id.clone().into(), - to: vec![generate_to(&community)?], + to: generate_to(&community)?, object: ObjectId::from(post.ap_id), cc: vec![community_id.clone()], kind: LockType::Lock, id, - audience: Some(community_id.into()), }; let activity = if locked { AnnouncableActivities::LockPost(lock) @@ -154,11 +153,10 @@ pub(crate) async fn send_lock_post( )?; let undo = UndoLockPage { actor: lock.actor.clone(), - to: vec![generate_to(&community)?], + to: generate_to(&community)?, cc: lock.cc.clone(), kind: UndoType::Undo, id, - audience: lock.audience.clone(), object: lock, }; AnnouncableActivities::UndoLockPost(undo) diff --git a/crates/apub/src/activities/community/report.rs b/crates/apub/src/activities/community/report.rs index c33064459f..804822d6ea 100644 --- a/crates/apub/src/activities/community/report.rs +++ b/crates/apub/src/activities/community/report.rs @@ -56,7 +56,6 @@ impl Report { content: None, kind, id: id.clone(), - audience: Some(community.id().into()), }; // send report to the community where object was posted diff --git a/crates/apub/src/activities/community/update.rs b/crates/apub/src/activities/community/update.rs index b6bc50ca0b..280038d5fb 100644 --- a/crates/apub/src/activities/community/update.rs +++ b/crates/apub/src/activities/community/update.rs @@ -43,12 +43,11 @@ pub(crate) async fn send_update_community( )?; let update = UpdateCommunity { actor: actor.id().into(), - to: vec![generate_to(&community)?], + to: generate_to(&community)?, object: Box::new(community.clone().into_json(&context).await?), cc: vec![community.id()], kind: UpdateType::Update, id: id.clone(), - audience: Some(community.id().into()), }; let activity = AnnouncableActivities::UpdateCommunity(update); diff --git a/crates/apub/src/activities/create_or_update/comment.rs b/crates/apub/src/activities/create_or_update/comment.rs index 72dae48b71..f8d2a6d714 100644 --- a/crates/apub/src/activities/create_or_update/comment.rs +++ b/crates/apub/src/activities/create_or_update/comment.rs @@ -71,13 +71,12 @@ impl CreateOrUpdateNote { let create_or_update = CreateOrUpdateNote { actor: person.id().into(), - to: vec![generate_to(&community)?], + to: generate_to(&community)?, cc: note.cc.clone(), tag: note.tag.clone(), object: note, kind, id: id.clone(), - audience: Some(community.id().into()), }; let tagged_users: Vec> = create_or_update diff --git a/crates/apub/src/activities/create_or_update/post.rs b/crates/apub/src/activities/create_or_update/post.rs index 832b2da6d4..80a95f4bec 100644 --- a/crates/apub/src/activities/create_or_update/post.rs +++ b/crates/apub/src/activities/create_or_update/post.rs @@ -49,12 +49,11 @@ impl CreateOrUpdatePage { )?; Ok(CreateOrUpdatePage { actor: actor.id().into(), - to: vec![generate_to(community)?], + to: generate_to(community)?, object: post.into_json(context).await?, cc: vec![community.id()], kind, id: id.clone(), - audience: Some(community.id().into()), }) } diff --git a/crates/apub/src/activities/deletion/delete.rs b/crates/apub/src/activities/deletion/delete.rs index 4ad24d9662..48e24bbebd 100644 --- a/crates/apub/src/activities/deletion/delete.rs +++ b/crates/apub/src/activities/deletion/delete.rs @@ -102,7 +102,6 @@ impl Delete { kind: DeleteType::Delete, summary, id, - audience: community.map(|c| c.actor_id.clone().into()), remove_data: None, }) } diff --git a/crates/apub/src/activities/deletion/mod.rs b/crates/apub/src/activities/deletion/mod.rs index 941ac4237d..3b50cfd1aa 100644 --- a/crates/apub/src/activities/deletion/mod.rs +++ b/crates/apub/src/activities/deletion/mod.rs @@ -60,7 +60,7 @@ pub(crate) async fn send_apub_delete_in_community( ) -> LemmyResult<()> { let actor = ApubPerson::from(actor); let is_mod_action = reason.is_some(); - let to = vec![generate_to(&community)?]; + let to = generate_to(&community)?; let activity = if deleted { let delete = Delete::new(&actor, object, to, Some(&community), reason, context)?; AnnouncableActivities::Delete(delete) diff --git a/crates/apub/src/activities/deletion/undo_delete.rs b/crates/apub/src/activities/deletion/undo_delete.rs index b30b22fd42..0329369099 100644 --- a/crates/apub/src/activities/deletion/undo_delete.rs +++ b/crates/apub/src/activities/deletion/undo_delete.rs @@ -87,7 +87,6 @@ impl UndoDelete { cc: cc.into_iter().collect(), kind: UndoType::Undo, id, - audience: community.map(|c| c.actor_id.clone().into()), }) } diff --git a/crates/apub/src/activities/mod.rs b/crates/apub/src/activities/mod.rs index ffb6a662e7..feef9cbd03 100644 --- a/crates/apub/src/activities/mod.rs +++ b/crates/apub/src/activities/mod.rs @@ -136,23 +136,15 @@ pub(crate) fn verify_visibility(to: &[Url], cc: &[Url], community: &Community) - } /// Marks object as public only if the community is public -pub(crate) fn generate_to(community: &Community) -> LemmyResult { +pub(crate) fn generate_to(community: &Community) -> LemmyResult> { + let actor_id = community.actor_id.clone().into(); if community.visibility == CommunityVisibility::Public { - Ok(public()) + Ok(vec![actor_id, public()]) } else { - Ok(Url::parse(&format!("{}/followers", community.actor_id))?) - } -} - -pub(crate) fn verify_community_matches(a: &ObjectId, b: T) -> LemmyResult<()> -where - T: Into>, -{ - let b: ObjectId = b.into(); - if a != &b { - Err(FederationError::InvalidCommunity)? - } else { - Ok(()) + Ok(vec![ + actor_id.clone(), + Url::parse(&format!("{}/followers", actor_id))?, + ]) } } diff --git a/crates/apub/src/activities/voting/mod.rs b/crates/apub/src/activities/voting/mod.rs index 5cda291ebe..4ce0f695bc 100644 --- a/crates/apub/src/activities/voting/mod.rs +++ b/crates/apub/src/activities/voting/mod.rs @@ -40,13 +40,13 @@ pub(crate) async fn send_like_activity( let empty = ActivitySendTargets::empty(); // score of 1 means upvote, -1 downvote, 0 undo a previous vote if score != 0 { - let vote = Vote::new(object_id, &actor, &community, score.try_into()?, &context)?; + let vote = Vote::new(object_id, &actor, score.try_into()?, &context)?; let activity = AnnouncableActivities::Vote(vote); send_activity_in_community(activity, &actor, &community, empty, false, &context).await } else { // Lemmy API doesn't distinguish between Undo/Like and Undo/Dislike, so we hardcode it here. - let vote = Vote::new(object_id, &actor, &community, VoteType::Like, &context)?; - let undo_vote = UndoVote::new(vote, &actor, &community, &context)?; + let vote = Vote::new(object_id, &actor, VoteType::Like, &context)?; + let undo_vote = UndoVote::new(vote, &actor, &context)?; let activity = AnnouncableActivities::UndoVote(undo_vote); send_activity_in_community(activity, &actor, &community, empty, false, &context).await } diff --git a/crates/apub/src/activities/voting/undo_vote.rs b/crates/apub/src/activities/voting/undo_vote.rs index 61875d442f..f6a6039b08 100644 --- a/crates/apub/src/activities/voting/undo_vote.rs +++ b/crates/apub/src/activities/voting/undo_vote.rs @@ -5,7 +5,7 @@ use crate::{ voting::{undo_vote_comment, undo_vote_post}, }, insert_received_activity, - objects::{community::ApubCommunity, person::ApubPerson}, + objects::person::ApubPerson, protocol::{ activities::voting::{undo_vote::UndoVote, vote::Vote}, InCommunity, @@ -26,7 +26,6 @@ impl UndoVote { pub(in crate::activities::voting) fn new( vote: Vote, actor: &ApubPerson, - community: &ApubCommunity, context: &Data, ) -> LemmyResult { Ok(UndoVote { @@ -37,7 +36,6 @@ impl UndoVote { UndoType::Undo, &context.settings().get_protocol_and_hostname(), )?, - audience: Some(community.id().into()), }) } } diff --git a/crates/apub/src/activities/voting/vote.rs b/crates/apub/src/activities/voting/vote.rs index 1cdc819529..bb0b32bd94 100644 --- a/crates/apub/src/activities/voting/vote.rs +++ b/crates/apub/src/activities/voting/vote.rs @@ -5,7 +5,7 @@ use crate::{ voting::{undo_vote_comment, undo_vote_post, vote_comment, vote_post}, }, insert_received_activity, - objects::{community::ApubCommunity, person::ApubPerson}, + objects::person::ApubPerson, protocol::{ activities::voting::vote::{Vote, VoteType}, InCommunity, @@ -26,7 +26,6 @@ impl Vote { pub(in crate::activities::voting) fn new( object_id: ObjectId, actor: &ApubPerson, - community: &ApubCommunity, kind: VoteType, context: &Data, ) -> LemmyResult { @@ -35,7 +34,6 @@ impl Vote { object: object_id, kind: kind.clone(), id: generate_activity_id(kind, &context.settings().get_protocol_and_hostname())?, - audience: Some(community.id().into()), }) } } diff --git a/crates/apub/src/mentions.rs b/crates/apub/src/mentions.rs index cb46be52a0..0f04818a39 100644 --- a/crates/apub/src/mentions.rs +++ b/crates/apub/src/mentions.rs @@ -1,7 +1,7 @@ -use crate::objects::{comment::ApubComment, community::ApubCommunity, person::ApubPerson}; +use crate::objects::{comment::ApubComment, person::ApubPerson}; use activitypub_federation::{ config::Data, - fetch::{object_id::ObjectId, webfinger::webfinger_resolve_actor}, + fetch::webfinger::webfinger_resolve_actor, kinds::link::MentionType, traits::Actor, }; @@ -42,14 +42,13 @@ pub struct MentionsAndAddresses { /// This takes a comment, and builds a list of to_addresses, inboxes, /// and mention tags, so they know where to be sent to. /// Addresses are the persons / addresses that go in the cc field. -#[tracing::instrument(skip(comment, community_id, context))] +#[tracing::instrument(skip(comment, context))] pub async fn collect_non_local_mentions( comment: &ApubComment, - community_id: ObjectId, context: &Data, ) -> LemmyResult { let parent_creator = get_comment_parent_creator(&mut context.pool(), comment).await?; - let mut addressed_ccs: Vec = vec![community_id.into(), parent_creator.id()]; + let mut addressed_ccs: Vec = vec![parent_creator.id()]; // Add the mention tag let parent_creator_tag = Mention { diff --git a/crates/apub/src/objects/comment.rs b/crates/apub/src/objects/comment.rs index ed9a9e1a2a..fd168e370f 100644 --- a/crates/apub/src/objects/comment.rs +++ b/crates/apub/src/objects/comment.rs @@ -105,13 +105,13 @@ impl Object for ApubComment { post.ap_id.into() }; let language = Some(LanguageTag::new_single(self.language_id, &mut context.pool()).await?); - let maa = collect_non_local_mentions(&self, community.actor_id.clone().into(), context).await?; + let maa = collect_non_local_mentions(&self, context).await?; let note = Note { r#type: NoteType::Note, id: self.ap_id.clone().into(), attributed_to: creator.actor_id.into(), - to: vec![generate_to(&community)?], + to: generate_to(&community)?, cc: maa.ccs, content: markdown_to_html(&self.content), media_type: Some(MediaTypeMarkdownOrHtml::Html), @@ -122,7 +122,6 @@ impl Object for ApubComment { tag: maa.tags, distinguished: Some(self.distinguished), language, - audience: Some(community.actor_id.into()), attachment: vec![], }; diff --git a/crates/apub/src/objects/post.rs b/crates/apub/src/objects/post.rs index 0dd9201c21..73e940a3c6 100644 --- a/crates/apub/src/objects/post.rs +++ b/crates/apub/src/objects/post.rs @@ -133,7 +133,7 @@ impl Object for ApubPost { kind: PageType::Page, id: self.ap_id.clone().into(), attributed_to: AttributedTo::Lemmy(creator.actor_id.into()), - to: vec![generate_to(&community)?], + to: generate_to(&community)?, cc: vec![], name: Some(self.name.clone()), content: self.body.as_ref().map(|b| markdown_to_html(b)), @@ -145,7 +145,6 @@ impl Object for ApubPost { language, published: Some(self.published), updated: self.updated, - audience: Some(community.actor_id.into()), in_reply_to: None, tag: vec![hashtag], }; diff --git a/crates/apub/src/protocol/activities/block/block_user.rs b/crates/apub/src/protocol/activities/block/block_user.rs index 96135d6454..97f54a2a30 100644 --- a/crates/apub/src/protocol/activities/block/block_user.rs +++ b/crates/apub/src/protocol/activities/block/block_user.rs @@ -1,5 +1,5 @@ use crate::{ - activities::{block::SiteOrCommunity, verify_community_matches}, + activities::block::SiteOrCommunity, objects::{community::ApubCommunity, person::ApubPerson}, protocol::InCommunity, }; @@ -31,7 +31,6 @@ pub struct BlockUser { #[serde(rename = "type")] pub(crate) kind: BlockType, pub(crate) id: Url, - pub(crate) audience: Option>, /// Quick and dirty solution. /// TODO: send a separate Delete activity instead @@ -49,9 +48,6 @@ impl InCommunity for BlockUser { SiteOrCommunity::Community(c) => c, SiteOrCommunity::Site(_) => return Err(anyhow!("activity is not in community").into()), }; - if let Some(audience) = &self.audience { - verify_community_matches(audience, community.actor_id.clone())?; - } Ok(community) } } diff --git a/crates/apub/src/protocol/activities/block/undo_block_user.rs b/crates/apub/src/protocol/activities/block/undo_block_user.rs index e038fa2dcb..1dad9b03ce 100644 --- a/crates/apub/src/protocol/activities/block/undo_block_user.rs +++ b/crates/apub/src/protocol/activities/block/undo_block_user.rs @@ -1,5 +1,4 @@ use crate::{ - activities::verify_community_matches, objects::{community::ApubCommunity, person::ApubPerson}, protocol::{activities::block::block_user::BlockUser, InCommunity}, }; @@ -28,7 +27,6 @@ pub struct UndoBlockUser { #[serde(rename = "type")] pub(crate) kind: UndoType, pub(crate) id: Url, - pub(crate) audience: Option>, /// Quick and dirty solution. /// TODO: send a separate Delete activity instead @@ -39,9 +37,6 @@ pub struct UndoBlockUser { impl InCommunity for UndoBlockUser { async fn community(&self, context: &Data) -> LemmyResult { let community = self.object.community(context).await?; - if let Some(audience) = &self.audience { - verify_community_matches(audience, community.actor_id.clone())?; - } Ok(community) } } diff --git a/crates/apub/src/protocol/activities/community/collection_add.rs b/crates/apub/src/protocol/activities/community/collection_add.rs index 777ad8b621..d7c5e5143a 100644 --- a/crates/apub/src/protocol/activities/community/collection_add.rs +++ b/crates/apub/src/protocol/activities/community/collection_add.rs @@ -1,5 +1,4 @@ use crate::{ - activities::verify_community_matches, objects::{community::ApubCommunity, person::ApubPerson}, protocol::InCommunity, }; @@ -28,7 +27,6 @@ pub struct CollectionAdd { #[serde(rename = "type")] pub(crate) kind: AddType, pub(crate) id: Url, - pub(crate) audience: Option>, } #[async_trait::async_trait] @@ -36,9 +34,6 @@ impl InCommunity for CollectionAdd { async fn community(&self, context: &Data) -> LemmyResult { let (community, _) = Community::get_by_collection_url(&mut context.pool(), &self.clone().target.into()).await?; - if let Some(audience) = &self.audience { - verify_community_matches(audience, community.actor_id.clone())?; - } Ok(community.into()) } } diff --git a/crates/apub/src/protocol/activities/community/collection_remove.rs b/crates/apub/src/protocol/activities/community/collection_remove.rs index afc0c24a01..85b314b4b9 100644 --- a/crates/apub/src/protocol/activities/community/collection_remove.rs +++ b/crates/apub/src/protocol/activities/community/collection_remove.rs @@ -1,5 +1,4 @@ use crate::{ - activities::verify_community_matches, objects::{community::ApubCommunity, person::ApubPerson}, protocol::InCommunity, }; @@ -28,7 +27,6 @@ pub struct CollectionRemove { pub(crate) kind: RemoveType, pub(crate) target: Url, pub(crate) id: Url, - pub(crate) audience: Option>, } #[async_trait::async_trait] @@ -36,9 +34,6 @@ impl InCommunity for CollectionRemove { async fn community(&self, context: &Data) -> LemmyResult { let (community, _) = Community::get_by_collection_url(&mut context.pool(), &self.clone().target.into()).await?; - if let Some(audience) = &self.audience { - verify_community_matches(audience, community.actor_id.clone())?; - } Ok(community.into()) } } diff --git a/crates/apub/src/protocol/activities/community/lock_page.rs b/crates/apub/src/protocol/activities/community/lock_page.rs index 5c8ecfca90..a97466edca 100644 --- a/crates/apub/src/protocol/activities/community/lock_page.rs +++ b/crates/apub/src/protocol/activities/community/lock_page.rs @@ -1,5 +1,4 @@ use crate::{ - activities::verify_community_matches, objects::{community::ApubCommunity, person::ApubPerson, post::ApubPost}, protocol::InCommunity, }; @@ -33,7 +32,6 @@ pub struct LockPage { #[serde(rename = "type")] pub(crate) kind: LockType, pub(crate) id: Url, - pub(crate) audience: Option>, } #[derive(Clone, Debug, Deserialize, Serialize)] @@ -48,7 +46,6 @@ pub struct UndoLockPage { #[serde(rename = "type")] pub(crate) kind: UndoType, pub(crate) id: Url, - pub(crate) audience: Option>, } #[async_trait::async_trait] @@ -56,9 +53,6 @@ impl InCommunity for LockPage { async fn community(&self, context: &Data) -> LemmyResult { let post = self.object.dereference(context).await?; let community = Community::read(&mut context.pool(), post.community_id).await?; - if let Some(audience) = &self.audience { - verify_community_matches(audience, community.actor_id.clone())?; - } Ok(community.into()) } } @@ -67,9 +61,6 @@ impl InCommunity for LockPage { impl InCommunity for UndoLockPage { async fn community(&self, context: &Data) -> LemmyResult { let community = self.object.community(context).await?; - if let Some(audience) = &self.audience { - verify_community_matches(audience, community.actor_id.clone())?; - } Ok(community) } } diff --git a/crates/apub/src/protocol/activities/community/report.rs b/crates/apub/src/protocol/activities/community/report.rs index dd0f72f43d..71ecf4c5ce 100644 --- a/crates/apub/src/protocol/activities/community/report.rs +++ b/crates/apub/src/protocol/activities/community/report.rs @@ -1,5 +1,4 @@ use crate::{ - activities::verify_community_matches, fetcher::post_or_comment::PostOrComment, objects::{community::ApubCommunity, person::ApubPerson}, protocol::InCommunity, @@ -29,7 +28,6 @@ pub struct Report { #[serde(rename = "type")] pub(crate) kind: FlagType, pub(crate) id: Url, - pub(crate) audience: Option>, } impl Report { @@ -73,9 +71,6 @@ impl ReportObject { impl InCommunity for Report { async fn community(&self, context: &Data) -> LemmyResult { let community = self.to[0].dereference(context).await?; - if let Some(audience) = &self.audience { - verify_community_matches(audience, community.actor_id.clone())?; - } Ok(community) } } diff --git a/crates/apub/src/protocol/activities/community/update.rs b/crates/apub/src/protocol/activities/community/update.rs index 268f050737..080dd27e60 100644 --- a/crates/apub/src/protocol/activities/community/update.rs +++ b/crates/apub/src/protocol/activities/community/update.rs @@ -1,5 +1,4 @@ use crate::{ - activities::verify_community_matches, objects::{community::ApubCommunity, person::ApubPerson}, protocol::{objects::group::Group, InCommunity}, }; @@ -29,16 +28,12 @@ pub struct UpdateCommunity { #[serde(rename = "type")] pub(crate) kind: UpdateType, pub(crate) id: Url, - pub(crate) audience: Option>, } #[async_trait::async_trait] impl InCommunity for UpdateCommunity { async fn community(&self, context: &Data) -> LemmyResult { let community: ApubCommunity = self.object.id.clone().dereference(context).await?; - if let Some(audience) = &self.audience { - verify_community_matches(audience, community.actor_id.clone())?; - } Ok(community) } } diff --git a/crates/apub/src/protocol/activities/create_or_update/note.rs b/crates/apub/src/protocol/activities/create_or_update/note.rs index ff07281744..37f5953375 100644 --- a/crates/apub/src/protocol/activities/create_or_update/note.rs +++ b/crates/apub/src/protocol/activities/create_or_update/note.rs @@ -1,5 +1,4 @@ use crate::{ - activities::verify_community_matches, mentions::MentionOrValue, objects::{community::ApubCommunity, person::ApubPerson}, protocol::{activities::CreateOrUpdateType, objects::note::Note, InCommunity}, @@ -29,7 +28,6 @@ pub struct CreateOrUpdateNote { #[serde(rename = "type")] pub(crate) kind: CreateOrUpdateType, pub(crate) id: Url, - pub(crate) audience: Option>, } #[async_trait::async_trait] @@ -37,9 +35,6 @@ impl InCommunity for CreateOrUpdateNote { async fn community(&self, context: &Data) -> LemmyResult { let post = self.object.get_parents(context).await?.0; let community = Community::read(&mut context.pool(), post.community_id).await?; - if let Some(audience) = &self.audience { - verify_community_matches(audience, community.actor_id.clone())?; - } Ok(community.into()) } } diff --git a/crates/apub/src/protocol/activities/create_or_update/page.rs b/crates/apub/src/protocol/activities/create_or_update/page.rs index 21052a9ef9..3fd397022e 100644 --- a/crates/apub/src/protocol/activities/create_or_update/page.rs +++ b/crates/apub/src/protocol/activities/create_or_update/page.rs @@ -1,5 +1,4 @@ use crate::{ - activities::verify_community_matches, objects::{community::ApubCommunity, person::ApubPerson}, protocol::{activities::CreateOrUpdateType, objects::page::Page, InCommunity}, }; @@ -25,16 +24,12 @@ pub struct CreateOrUpdatePage { #[serde(rename = "type")] pub(crate) kind: CreateOrUpdateType, pub(crate) id: Url, - pub(crate) audience: Option>, } #[async_trait::async_trait] impl InCommunity for CreateOrUpdatePage { async fn community(&self, context: &Data) -> LemmyResult { let community = self.object.community(context).await?; - if let Some(audience) = &self.audience { - verify_community_matches(audience, community.actor_id.clone())?; - } Ok(community) } } diff --git a/crates/apub/src/protocol/activities/deletion/delete.rs b/crates/apub/src/protocol/activities/deletion/delete.rs index 3a29da069a..878f6fb6c2 100644 --- a/crates/apub/src/protocol/activities/deletion/delete.rs +++ b/crates/apub/src/protocol/activities/deletion/delete.rs @@ -1,5 +1,5 @@ use crate::{ - activities::{deletion::DeletableObjects, verify_community_matches}, + activities::deletion::DeletableObjects, objects::{community::ApubCommunity, person::ApubPerson}, protocol::{objects::tombstone::Tombstone, IdOrNestedObject, InCommunity}, }; @@ -31,7 +31,6 @@ pub struct Delete { #[serde(rename = "type")] pub(crate) kind: DeleteType, pub(crate) id: Url, - pub(crate) audience: Option>, #[serde(deserialize_with = "deserialize_one_or_many")] #[serde(default)] @@ -61,9 +60,6 @@ impl InCommunity for Delete { } }; let community = Community::read(&mut context.pool(), community_id).await?; - if let Some(audience) = &self.audience { - verify_community_matches(audience, community.actor_id.clone())?; - } Ok(community.into()) } } diff --git a/crates/apub/src/protocol/activities/deletion/undo_delete.rs b/crates/apub/src/protocol/activities/deletion/undo_delete.rs index 508b901134..a6bf0589bd 100644 --- a/crates/apub/src/protocol/activities/deletion/undo_delete.rs +++ b/crates/apub/src/protocol/activities/deletion/undo_delete.rs @@ -1,5 +1,4 @@ use crate::{ - activities::verify_community_matches, objects::{community::ApubCommunity, person::ApubPerson}, protocol::{activities::deletion::delete::Delete, InCommunity}, }; @@ -26,7 +25,6 @@ pub struct UndoDelete { #[serde(rename = "type")] pub(crate) kind: UndoType, pub(crate) id: Url, - pub(crate) audience: Option>, #[serde(deserialize_with = "deserialize_one_or_many", default)] #[serde(skip_serializing_if = "Vec::is_empty")] @@ -37,9 +35,6 @@ pub struct UndoDelete { impl InCommunity for UndoDelete { async fn community(&self, context: &Data) -> LemmyResult { let community = self.object.community(context).await?; - if let Some(audience) = &self.audience { - verify_community_matches(audience, community.actor_id.clone())?; - } Ok(community) } } diff --git a/crates/apub/src/protocol/activities/voting/undo_vote.rs b/crates/apub/src/protocol/activities/voting/undo_vote.rs index e9ccbd593e..a9f0d05410 100644 --- a/crates/apub/src/protocol/activities/voting/undo_vote.rs +++ b/crates/apub/src/protocol/activities/voting/undo_vote.rs @@ -1,5 +1,4 @@ use crate::{ - activities::verify_community_matches, objects::{community::ApubCommunity, person::ApubPerson}, protocol::{activities::voting::vote::Vote, InCommunity}, }; @@ -17,16 +16,12 @@ pub struct UndoVote { #[serde(rename = "type")] pub(crate) kind: UndoType, pub(crate) id: Url, - pub(crate) audience: Option>, } #[async_trait::async_trait] impl InCommunity for UndoVote { async fn community(&self, context: &Data) -> LemmyResult { let community = self.object.community(context).await?; - if let Some(audience) = &self.audience { - verify_community_matches(audience, community.actor_id.clone())?; - } Ok(community) } } diff --git a/crates/apub/src/protocol/activities/voting/vote.rs b/crates/apub/src/protocol/activities/voting/vote.rs index 883fc85fb0..b6ffe485a0 100644 --- a/crates/apub/src/protocol/activities/voting/vote.rs +++ b/crates/apub/src/protocol/activities/voting/vote.rs @@ -1,5 +1,4 @@ use crate::{ - activities::verify_community_matches, fetcher::post_or_comment::PostOrComment, objects::{community::ApubCommunity, person::ApubPerson}, protocol::InCommunity, @@ -19,7 +18,6 @@ pub struct Vote { #[serde(rename = "type")] pub(crate) kind: VoteType, pub(crate) id: Url, - pub(crate) audience: Option>, } #[derive(Clone, Debug, Display, Deserialize, Serialize, PartialEq, Eq)] @@ -58,9 +56,6 @@ impl InCommunity for Vote { .await? .community(context) .await?; - if let Some(audience) = &self.audience { - verify_community_matches(audience, community.actor_id.clone())?; - } Ok(community) } } diff --git a/crates/apub/src/protocol/mod.rs b/crates/apub/src/protocol/mod.rs index a4774ac1d6..90f1f51ea9 100644 --- a/crates/apub/src/protocol/mod.rs +++ b/crates/apub/src/protocol/mod.rs @@ -82,8 +82,6 @@ impl IdOrNestedObject { #[async_trait::async_trait] pub trait InCommunity { - // TODO: after we use audience field and remove backwards compat, it should be possible to change - // this to simply `fn community(&self) -> LemmyResult>` async fn community(&self, context: &Data) -> LemmyResult; } diff --git a/crates/apub/src/protocol/objects/note.rs b/crates/apub/src/protocol/objects/note.rs index fc38b9b5ed..d4c87333ff 100644 --- a/crates/apub/src/protocol/objects/note.rs +++ b/crates/apub/src/protocol/objects/note.rs @@ -1,5 +1,4 @@ use crate::{ - activities::verify_community_matches, fetcher::post_or_comment::PostOrComment, mentions::MentionOrValue, objects::{comment::ApubComment, community::ApubCommunity, person::ApubPerson, post::ApubPost}, @@ -56,7 +55,6 @@ pub struct Note { // lemmy extension pub(crate) distinguished: Option, pub(crate) language: Option, - pub(crate) audience: Option>, #[serde(default)] pub(crate) attachment: Vec, } @@ -94,9 +92,6 @@ impl InCommunity for Note { async fn community(&self, context: &Data) -> LemmyResult { let (post, _) = self.get_parents(context).await?; let community = Community::read(&mut context.pool(), post.community_id).await?; - if let Some(audience) = &self.audience { - verify_community_matches(audience, community.actor_id.clone())?; - } Ok(community.into()) } } diff --git a/crates/apub/src/protocol/objects/page.rs b/crates/apub/src/protocol/objects/page.rs index 3ce720bc0b..ae5925e573 100644 --- a/crates/apub/src/protocol/objects/page.rs +++ b/crates/apub/src/protocol/objects/page.rs @@ -1,5 +1,4 @@ use crate::{ - activities::verify_community_matches, fetcher::user_or_community::{PersonOrGroupType, UserOrCommunity}, objects::{community::ApubCommunity, person::ApubPerson, post::ApubPost}, protocol::{objects::LanguageTag, ImageObject, InCommunity, Source}, @@ -64,7 +63,6 @@ pub struct Page { pub(crate) published: Option>, pub(crate) updated: Option>, pub(crate) language: Option, - pub(crate) audience: Option>, #[serde(deserialize_with = "deserialize_skip_error", default)] pub(crate) tag: Vec, } @@ -231,10 +229,6 @@ impl ActivityHandler for Page { #[async_trait::async_trait] impl InCommunity for Page { async fn community(&self, context: &Data) -> LemmyResult { - if let Some(audience) = &self.audience { - return audience.dereference(context).await; - } - let community = match &self.attributed_to { AttributedTo::Lemmy(_) => { let mut iter = self.to.iter().merge(self.cc.iter()); @@ -259,9 +253,6 @@ impl InCommunity for Page { } }; - if let Some(audience) = &self.audience { - verify_community_matches(audience, community.actor_id.clone())?; - } Ok(community) } } diff --git a/crates/federate/src/worker.rs b/crates/federate/src/worker.rs index 1d666cfa31..260103c4af 100644 --- a/crates/federate/src/worker.rs +++ b/crates/federate/src/worker.rs @@ -710,7 +710,6 @@ mod test { let data = json!({ "actor": "http://ds9.lemmy.ml/u/lemmy_alpha", "object": "http://ds9.lemmy.ml/comment/1", - "audience": "https://enterprise.lemmy.ml/c/tenforward", "type": "Like", "id": format!("http://ds9.lemmy.ml/activities/like/{}", uuid::Uuid::new_v4()), });