* Remove unused apub audience field (fixes #5278) * fix * fix test * remove comments
This commit is contained in:
parent
712197f53c
commit
c879eb1244
62 changed files with 49 additions and 198 deletions
|
@ -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,
|
||||
|
|
|
@ -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"
|
||||
}
|
||||
|
|
|
@ -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"
|
||||
}
|
||||
|
|
|
@ -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"
|
||||
}
|
||||
|
|
|
@ -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"
|
||||
}
|
||||
|
|
|
@ -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"
|
||||
}
|
||||
|
|
|
@ -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"
|
||||
}
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -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"
|
||||
}
|
||||
|
|
|
@ -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"
|
||||
}
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -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",
|
||||
|
@ -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"
|
||||
}
|
||||
|
|
|
@ -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",
|
||||
|
@ -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"
|
||||
}
|
||||
|
|
|
@ -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"
|
||||
}
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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"
|
||||
}
|
||||
|
|
|
@ -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"
|
||||
}
|
||||
|
|
|
@ -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"
|
||||
}
|
||||
|
|
|
@ -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"
|
||||
}
|
||||
|
|
|
@ -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"
|
||||
}
|
||||
|
|
|
@ -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"
|
||||
}
|
||||
|
|
|
@ -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"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -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<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,
|
||||
|
@ -68,7 +68,6 @@ impl BlockUser {
|
|||
BlockType::Block,
|
||||
&context.settings().get_protocol_and_hostname(),
|
||||
)?,
|
||||
audience,
|
||||
end_time: expires,
|
||||
})
|
||||
}
|
||||
|
|
|
@ -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()]
|
||||
})
|
||||
}
|
||||
|
|
|
@ -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<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,
|
||||
|
@ -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),
|
||||
};
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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<ObjectId<ApubPerson>> = create_or_update
|
||||
|
|
|
@ -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()),
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -102,7 +102,6 @@ impl Delete {
|
|||
kind: DeleteType::Delete,
|
||||
summary,
|
||||
id,
|
||||
audience: community.map(|c| c.actor_id.clone().into()),
|
||||
remove_data: None,
|
||||
})
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -87,7 +87,6 @@ impl UndoDelete {
|
|||
cc: cc.into_iter().collect(),
|
||||
kind: UndoType::Undo,
|
||||
id,
|
||||
audience: community.map(|c| c.actor_id.clone().into()),
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -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<Url> {
|
||||
pub(crate) fn generate_to(community: &Community) -> LemmyResult<Vec<Url>> {
|
||||
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<T>(a: &ObjectId<ApubCommunity>, b: T) -> LemmyResult<()>
|
||||
where
|
||||
T: Into<ObjectId<ApubCommunity>>,
|
||||
{
|
||||
let b: ObjectId<ApubCommunity> = b.into();
|
||||
if a != &b {
|
||||
Err(FederationError::InvalidCommunity)?
|
||||
} else {
|
||||
Ok(())
|
||||
Ok(vec![
|
||||
actor_id.clone(),
|
||||
Url::parse(&format!("{}/followers", actor_id))?,
|
||||
])
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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<LemmyContext>,
|
||||
) -> LemmyResult<Self> {
|
||||
Ok(UndoVote {
|
||||
|
@ -37,7 +36,6 @@ impl UndoVote {
|
|||
UndoType::Undo,
|
||||
&context.settings().get_protocol_and_hostname(),
|
||||
)?,
|
||||
audience: Some(community.id().into()),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<PostOrComment>,
|
||||
actor: &ApubPerson,
|
||||
community: &ApubCommunity,
|
||||
kind: VoteType,
|
||||
context: &Data<LemmyContext>,
|
||||
) -> LemmyResult<Vote> {
|
||||
|
@ -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()),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<ApubCommunity>,
|
||||
context: &Data<LemmyContext>,
|
||||
) -> LemmyResult<MentionsAndAddresses> {
|
||||
let parent_creator = get_comment_parent_creator(&mut context.pool(), comment).await?;
|
||||
let mut addressed_ccs: Vec<Url> = vec![community_id.into(), parent_creator.id()];
|
||||
let mut addressed_ccs: Vec<Url> = vec![parent_creator.id()];
|
||||
|
||||
// Add the mention tag
|
||||
let parent_creator_tag = Mention {
|
||||
|
|
|
@ -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![],
|
||||
};
|
||||
|
||||
|
|
|
@ -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],
|
||||
};
|
||||
|
|
|
@ -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<ObjectId<ApubCommunity>>,
|
||||
|
||||
/// 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)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<ObjectId<ApubCommunity>>,
|
||||
|
||||
/// 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<LemmyContext>) -> LemmyResult<ApubCommunity> {
|
||||
let community = self.object.community(context).await?;
|
||||
if let Some(audience) = &self.audience {
|
||||
verify_community_matches(audience, community.actor_id.clone())?;
|
||||
}
|
||||
Ok(community)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<ObjectId<ApubCommunity>>,
|
||||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
|
@ -36,9 +34,6 @@ impl InCommunity for CollectionAdd {
|
|||
async fn community(&self, context: &Data<LemmyContext>) -> LemmyResult<ApubCommunity> {
|
||||
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())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<ObjectId<ApubCommunity>>,
|
||||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
|
@ -36,9 +34,6 @@ impl InCommunity for CollectionRemove {
|
|||
async fn community(&self, context: &Data<LemmyContext>) -> LemmyResult<ApubCommunity> {
|
||||
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())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<ObjectId<ApubCommunity>>,
|
||||
}
|
||||
|
||||
#[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<ObjectId<ApubCommunity>>,
|
||||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
|
@ -56,9 +53,6 @@ impl InCommunity for LockPage {
|
|||
async fn community(&self, context: &Data<LemmyContext>) -> LemmyResult<ApubCommunity> {
|
||||
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<LemmyContext>) -> LemmyResult<ApubCommunity> {
|
||||
let community = self.object.community(context).await?;
|
||||
if let Some(audience) = &self.audience {
|
||||
verify_community_matches(audience, community.actor_id.clone())?;
|
||||
}
|
||||
Ok(community)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<ObjectId<ApubCommunity>>,
|
||||
}
|
||||
|
||||
impl Report {
|
||||
|
@ -73,9 +71,6 @@ impl ReportObject {
|
|||
impl InCommunity for Report {
|
||||
async fn community(&self, context: &Data<LemmyContext>) -> LemmyResult<ApubCommunity> {
|
||||
let community = self.to[0].dereference(context).await?;
|
||||
if let Some(audience) = &self.audience {
|
||||
verify_community_matches(audience, community.actor_id.clone())?;
|
||||
}
|
||||
Ok(community)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<ObjectId<ApubCommunity>>,
|
||||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl InCommunity for UpdateCommunity {
|
||||
async fn community(&self, context: &Data<LemmyContext>) -> LemmyResult<ApubCommunity> {
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<ObjectId<ApubCommunity>>,
|
||||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
|
@ -37,9 +35,6 @@ impl InCommunity for CreateOrUpdateNote {
|
|||
async fn community(&self, context: &Data<LemmyContext>) -> LemmyResult<ApubCommunity> {
|
||||
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())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<ObjectId<ApubCommunity>>,
|
||||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl InCommunity for CreateOrUpdatePage {
|
||||
async fn community(&self, context: &Data<LemmyContext>) -> LemmyResult<ApubCommunity> {
|
||||
let community = self.object.community(context).await?;
|
||||
if let Some(audience) = &self.audience {
|
||||
verify_community_matches(audience, community.actor_id.clone())?;
|
||||
}
|
||||
Ok(community)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<ObjectId<ApubCommunity>>,
|
||||
|
||||
#[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())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<ObjectId<ApubCommunity>>,
|
||||
|
||||
#[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<LemmyContext>) -> LemmyResult<ApubCommunity> {
|
||||
let community = self.object.community(context).await?;
|
||||
if let Some(audience) = &self.audience {
|
||||
verify_community_matches(audience, community.actor_id.clone())?;
|
||||
}
|
||||
Ok(community)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<ObjectId<ApubCommunity>>,
|
||||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl InCommunity for UndoVote {
|
||||
async fn community(&self, context: &Data<LemmyContext>) -> LemmyResult<ApubCommunity> {
|
||||
let community = self.object.community(context).await?;
|
||||
if let Some(audience) = &self.audience {
|
||||
verify_community_matches(audience, community.actor_id.clone())?;
|
||||
}
|
||||
Ok(community)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<ObjectId<ApubCommunity>>,
|
||||
}
|
||||
|
||||
#[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)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -82,8 +82,6 @@ impl<Kind: Id + DeserializeOwned + Send> IdOrNestedObject<Kind> {
|
|||
|
||||
#[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<ObjectId<ApubCommunity>>`
|
||||
async fn community(&self, context: &Data<LemmyContext>) -> LemmyResult<ApubCommunity>;
|
||||
}
|
||||
|
||||
|
|
|
@ -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<bool>,
|
||||
pub(crate) language: Option<LanguageTag>,
|
||||
pub(crate) audience: Option<ObjectId<ApubCommunity>>,
|
||||
#[serde(default)]
|
||||
pub(crate) attachment: Vec<Attachment>,
|
||||
}
|
||||
|
@ -94,9 +92,6 @@ impl InCommunity for Note {
|
|||
async fn community(&self, context: &Data<LemmyContext>) -> LemmyResult<ApubCommunity> {
|
||||
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())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<DateTime<Utc>>,
|
||||
pub(crate) updated: Option<DateTime<Utc>>,
|
||||
pub(crate) language: Option<LanguageTag>,
|
||||
pub(crate) audience: Option<ObjectId<ApubCommunity>>,
|
||||
#[serde(deserialize_with = "deserialize_skip_error", default)]
|
||||
pub(crate) tag: Vec<Hashtag>,
|
||||
}
|
||||
|
@ -231,10 +229,6 @@ impl ActivityHandler for Page {
|
|||
#[async_trait::async_trait]
|
||||
impl InCommunity for Page {
|
||||
async fn community(&self, context: &Data<LemmyContext>) -> LemmyResult<ApubCommunity> {
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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()),
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue