Community should announce received activities to followers

This commit is contained in:
Felix Ableitner 2021-08-19 19:45:44 +02:00
parent 33a4dac675
commit 71b0738ae8
3 changed files with 18 additions and 9 deletions

View file

@ -1,6 +1,7 @@
use crate::{
activities::{
community::announce::AnnouncableActivities,
community::announce::{AnnouncableActivities, AnnounceActivity},
extract_community,
following::{follow::FollowCommunity, undo::UndoFollowCommunity},
},
extensions::context::lemmy_context,
@ -76,15 +77,23 @@ pub async fn community_inbox(
trace!("Received community inbox activity {}", unparsed);
let activity = serde_json::from_str::<GroupInboxActivities>(&unparsed)?;
receive_group_inbox(activity.clone(), request, context).await
receive_group_inbox(activity.clone(), request, &context).await?;
if let GroupInboxActivities::AnnouncableActivities(announcable) = activity {
let community = extract_community(&announcable.cc(), &context, &mut 0).await?;
if community.local {
AnnounceActivity::send(announcable, &community, vec![], &context).await?;
}
}
Ok(HttpResponse::Ok().finish())
}
pub(in crate::http) async fn receive_group_inbox(
activity: GroupInboxActivities,
request: HttpRequest,
context: web::Data<LemmyContext>,
context: &LemmyContext,
) -> Result<HttpResponse, LemmyError> {
receive_activity(request, activity.clone(), context.get_ref()).await
receive_activity(request, activity.clone(), context).await
}
/// Returns an empty followers collection, only populating the size (for privacy).

View file

@ -55,10 +55,10 @@ pub async fn shared_inbox(
let activity = serde_json::from_str::<SharedInboxActivities>(&unparsed)?;
match activity {
SharedInboxActivities::GroupInboxActivities(g) => {
receive_group_inbox(g, request, context).await
receive_group_inbox(g, request, &context).await
}
SharedInboxActivities::PersonInboxActivities(p) => {
receive_person_inbox(p, request, context).await
receive_person_inbox(p, request, &context).await
}
}
}

View file

@ -80,15 +80,15 @@ pub async fn person_inbox(
let unparsed = payload_to_string(payload).await?;
trace!("Received person inbox activity {}", unparsed);
let activity = serde_json::from_str::<PersonInboxActivities>(&unparsed)?;
receive_person_inbox(activity, request, context).await
receive_person_inbox(activity, request, &context).await
}
pub(in crate::http) async fn receive_person_inbox(
activity: PersonInboxActivities,
request: HttpRequest,
context: web::Data<LemmyContext>,
context: &LemmyContext,
) -> Result<HttpResponse, LemmyError> {
receive_activity(request, activity, context.get_ref()).await
receive_activity(request, activity, context).await
}
pub(crate) async fn get_apub_person_outbox(