mirror of https://github.com/LemmyNet/lemmy.git
Activities in community should also be sent to actors in cc
parent
d1ac6962d0
commit
12c51ab435
|
@ -2,7 +2,7 @@ use crate::{
|
|||
activities::{
|
||||
check_community_deleted_or_removed,
|
||||
comment::{collect_non_local_mentions, get_notif_recipients},
|
||||
community::{announce::GetCommunity, send_to_community},
|
||||
community::{announce::GetCommunity, send_activity_in_community},
|
||||
generate_activity_id,
|
||||
verify_activity,
|
||||
verify_is_public,
|
||||
|
@ -62,7 +62,7 @@ impl CreateOrUpdateComment {
|
|||
};
|
||||
|
||||
let activity = AnnouncableActivities::CreateOrUpdateComment(create_or_update);
|
||||
send_to_community(activity, &id, actor, &community, maa.inboxes, context).await
|
||||
send_activity_in_community(activity, &id, actor, &community, maa.inboxes, context).await
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
use crate::{
|
||||
activities::{
|
||||
community::{announce::GetCommunity, get_community_from_moderators_url, send_to_community},
|
||||
community::{
|
||||
announce::GetCommunity,
|
||||
get_community_from_moderators_url,
|
||||
send_activity_in_community,
|
||||
},
|
||||
generate_activity_id,
|
||||
verify_activity,
|
||||
verify_add_remove_moderator_target,
|
||||
|
@ -51,7 +55,7 @@ impl AddMod {
|
|||
|
||||
let activity = AnnouncableActivities::AddMod(add);
|
||||
let inboxes = vec![added_mod.shared_inbox_or_inbox_url()];
|
||||
send_to_community(activity, &id, actor, community, inboxes, context).await
|
||||
send_activity_in_community(activity, &id, actor, community, inboxes, context).await
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -14,7 +14,6 @@ use lemmy_apub_lib::{
|
|||
};
|
||||
use lemmy_utils::LemmyError;
|
||||
use lemmy_websocket::LemmyContext;
|
||||
use url::Url;
|
||||
|
||||
#[async_trait::async_trait(?Send)]
|
||||
pub(crate) trait GetCommunity {
|
||||
|
@ -48,13 +47,10 @@ impl AnnounceActivity {
|
|||
pub async fn send(
|
||||
object: AnnouncableActivities,
|
||||
community: &ApubCommunity,
|
||||
additional_inboxes: Vec<Url>,
|
||||
context: &LemmyContext,
|
||||
) -> Result<(), LemmyError> {
|
||||
let announce = AnnounceActivity::new(object.clone(), community, context)?;
|
||||
let inboxes = community
|
||||
.get_follower_inboxes(additional_inboxes.clone(), context)
|
||||
.await?;
|
||||
let inboxes = community.get_follower_inboxes(context).await?;
|
||||
send_lemmy_activity(
|
||||
context,
|
||||
&announce,
|
||||
|
@ -65,9 +61,9 @@ impl AnnounceActivity {
|
|||
)
|
||||
.await?;
|
||||
|
||||
// Pleroma (and likely Mastodon) can't handle activities like Announce/Create/Page, so for
|
||||
// compatibility, we also send Announce/Page and Announce/Note (for new and updated
|
||||
// posts/comments).
|
||||
// Pleroma (and likely Mastodon) can't handle activities like Announce/Create/Page. So for
|
||||
// compatibility to allow them to follow Lemmy communities, we also send Announce/Page and
|
||||
// Announce/Note (for new and updated posts/comments).
|
||||
use AnnouncableActivities::*;
|
||||
let object = match object {
|
||||
CreateOrUpdatePost(c) => Page(c.object),
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use crate::{
|
||||
activities::{
|
||||
community::{announce::GetCommunity, send_to_community},
|
||||
community::{announce::GetCommunity, send_activity_in_community},
|
||||
generate_activity_id,
|
||||
verify_activity,
|
||||
verify_is_public,
|
||||
|
@ -63,7 +63,7 @@ impl BlockUserFromCommunity {
|
|||
|
||||
let activity = AnnouncableActivities::BlockUserFromCommunity(block);
|
||||
let inboxes = vec![target.shared_inbox_or_inbox_url()];
|
||||
send_to_community(activity, &block_id, actor, community, inboxes, context).await
|
||||
send_activity_in_community(activity, &block_id, actor, community, inboxes, context).await
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -18,22 +18,20 @@ pub mod report;
|
|||
pub mod undo_block_user;
|
||||
pub mod update;
|
||||
|
||||
pub(crate) async fn send_to_community<T: ActorType>(
|
||||
pub(crate) async fn send_activity_in_community<T: ActorType>(
|
||||
activity: AnnouncableActivities,
|
||||
activity_id: &Url,
|
||||
actor: &T,
|
||||
community: &ApubCommunity,
|
||||
additional_inboxes: Vec<Url>,
|
||||
mut inboxes: Vec<Url>,
|
||||
context: &LemmyContext,
|
||||
) -> Result<(), LemmyError> {
|
||||
// if this is a local community, we need to do an announce from the community instead
|
||||
inboxes.push(community.shared_inbox_or_inbox_url());
|
||||
send_lemmy_activity(context, &activity, activity_id, actor, inboxes, false).await?;
|
||||
|
||||
if community.local {
|
||||
insert_activity(activity_id, &activity, true, false, context.pool()).await?;
|
||||
AnnounceActivity::send(activity, community, additional_inboxes, context).await?;
|
||||
} else {
|
||||
let mut inboxes = additional_inboxes;
|
||||
inboxes.push(community.shared_inbox_or_inbox_url());
|
||||
send_lemmy_activity(context, &activity, activity_id, actor, inboxes, false).await?;
|
||||
AnnounceActivity::send(activity, community, context).await?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
use crate::{
|
||||
activities::{
|
||||
community::{announce::GetCommunity, get_community_from_moderators_url, send_to_community},
|
||||
community::{
|
||||
announce::GetCommunity,
|
||||
get_community_from_moderators_url,
|
||||
send_activity_in_community,
|
||||
},
|
||||
generate_activity_id,
|
||||
verify_activity,
|
||||
verify_add_remove_moderator_target,
|
||||
|
@ -51,7 +55,7 @@ impl RemoveMod {
|
|||
|
||||
let activity = AnnouncableActivities::RemoveMod(remove);
|
||||
let inboxes = vec![removed_mod.shared_inbox_or_inbox_url()];
|
||||
send_to_community(activity, &id, actor, community, inboxes, context).await
|
||||
send_activity_in_community(activity, &id, actor, community, inboxes, context).await
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use crate::{
|
||||
activities::{
|
||||
community::{announce::GetCommunity, send_to_community},
|
||||
community::{announce::GetCommunity, send_activity_in_community},
|
||||
generate_activity_id,
|
||||
verify_activity,
|
||||
verify_is_public,
|
||||
|
@ -53,7 +53,7 @@ impl UndoBlockUserFromCommunity {
|
|||
|
||||
let activity = AnnouncableActivities::UndoBlockUserFromCommunity(undo);
|
||||
let inboxes = vec![target.shared_inbox_or_inbox_url()];
|
||||
send_to_community(activity, &id, actor, community, inboxes, context).await
|
||||
send_activity_in_community(activity, &id, actor, community, inboxes, context).await
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use crate::{
|
||||
activities::{
|
||||
community::{announce::GetCommunity, send_to_community},
|
||||
community::{announce::GetCommunity, send_activity_in_community},
|
||||
generate_activity_id,
|
||||
verify_activity,
|
||||
verify_is_public,
|
||||
|
@ -46,7 +46,7 @@ impl UpdateCommunity {
|
|||
};
|
||||
|
||||
let activity = AnnouncableActivities::UpdateCommunity(update);
|
||||
send_to_community(activity, &id, actor, &community, vec![], context).await
|
||||
send_activity_in_community(activity, &id, actor, &community, vec![], context).await
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use crate::{
|
||||
activities::{
|
||||
community::{announce::GetCommunity, send_to_community},
|
||||
community::{announce::GetCommunity, send_activity_in_community},
|
||||
deletion::{receive_delete_action, verify_delete_activity, DeletableObjects},
|
||||
generate_activity_id,
|
||||
verify_activity,
|
||||
|
@ -118,7 +118,7 @@ impl Delete {
|
|||
let delete_id = delete.id.clone();
|
||||
|
||||
let activity = AnnouncableActivities::Delete(delete);
|
||||
send_to_community(activity, &delete_id, actor, community, vec![], context).await
|
||||
send_activity_in_community(activity, &delete_id, actor, community, vec![], context).await
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use crate::{
|
||||
activities::{
|
||||
community::{announce::GetCommunity, send_to_community},
|
||||
community::{announce::GetCommunity, send_activity_in_community},
|
||||
deletion::{receive_delete_action, verify_delete_activity, DeletableObjects},
|
||||
generate_activity_id,
|
||||
verify_activity,
|
||||
|
@ -96,7 +96,7 @@ impl UndoDelete {
|
|||
};
|
||||
|
||||
let activity = AnnouncableActivities::UndoDelete(undo);
|
||||
send_to_community(activity, &id, actor, community, vec![], context).await
|
||||
send_activity_in_community(activity, &id, actor, community, vec![], context).await
|
||||
}
|
||||
|
||||
pub(in crate::activities) async fn receive_undo_remove_action(
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use crate::{
|
||||
activities::{
|
||||
check_community_deleted_or_removed,
|
||||
community::{announce::GetCommunity, send_to_community},
|
||||
community::{announce::GetCommunity, send_activity_in_community},
|
||||
generate_activity_id,
|
||||
verify_activity,
|
||||
verify_is_public,
|
||||
|
@ -63,7 +63,7 @@ impl CreateOrUpdatePost {
|
|||
let create_or_update = CreateOrUpdatePost::new(post, actor, &community, kind, context).await?;
|
||||
let id = create_or_update.id.clone();
|
||||
let activity = AnnouncableActivities::CreateOrUpdatePost(create_or_update);
|
||||
send_to_community(activity, &id, actor, &community, vec![], context).await
|
||||
send_activity_in_community(activity, &id, actor, &community, vec![], context).await
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use crate::{
|
||||
activities::{
|
||||
community::{announce::GetCommunity, send_to_community},
|
||||
community::{announce::GetCommunity, send_activity_in_community},
|
||||
generate_activity_id,
|
||||
verify_activity,
|
||||
verify_is_public,
|
||||
|
@ -56,7 +56,7 @@ impl UndoVote {
|
|||
unparsed: Default::default(),
|
||||
};
|
||||
let activity = AnnouncableActivities::UndoVote(undo_vote);
|
||||
send_to_community(activity, &id, actor, &community, vec![], context).await
|
||||
send_activity_in_community(activity, &id, actor, &community, vec![], context).await
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use crate::{
|
||||
activities::{
|
||||
community::{announce::GetCommunity, send_to_community},
|
||||
community::{announce::GetCommunity, send_activity_in_community},
|
||||
generate_activity_id,
|
||||
verify_activity,
|
||||
verify_is_public,
|
||||
|
@ -62,7 +62,7 @@ impl Vote {
|
|||
let vote_id = vote.id.clone();
|
||||
|
||||
let activity = AnnouncableActivities::Vote(vote);
|
||||
send_to_community(activity, &vote_id, actor, &community, vec![], context).await
|
||||
send_activity_in_community(activity, &vote_id, actor, &community, vec![], context).await
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -85,7 +85,7 @@ pub(in crate::http) async fn receive_group_inbox(
|
|||
let community = announcable.get_community(context, &mut 0).await?;
|
||||
verify_person_in_community(&actor_id, &community, context, &mut 0).await?;
|
||||
if community.local {
|
||||
AnnounceActivity::send(*announcable, &community, vec![], context).await?;
|
||||
AnnounceActivity::send(*announcable, &community, context).await?;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -192,7 +192,6 @@ impl ApubCommunity {
|
|||
/// For a given community, returns the inboxes of all followers.
|
||||
pub(crate) async fn get_follower_inboxes(
|
||||
&self,
|
||||
additional_inboxes: Vec<Url>,
|
||||
context: &LemmyContext,
|
||||
) -> Result<Vec<Url>, LemmyError> {
|
||||
let id = self.id;
|
||||
|
@ -201,7 +200,7 @@ impl ApubCommunity {
|
|||
CommunityFollowerView::for_community(conn, id)
|
||||
})
|
||||
.await??;
|
||||
let follower_inboxes: Vec<Url> = follows
|
||||
let inboxes: Vec<Url> = follows
|
||||
.into_iter()
|
||||
.filter(|f| !f.follower.local)
|
||||
.map(|f| {
|
||||
|
@ -210,12 +209,8 @@ impl ApubCommunity {
|
|||
.unwrap_or(f.follower.inbox_url)
|
||||
.into()
|
||||
})
|
||||
.collect();
|
||||
let inboxes = vec![follower_inboxes, additional_inboxes]
|
||||
.into_iter()
|
||||
.flatten()
|
||||
.unique()
|
||||
.filter(|inbox| inbox.host_str() != Some(&context.settings().hostname))
|
||||
.filter(|inbox: &Url| inbox.host_str() != Some(&context.settings().hostname))
|
||||
// Don't send to blocked instances
|
||||
.filter(|inbox| check_is_apub_id_valid(inbox, false, &context.settings()).is_ok())
|
||||
.collect();
|
||||
|
|
Loading…
Reference in New Issue