use crate::{
activities::{
check_community_deleted_or_removed,
- community::{announce::GetCommunity, send_activity_in_community},
+ community::send_activity_in_community,
create_or_update::get_comment_notif_recipients,
generate_activity_id,
verify_is_public,
local_instance,
mentions::MentionOrValue,
objects::{comment::ApubComment, community::ApubCommunity, person::ApubPerson},
- protocol::activities::{create_or_update::comment::CreateOrUpdateComment, CreateOrUpdateType},
+ protocol::{
+ activities::{create_or_update::note::CreateOrUpdateNote, CreateOrUpdateType},
+ InCommunity,
+ },
ActorType,
};
use activitypub_federation::{
use lemmy_websocket::{send::send_comment_ws_message, LemmyContext, UserOperationCrud};
use url::Url;
-impl CreateOrUpdateComment {
+impl CreateOrUpdateNote {
#[tracing::instrument(skip(comment, actor, kind, context))]
pub async fn send(
comment: ApubComment,
)?;
let note = comment.into_apub(context).await?;
- let create_or_update = CreateOrUpdateComment {
+ let create_or_update = CreateOrUpdateNote {
actor: ObjectId::new(actor.actor_id()),
to: vec![public()],
cc: note.cc.clone(),
object: note,
kind,
id: id.clone(),
+ audience: Some(ObjectId::new(community.actor_id())),
};
let tagged_users: Vec<ObjectId<ApubPerson>> = create_or_update
}
#[async_trait::async_trait(?Send)]
-impl ActivityHandler for CreateOrUpdateComment {
+impl ActivityHandler for CreateOrUpdateNote {
type DataType = LemmyContext;
type Error = LemmyError;
) -> Result<(), LemmyError> {
verify_is_public(&self.to, &self.cc)?;
let post = self.object.get_parents(context, request_counter).await?.0;
- let community = self.get_community(context, request_counter).await?;
+ let community = self.community(context, request_counter).await?;
verify_person_in_community(&self.actor, &community, context, request_counter).await?;
verify_domains_match(self.actor.inner(), self.object.id.inner())?;
Ok(())
}
}
-
-#[async_trait::async_trait(?Send)]
-impl GetCommunity for CreateOrUpdateComment {
- #[tracing::instrument(skip_all)]
- async fn get_community(
- &self,
- context: &LemmyContext,
- request_counter: &mut i32,
- ) -> Result<ApubCommunity, LemmyError> {
- let post = self.object.get_parents(context, request_counter).await?.0;
- let community = Community::read(context.pool(), post.community_id).await?;
- Ok(community.into())
- }
-}