context::LemmyContext,
post::{DeletePost, PostResponse, RemovePost},
private_message::{DeletePrivateMessage, PrivateMessageResponse},
- utils::get_local_user_view_from_jwt,
- websocket::{
- send::{
- send_comment_ws_message_simple,
- send_community_ws_message,
- send_pm_ws_message,
- send_post_ws_message,
- },
- UserOperationCrud,
- },
+ utils::local_user_view_from_jwt,
};
use lemmy_db_schema::{
source::{
response: &Self::Response,
context: &Data<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 local_user_view = local_user_view_from_jwt(&request.auth, context).await?;
+ let community = Community::read(&mut context.pool(), response.post_view.community.id).await?;
let deletable = DeletableObjects::Post(response.post_view.post.clone().into());
send_apub_delete_in_community(
local_user_view.person,
response: &Self::Response,
context: &Data<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 local_user_view = local_user_view_from_jwt(&request.auth, context).await?;
+ let community = Community::read(&mut context.pool(), response.post_view.community.id).await?;
let deletable = DeletableObjects::Post(response.post_view.post.clone().into());
send_apub_delete_in_community(
local_user_view.person,
context: &Data<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 community = Community::read(&mut context.pool(), community_id).await?;
+ let person = Person::read(&mut context.pool(), response.comment_view.creator.id).await?;
let deletable = DeletableObjects::Comment(response.comment_view.comment.clone().into());
send_apub_delete_in_community(person, community, deletable, None, request.deleted, context)
.await
response: &Self::Response,
context: &Data<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 local_user_view = local_user_view_from_jwt(&request.auth, context).await?;
+ let comment = Comment::read(&mut context.pool(), request.comment_id).await?;
+ let community =
+ Community::read(&mut context.pool(), response.comment_view.community.id).await?;
let deletable = DeletableObjects::Comment(comment.into());
send_apub_delete_in_community(
local_user_view.person,
response: &Self::Response,
context: &Data<LemmyContext>,
) -> Result<(), LemmyError> {
- let local_user_view =
- get_local_user_view_from_jwt(&request.auth, context.pool(), context.secret()).await?;
+ let local_user_view = local_user_view_from_jwt(&request.auth, context).await?;
send_apub_delete_private_message(
&local_user_view.person.into(),
response.private_message_view.private_message.clone(),
_response: &Self::Response,
context: &Data<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 local_user_view = local_user_view_from_jwt(&request.auth, context).await?;
+ let community = Community::read(&mut context.pool(), request.community_id).await?;
let deletable = DeletableObjects::Community(community.clone().into());
send_apub_delete_in_community(
local_user_view.person,
_response: &Self::Response,
context: &Data<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 local_user_view = local_user_view_from_jwt(&request.auth, context).await?;
+ let community = Community::read(&mut context.pool(), request.community_id).await?;
let deletable = DeletableObjects::Community(community.clone().into());
send_apub_delete_in_community(
local_user_view.person,
context: &Data<LemmyContext>,
) -> Result<(), LemmyError> {
let recipient_id = pm.recipient_id;
- let recipient: ApubPerson = Person::read(context.pool(), recipient_id).await?.into();
+ let recipient: ApubPerson = Person::read(&mut context.pool(), recipient_id)
+ .await?
+ .into();
let deletable = DeletableObjects::PrivateMessage(pm.into());
let inbox = vec![recipient.shared_inbox_or_inbox()];
send_apub_delete_in_community(mod_, c, object, None, true, context).await?;
}
- let community = Community::update(
- context.pool(),
+ Community::update(
+ &mut context.pool(),
community.id,
&CommunityUpdateForm::builder()
.deleted(Some(deleted))
.build(),
)
.await?;
- send_community_ws_message(
- community.id,
- UserOperationCrud::DeleteCommunity,
- None,
- None,
- context,
- )
- .await?;
}
DeletableObjects::Post(post) => {
if deleted != post.deleted {
- let deleted_post = Post::update(
- context.pool(),
+ Post::update(
+ &mut context.pool(),
post.id,
&PostUpdateForm::builder().deleted(Some(deleted)).build(),
)
.await?;
- send_post_ws_message(
- deleted_post.id,
- UserOperationCrud::DeletePost,
- None,
- None,
- context,
- )
- .await?;
}
}
DeletableObjects::Comment(comment) => {
if deleted != comment.deleted {
- let deleted_comment = Comment::update(
- context.pool(),
+ Comment::update(
+ &mut context.pool(),
comment.id,
&CommentUpdateForm::builder().deleted(Some(deleted)).build(),
)
.await?;
- send_comment_ws_message_simple(
- deleted_comment.id,
- UserOperationCrud::DeleteComment,
- context,
- )
- .await?;
}
}
DeletableObjects::PrivateMessage(pm) => {
- let deleted_private_message = PrivateMessage::update(
- context.pool(),
+ PrivateMessage::update(
+ &mut context.pool(),
pm.id,
&PrivateMessageUpdateForm::builder()
.deleted(Some(deleted))
.build(),
)
.await?;
-
- send_pm_ws_message(
- deleted_private_message.id,
- UserOperationCrud::DeletePrivateMessage,
- None,
- context,
- )
- .await?;
}
}
Ok(())