Skip to content

Commit 2e60451

Browse files
authored
Restore Activitypub audience field (#6157)
* Restore Activitypub audience field I previously removed this in #5315 because it wasnt used much. However it seems that since then [NodeBB and Piefed](https://activitypub.space/topic/63/lemmy-s-removal-of-audience-in-posts) have adopted it, and so it should be kept. Additionally it is part of [FEP-1b12](https://codeberg.org/fediverse/fep/src/branch/main/fep/1b12/fep-1b12.md). * test fixes * x
1 parent b624037 commit 2e60451

61 files changed

Lines changed: 131 additions & 16 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

crates/apub/activities/src/block/block_user.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ impl BlockUser {
6262
summary: Some(reason),
6363
id: generate_activity_id(BlockType::Block, context)?,
6464
end_time: expires,
65+
audience: target.as_ref().right().map(|c| c.ap_id.clone().into()),
6566
})
6667
}
6768

crates/apub/activities/src/block/undo_block_user.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ impl UndoBlockUser {
5656
kind: UndoType::Undo,
5757
id: id.clone(),
5858
restore_data: Some(restore_data),
59+
audience: target.as_ref().right().map(|c| c.ap_id.clone().into()),
5960
};
6061

6162
let mut inboxes = ActivitySendTargets::to_inbox(user.shared_inbox_or_inbox());

crates/apub/activities/src/community/collection_add.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ impl CollectionAdd {
5454
cc: vec![community.id().clone()],
5555
kind: AddType::Add,
5656
id: id.clone(),
57+
audience: Some(community.ap_id.clone().into()),
5758
};
5859

5960
let activity = AnnouncableActivities::CollectionAdd(add);
@@ -76,6 +77,7 @@ impl CollectionAdd {
7677
cc: vec![community.id().clone()],
7778
kind: AddType::Add,
7879
id: id.clone(),
80+
audience: Some(community.ap_id.clone().into()),
7981
};
8082
let activity = AnnouncableActivities::CollectionAdd(add);
8183
send_activity_in_community(

crates/apub/activities/src/community/collection_remove.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ impl CollectionRemove {
5151
id: id.clone(),
5252
cc: vec![community.id().clone()],
5353
kind: RemoveType::Remove,
54+
audience: Some(community.ap_id.clone().into()),
5455
};
5556

5657
let activity = AnnouncableActivities::CollectionRemove(remove);
@@ -73,6 +74,7 @@ impl CollectionRemove {
7374
cc: vec![community.id().clone()],
7475
kind: RemoveType::Remove,
7576
id: id.clone(),
77+
audience: Some(community.ap_id.clone().into()),
7678
};
7779
let activity = AnnouncableActivities::CollectionRemove(remove);
7880
send_activity_in_community(

crates/apub/activities/src/community/lock.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ pub(crate) async fn send_lock(
163163
kind: LockType::Lock,
164164
id,
165165
summary: Some(reason.clone()),
166+
audience: Some(community.ap_id.clone().into()),
166167
};
167168
let activity = if locked {
168169
AnnouncableActivities::Lock(lock)
@@ -176,6 +177,7 @@ pub(crate) async fn send_lock(
176177
id,
177178
object: lock,
178179
summary: Some(reason),
180+
audience: Some(community.ap_id.clone().into()),
179181
};
180182
AnnouncableActivities::UndoLock(undo)
181183
};

crates/apub/activities/src/community/report.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ impl Report {
6262
content: None,
6363
kind,
6464
id: id.clone(),
65+
audience: receiver.as_ref().right().map(|c| c.ap_id.clone().into()),
6566
})
6667
}
6768

crates/apub/activities/src/community/resolve_report.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ impl ResolveReport {
5555
object,
5656
kind,
5757
id: id.clone(),
58+
audience: receiver.as_ref().right().map(|c| c.ap_id.clone().into()),
5859
};
5960
let inboxes = report_inboxes(object_id, receiver, report_creator, &context).await?;
6061

crates/apub/activities/src/community/update.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ pub(crate) async fn send_update_community(
4343
cc: vec![community.id().clone()],
4444
kind: UpdateType::Update,
4545
id: id.clone(),
46+
audience: Some(community.ap_id.clone().into()),
4647
};
4748

4849
let activity = AnnouncableActivities::UpdateCommunity(Box::new(update));
@@ -72,6 +73,7 @@ pub(crate) async fn send_update_multi_community(
7273
cc: vec![],
7374
kind: UpdateType::Update,
7475
id: id.clone(),
76+
audience: Some(multi.ap_id.clone().into()),
7577
};
7678

7779
let activity = AnnouncableActivities::UpdateCommunity(Box::new(update));

crates/apub/activities/src/create_or_update/comment.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ impl CreateOrUpdateNote {
6868
object: note,
6969
kind,
7070
id: id.clone(),
71+
audience: Some(community.ap_id.clone().into()),
7172
};
7273

7374
let tagged_users: Vec<ObjectId<ApubPerson>> = create_or_update

crates/apub/activities/src/create_or_update/post.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ impl CreateOrUpdatePage {
5454
cc: vec![community.id().clone()],
5555
kind,
5656
id: id.clone(),
57+
audience: Some(community.ap_id.clone().into()),
5758
})
5859
}
5960

0 commit comments

Comments
 (0)