Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unused apub audience field (fixes #5278) #5315

Merged
merged 4 commits into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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"
}
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand All @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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": "<p>test body</p>\n",
"mediaType": "text/html",
Expand All @@ -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"
}
Original file line number Diff line number Diff line change
Expand Up @@ -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": "<p>test body</p>\n",
"mediaType": "text/html",
Expand All @@ -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"
}
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Original file line number Diff line number Diff line change
@@ -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"
}
Original file line number Diff line number Diff line change
@@ -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"
}
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@
"language": {
"identifier": "de",
"name": "Deutsch"
},
"audience": "https://ds9.lemmy.ml/c/main"
}
},
{
"type": "Page",
Expand All @@ -40,8 +39,7 @@
"language": {
"identifier": "de",
"name": "Deutsch"
},
"audience": "https://ds9.lemmy.ml/c/main"
}
}
]
}
7 changes: 3 additions & 4 deletions crates/apub/assets/lemmy/objects/comment.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "<p>first comment!</p>\n",
"mediaType": "text/html",
Expand Down
1 change: 0 additions & 1 deletion crates/apub/assets/lemmy/objects/page.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "<p>This is a post in the /c/tenforward community</p>\n",
"mediaType": "text/html",
Expand Down
5 changes: 2 additions & 3 deletions crates/apub/src/activities/block/block_user.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use super::to_and_audience;
use super::to;
use crate::{
activities::{
block::{generate_cc, SiteOrCommunity},
Expand Down Expand Up @@ -54,7 +54,7 @@ impl BlockUser {
expires: Option<DateTime<Utc>>,
context: &Data<LemmyContext>,
) -> LemmyResult<BlockUser> {
let (to, audience) = to_and_audience(target)?;
let to = to(target)?;
Ok(BlockUser {
actor: mod_.id().into(),
to,
Expand All @@ -68,7 +68,6 @@ impl BlockUser {
BlockType::Block,
&context.settings().get_protocol_and_hostname(),
)?,
audience,
end_time: expires,
})
}
Expand Down
8 changes: 3 additions & 5 deletions crates/apub/src/activities/block/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,12 +208,10 @@ pub(crate) async fn send_ban_from_community(
}
}

fn to_and_audience(
target: &SiteOrCommunity,
) -> LemmyResult<(Vec<Url>, Option<ObjectId<ApubCommunity>>)> {
fn to(target: &SiteOrCommunity) -> LemmyResult<Vec<Url>> {
Ok(if let SiteOrCommunity::Community(c) = target {
(vec![generate_to(c)?], Some(c.id().into()))
generate_to(c)?
} else {
(vec![public()], None)
vec![public()]
})
}
5 changes: 2 additions & 3 deletions crates/apub/src/activities/block/undo_block_user.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use super::to_and_audience;
use super::to;
use crate::{
activities::{
block::{generate_cc, SiteOrCommunity},
Expand Down Expand Up @@ -46,7 +46,7 @@ impl UndoBlockUser {
context: &Data<LemmyContext>,
) -> 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,
Expand All @@ -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),
};

Expand Down
2 changes: 1 addition & 1 deletion crates/apub/src/activities/community/announce.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 2 additions & 4 deletions crates/apub/src/activities/community/collection_add.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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(
Expand Down
6 changes: 2 additions & 4 deletions crates/apub/src/activities/community/collection_remove.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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(
Expand Down
Loading