mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-11-30 00:01:25 +00:00
Community should announce received activities to followers
This commit is contained in:
parent
33a4dac675
commit
71b0738ae8
3 changed files with 18 additions and 9 deletions
|
@ -1,6 +1,7 @@
|
||||||
use crate::{
|
use crate::{
|
||||||
activities::{
|
activities::{
|
||||||
community::announce::AnnouncableActivities,
|
community::announce::{AnnouncableActivities, AnnounceActivity},
|
||||||
|
extract_community,
|
||||||
following::{follow::FollowCommunity, undo::UndoFollowCommunity},
|
following::{follow::FollowCommunity, undo::UndoFollowCommunity},
|
||||||
},
|
},
|
||||||
extensions::context::lemmy_context,
|
extensions::context::lemmy_context,
|
||||||
|
@ -76,15 +77,23 @@ pub async fn community_inbox(
|
||||||
trace!("Received community inbox activity {}", unparsed);
|
trace!("Received community inbox activity {}", unparsed);
|
||||||
let activity = serde_json::from_str::<GroupInboxActivities>(&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(
|
pub(in crate::http) async fn receive_group_inbox(
|
||||||
activity: GroupInboxActivities,
|
activity: GroupInboxActivities,
|
||||||
request: HttpRequest,
|
request: HttpRequest,
|
||||||
context: web::Data<LemmyContext>,
|
context: &LemmyContext,
|
||||||
) -> Result<HttpResponse, LemmyError> {
|
) -> 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).
|
/// Returns an empty followers collection, only populating the size (for privacy).
|
||||||
|
|
|
@ -55,10 +55,10 @@ pub async fn shared_inbox(
|
||||||
let activity = serde_json::from_str::<SharedInboxActivities>(&unparsed)?;
|
let activity = serde_json::from_str::<SharedInboxActivities>(&unparsed)?;
|
||||||
match activity {
|
match activity {
|
||||||
SharedInboxActivities::GroupInboxActivities(g) => {
|
SharedInboxActivities::GroupInboxActivities(g) => {
|
||||||
receive_group_inbox(g, request, context).await
|
receive_group_inbox(g, request, &context).await
|
||||||
}
|
}
|
||||||
SharedInboxActivities::PersonInboxActivities(p) => {
|
SharedInboxActivities::PersonInboxActivities(p) => {
|
||||||
receive_person_inbox(p, request, context).await
|
receive_person_inbox(p, request, &context).await
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,15 +80,15 @@ pub async fn person_inbox(
|
||||||
let unparsed = payload_to_string(payload).await?;
|
let unparsed = payload_to_string(payload).await?;
|
||||||
trace!("Received person inbox activity {}", unparsed);
|
trace!("Received person inbox activity {}", unparsed);
|
||||||
let activity = serde_json::from_str::<PersonInboxActivities>(&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(
|
pub(in crate::http) async fn receive_person_inbox(
|
||||||
activity: PersonInboxActivities,
|
activity: PersonInboxActivities,
|
||||||
request: HttpRequest,
|
request: HttpRequest,
|
||||||
context: web::Data<LemmyContext>,
|
context: &LemmyContext,
|
||||||
) -> Result<HttpResponse, LemmyError> {
|
) -> 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(
|
pub(crate) async fn get_apub_person_outbox(
|
||||||
|
|
Loading…
Reference in a new issue