-#[async_trait::async_trait(?Send)]
-impl SendActivity for DeletePost {
- type Response = PostResponse;
-
- async fn send_activity(
- request: &Self,
- response: &Self::Response,
- context: &LemmyContext,
- ) -> Result<(), LemmyError> {
- let local_user_view =
- get_local_user_view_from_jwt(&request.auth, context.pool(), context.secret()).await?;
- let community = Community::read(context.pool(), response.post_view.community.id).await?;
- let deletable = DeletableObjects::Post(Box::new(response.post_view.post.clone().into()));
- send_apub_delete_in_community(
- local_user_view.person,
- community,
- deletable,
- None,
- request.deleted,
- context,
- )
- .await
- }
-}
-
-#[async_trait::async_trait(?Send)]
-impl SendActivity for RemovePost {
- type Response = PostResponse;
-
- async fn send_activity(
- request: &Self,
- response: &Self::Response,
- context: &LemmyContext,
- ) -> Result<(), LemmyError> {
- let local_user_view =
- get_local_user_view_from_jwt(&request.auth, context.pool(), context.secret()).await?;
- let community = Community::read(context.pool(), response.post_view.community.id).await?;
- let deletable = DeletableObjects::Post(Box::new(response.post_view.post.clone().into()));
- send_apub_delete_in_community(
- local_user_view.person,
- community,
- deletable,
- request.reason.clone().or_else(|| Some(String::new())),
- request.removed,
- context,
- )
- .await
- }
-}
-
-#[async_trait::async_trait(?Send)]
-impl SendActivity for DeleteComment {
- type Response = CommentResponse;
-
- async fn send_activity(
- request: &Self,
- response: &Self::Response,
- context: &LemmyContext,
- ) -> Result<(), LemmyError> {
- let community_id = response.comment_view.community.id;
- let community = Community::read(context.pool(), community_id).await?;
- let person = Person::read(context.pool(), response.comment_view.creator.id).await?;
- let deletable =
- DeletableObjects::Comment(Box::new(response.comment_view.comment.clone().into()));
- send_apub_delete_in_community(person, community, deletable, None, request.deleted, context)
- .await
- }
-}
-
-#[async_trait::async_trait(?Send)]
-impl SendActivity for RemoveComment {
- type Response = CommentResponse;
-
- async fn send_activity(
- request: &Self,
- response: &Self::Response,
- context: &LemmyContext,
- ) -> Result<(), LemmyError> {
- let local_user_view =
- get_local_user_view_from_jwt(&request.auth, context.pool(), context.secret()).await?;
- let comment = Comment::read(context.pool(), request.comment_id).await?;
- let community = Community::read(context.pool(), response.comment_view.community.id).await?;
- let deletable = DeletableObjects::Comment(Box::new(comment.into()));
- send_apub_delete_in_community(
- local_user_view.person,
- community,
- deletable,
- request.reason.clone().or_else(|| Some(String::new())),
- request.removed,
- context,
- )
- .await
- }
-}
-
-#[async_trait::async_trait(?Send)]
-impl SendActivity for DeletePrivateMessage {
- type Response = PrivateMessageResponse;
-
- async fn send_activity(
- request: &Self,
- response: &Self::Response,
- context: &LemmyContext,
- ) -> Result<(), LemmyError> {
- let local_user_view =
- get_local_user_view_from_jwt(&request.auth, context.pool(), context.secret()).await?;
- send_apub_delete_private_message(
- &local_user_view.person.into(),
- response.private_message_view.private_message.clone(),
- request.deleted,
- context,
- )
- .await
- }
-}
-
-#[async_trait::async_trait(?Send)]
-impl SendActivity for DeleteCommunity {
- type Response = CommunityResponse;
-
- async fn send_activity(
- request: &Self,
- _response: &Self::Response,
- context: &LemmyContext,
- ) -> Result<(), LemmyError> {
- let local_user_view =
- get_local_user_view_from_jwt(&request.auth, context.pool(), context.secret()).await?;
- let community = Community::read(context.pool(), request.community_id).await?;
- let deletable = DeletableObjects::Community(Box::new(community.clone().into()));
- send_apub_delete_in_community(
- local_user_view.person,
- community,
- deletable,
- None,
- request.deleted,
- context,
- )
- .await
- }
-}
-
-#[async_trait::async_trait(?Send)]
-impl SendActivity for RemoveCommunity {
- type Response = CommunityResponse;
-
- async fn send_activity(
- request: &Self,
- _response: &Self::Response,
- context: &LemmyContext,
- ) -> Result<(), LemmyError> {
- let local_user_view =
- get_local_user_view_from_jwt(&request.auth, context.pool(), context.secret()).await?;
- let community = Community::read(context.pool(), request.community_id).await?;
- let deletable = DeletableObjects::Community(Box::new(community.clone().into()));
- send_apub_delete_in_community(
- local_user_view.person,
- community,
- deletable,
- request.reason.clone().or_else(|| Some(String::new())),
- request.removed,
- context,
- )
- .await
- }
-}
-