mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-11-26 22:31:20 +00:00
Remove more &mut *
This commit is contained in:
parent
5db6b556cc
commit
0d9db43b0a
65 changed files with 171 additions and 274 deletions
|
@ -27,13 +27,13 @@ impl Perform for DistinguishComment {
|
|||
check_community_ban(
|
||||
local_user_view.person.id,
|
||||
orig_comment.community.id,
|
||||
&mut *context.conn().await?,
|
||||
context.conn().await?,
|
||||
)
|
||||
.await?;
|
||||
|
||||
// Verify that only a mod or admin can distinguish a comment
|
||||
is_mod_or_admin(
|
||||
&mut *context.conn().await?,
|
||||
context.conn().await?,
|
||||
local_user_view.person.id,
|
||||
orig_comment.community.id,
|
||||
)
|
||||
|
|
|
@ -39,7 +39,7 @@ impl Perform for CreateCommentLike {
|
|||
check_community_ban(
|
||||
local_user_view.person.id,
|
||||
orig_comment.community.id,
|
||||
&mut *context.conn().await?,
|
||||
context.conn().await?,
|
||||
)
|
||||
.await?;
|
||||
|
||||
|
|
|
@ -36,12 +36,7 @@ impl Perform for CreateCommentReport {
|
|||
let comment_id = data.comment_id;
|
||||
let comment_view = CommentView::read(context.conn().await?, comment_id, None).await?;
|
||||
|
||||
check_community_ban(
|
||||
person_id,
|
||||
comment_view.community.id,
|
||||
&mut *context.conn().await?,
|
||||
)
|
||||
.await?;
|
||||
check_community_ban(person_id, comment_view.community.id, context.conn().await?).await?;
|
||||
|
||||
let report_form = CommentReportForm {
|
||||
creator_id: person_id,
|
||||
|
@ -62,7 +57,7 @@ impl Perform for CreateCommentReport {
|
|||
send_new_report_email_to_admins(
|
||||
&comment_report_view.creator.name,
|
||||
&comment_report_view.comment_creator.name,
|
||||
&mut *context.conn().await?,
|
||||
context.conn().await?,
|
||||
context.settings(),
|
||||
)
|
||||
.await?;
|
||||
|
|
|
@ -31,7 +31,7 @@ impl Perform for AddModToCommunity {
|
|||
|
||||
// Verify that only mods or admins can add mod
|
||||
is_mod_or_admin(
|
||||
&mut *context.conn().await?,
|
||||
context.conn().await?,
|
||||
local_user_view.person.id,
|
||||
community_id,
|
||||
)
|
||||
|
|
|
@ -42,7 +42,7 @@ impl Perform for BanFromCommunity {
|
|||
|
||||
// Verify that only mods or admins can ban
|
||||
is_mod_or_admin(
|
||||
&mut *context.conn().await?,
|
||||
context.conn().await?,
|
||||
local_user_view.person.id,
|
||||
community_id,
|
||||
)
|
||||
|
@ -78,8 +78,7 @@ impl Perform for BanFromCommunity {
|
|||
|
||||
// Remove/Restore their data if that's desired
|
||||
if remove_data {
|
||||
remove_user_data_in_community(community_id, banned_person_id, &mut *context.conn().await?)
|
||||
.await?;
|
||||
remove_user_data_in_community(community_id, banned_person_id, context.conn().await?).await?;
|
||||
}
|
||||
|
||||
// Mod tables
|
||||
|
|
|
@ -55,13 +55,8 @@ impl Perform for BlockCommunity {
|
|||
.map_err(|e| LemmyError::from_error_message(e, "community_block_already_exists"))?;
|
||||
}
|
||||
|
||||
let community_view = CommunityView::read(
|
||||
&mut *context.conn().await?,
|
||||
community_id,
|
||||
Some(person_id),
|
||||
None,
|
||||
)
|
||||
.await?;
|
||||
let community_view =
|
||||
CommunityView::read(context.conn().await?, community_id, Some(person_id), None).await?;
|
||||
|
||||
Ok(BlockCommunityResponse {
|
||||
blocked: data.block,
|
||||
|
|
|
@ -36,10 +36,10 @@ impl Perform for FollowCommunity {
|
|||
check_community_ban(
|
||||
local_user_view.person.id,
|
||||
community_id,
|
||||
&mut *context.conn().await?,
|
||||
context.conn().await?,
|
||||
)
|
||||
.await?;
|
||||
check_community_deleted_or_removed(community_id, &mut *context.conn().await?).await?;
|
||||
check_community_deleted_or_removed(community_id, context.conn().await?).await?;
|
||||
|
||||
CommunityFollower::follow(context.conn().await?, &community_follower_form)
|
||||
.await
|
||||
|
@ -53,13 +53,8 @@ impl Perform for FollowCommunity {
|
|||
|
||||
let community_id = data.community_id;
|
||||
let person_id = local_user_view.person.id;
|
||||
let community_view = CommunityView::read(
|
||||
&mut *context.conn().await?,
|
||||
community_id,
|
||||
Some(person_id),
|
||||
None,
|
||||
)
|
||||
.await?;
|
||||
let community_view =
|
||||
CommunityView::read(context.conn().await?, community_id, Some(person_id), None).await?;
|
||||
let discussion_languages = CommunityLanguage::read(context.conn().await?, community_id).await?;
|
||||
|
||||
Ok(Self::Response {
|
||||
|
|
|
@ -80,12 +80,8 @@ impl Perform for TransferCommunity {
|
|||
|
||||
let community_id = data.community_id;
|
||||
let person_id = local_user_view.person.id;
|
||||
let community_view = CommunityView::read(
|
||||
&mut *context.conn().await?,
|
||||
community_id,
|
||||
Some(person_id),
|
||||
None,
|
||||
)
|
||||
let community_view =
|
||||
CommunityView::read(context.conn().await?, community_id, Some(person_id), None)
|
||||
.await
|
||||
.map_err(|e| LemmyError::from_error_message(e, "couldnt_find_community"))?;
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ impl Perform for AddAdmin {
|
|||
let added = data.added;
|
||||
let added_person_id = data.person_id;
|
||||
let added_admin = Person::update(
|
||||
&mut *context.conn().await?,
|
||||
context.conn().await?,
|
||||
added_person_id,
|
||||
&PersonUpdateForm::builder().admin(Some(added)).build(),
|
||||
)
|
||||
|
|
|
@ -37,7 +37,7 @@ impl Perform for BanPerson {
|
|||
let expires = data.expires.map(naive_from_unix);
|
||||
|
||||
let person = Person::update(
|
||||
&mut *context.conn().await?,
|
||||
context.conn().await?,
|
||||
banned_person_id,
|
||||
&PersonUpdateForm::builder()
|
||||
.banned(Some(ban))
|
||||
|
@ -52,7 +52,7 @@ impl Perform for BanPerson {
|
|||
if remove_data {
|
||||
remove_user_data(
|
||||
person.id,
|
||||
&mut *context.conn().await?,
|
||||
context.conn().await?,
|
||||
context.settings(),
|
||||
context.client(),
|
||||
)
|
||||
|
|
|
@ -53,7 +53,7 @@ impl Perform for Login {
|
|||
check_registration_application(
|
||||
&local_user_view,
|
||||
&site_view.local_site,
|
||||
&mut *context.conn().await?,
|
||||
context.conn().await?,
|
||||
)
|
||||
.await?;
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ impl Perform for MarkPersonMentionAsRead {
|
|||
let person_mention_id = read_person_mention.id;
|
||||
let read = Some(data.read);
|
||||
PersonMention::update(
|
||||
&mut *context.conn().await?,
|
||||
context.conn().await?,
|
||||
person_mention_id,
|
||||
&PersonMentionUpdateForm { read },
|
||||
)
|
||||
|
@ -43,12 +43,8 @@ impl Perform for MarkPersonMentionAsRead {
|
|||
|
||||
let person_mention_id = read_person_mention.id;
|
||||
let person_id = local_user_view.person.id;
|
||||
let person_mention_view = PersonMentionView::read(
|
||||
&mut *context.conn().await?,
|
||||
person_mention_id,
|
||||
Some(person_id),
|
||||
)
|
||||
.await?;
|
||||
let person_mention_view =
|
||||
PersonMentionView::read(context.conn().await?, person_mention_id, Some(person_id)).await?;
|
||||
|
||||
Ok(PersonMentionResponse {
|
||||
person_mention_view,
|
||||
|
|
|
@ -35,7 +35,7 @@ impl Perform for MarkCommentReplyAsRead {
|
|||
let read = Some(data.read);
|
||||
|
||||
CommentReply::update(
|
||||
&mut *context.conn().await?,
|
||||
context.conn().await?,
|
||||
comment_reply_id,
|
||||
&CommentReplyUpdateForm { read },
|
||||
)
|
||||
|
@ -44,12 +44,8 @@ impl Perform for MarkCommentReplyAsRead {
|
|||
|
||||
let comment_reply_id = read_comment_reply.id;
|
||||
let person_id = local_user_view.person.id;
|
||||
let comment_reply_view = CommentReplyView::read(
|
||||
&mut *context.conn().await?,
|
||||
comment_reply_id,
|
||||
Some(person_id),
|
||||
)
|
||||
.await?;
|
||||
let comment_reply_view =
|
||||
CommentReplyView::read(context.conn().await?, comment_reply_id, Some(person_id)).await?;
|
||||
|
||||
Ok(CommentReplyResponse { comment_reply_view })
|
||||
}
|
||||
|
|
|
@ -24,12 +24,8 @@ impl Perform for GetReportCount {
|
|||
let admin = local_user_view.person.admin;
|
||||
let community_id = data.community_id;
|
||||
|
||||
let comment_reports = CommentReportView::get_report_count(
|
||||
&mut *context.conn().await?,
|
||||
person_id,
|
||||
admin,
|
||||
community_id,
|
||||
)
|
||||
let comment_reports =
|
||||
CommentReportView::get_report_count(context.conn().await?, person_id, admin, community_id)
|
||||
.await?;
|
||||
|
||||
let post_reports =
|
||||
|
|
|
@ -28,7 +28,7 @@ impl Perform for PasswordReset {
|
|||
|
||||
// Check for too many attempts (to limit potential abuse)
|
||||
let recent_resets_count = PasswordResetRequest::get_recent_password_resets_count(
|
||||
&mut *context.conn().await?,
|
||||
context.conn().await?,
|
||||
local_user_view.local_user.id,
|
||||
)
|
||||
.await?;
|
||||
|
@ -37,12 +37,7 @@ impl Perform for PasswordReset {
|
|||
}
|
||||
|
||||
// Email the pure token to the user.
|
||||
send_password_reset_email(
|
||||
&local_user_view,
|
||||
&mut *context.conn().await?,
|
||||
context.settings(),
|
||||
)
|
||||
.await?;
|
||||
send_password_reset_email(&local_user_view, context.conn().await?, context.settings()).await?;
|
||||
Ok(PasswordResetResponse {})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -52,7 +52,7 @@ impl Perform for SaveUserSettings {
|
|||
send_verification_email(
|
||||
&local_user_view,
|
||||
email,
|
||||
&mut *context.conn().await?,
|
||||
context.conn().await?,
|
||||
context.settings(),
|
||||
)
|
||||
.await?;
|
||||
|
@ -100,12 +100,7 @@ impl Perform for SaveUserSettings {
|
|||
.map_err(|e| LemmyError::from_error_message(e, "user_already_exists"))?;
|
||||
|
||||
if let Some(discussion_languages) = data.discussion_languages.clone() {
|
||||
LocalUserLanguage::update(
|
||||
&mut *context.conn().await?,
|
||||
discussion_languages,
|
||||
local_user_id,
|
||||
)
|
||||
.await?;
|
||||
LocalUserLanguage::update(context.conn().await?, discussion_languages, local_user_id).await?;
|
||||
}
|
||||
|
||||
// If generate_totp is Some(false), this will clear it out from the database.
|
||||
|
|
|
@ -37,15 +37,15 @@ impl Perform for FeaturePost {
|
|||
check_community_ban(
|
||||
local_user_view.person.id,
|
||||
orig_post.community_id,
|
||||
&mut *context.conn().await?,
|
||||
context.conn().await?,
|
||||
)
|
||||
.await?;
|
||||
check_community_deleted_or_removed(orig_post.community_id, &mut *context.conn().await?).await?;
|
||||
check_community_deleted_or_removed(orig_post.community_id, context.conn().await?).await?;
|
||||
|
||||
if data.feature_type == PostFeatureType::Community {
|
||||
// Verify that only the mods can feature in community
|
||||
is_mod_or_admin(
|
||||
&mut *context.conn().await?,
|
||||
context.conn().await?,
|
||||
local_user_view.person.id,
|
||||
orig_post.community_id,
|
||||
)
|
||||
|
|
|
@ -41,10 +41,10 @@ impl Perform for CreatePostLike {
|
|||
check_community_ban(
|
||||
local_user_view.person.id,
|
||||
post.community_id,
|
||||
&mut *context.conn().await?,
|
||||
context.conn().await?,
|
||||
)
|
||||
.await?;
|
||||
check_community_deleted_or_removed(post.community_id, &mut *context.conn().await?).await?;
|
||||
check_community_deleted_or_removed(post.community_id, context.conn().await?).await?;
|
||||
|
||||
let like_form = PostLikeForm {
|
||||
post_id: data.post_id,
|
||||
|
@ -66,7 +66,7 @@ impl Perform for CreatePostLike {
|
|||
}
|
||||
|
||||
// Mark the post as read
|
||||
mark_post_as_read(person_id, post_id, &mut *context.conn().await?).await?;
|
||||
mark_post_as_read(person_id, post_id, context.conn().await?).await?;
|
||||
|
||||
build_post_response(
|
||||
context,
|
||||
|
|
|
@ -35,14 +35,14 @@ impl Perform for LockPost {
|
|||
check_community_ban(
|
||||
local_user_view.person.id,
|
||||
orig_post.community_id,
|
||||
&mut *context.conn().await?,
|
||||
context.conn().await?,
|
||||
)
|
||||
.await?;
|
||||
check_community_deleted_or_removed(orig_post.community_id, &mut *context.conn().await?).await?;
|
||||
check_community_deleted_or_removed(orig_post.community_id, context.conn().await?).await?;
|
||||
|
||||
// Verify that only the mods can lock
|
||||
is_mod_or_admin(
|
||||
&mut *context.conn().await?,
|
||||
context.conn().await?,
|
||||
local_user_view.person.id,
|
||||
orig_post.community_id,
|
||||
)
|
||||
|
@ -52,7 +52,7 @@ impl Perform for LockPost {
|
|||
let post_id = data.post_id;
|
||||
let locked = data.locked;
|
||||
Post::update(
|
||||
&mut *context.conn().await?,
|
||||
context.conn().await?,
|
||||
post_id,
|
||||
&PostUpdateForm::builder().locked(Some(locked)).build(),
|
||||
)
|
||||
|
|
|
@ -22,9 +22,9 @@ impl Perform for MarkPostAsRead {
|
|||
|
||||
// Mark the post as read / unread
|
||||
if data.read {
|
||||
mark_post_as_read(person_id, post_id, &mut *context.conn().await?).await?;
|
||||
mark_post_as_read(person_id, post_id, context.conn().await?).await?;
|
||||
} else {
|
||||
mark_post_as_unread(person_id, post_id, &mut *context.conn().await?).await?;
|
||||
mark_post_as_unread(person_id, post_id, context.conn().await?).await?;
|
||||
}
|
||||
|
||||
// Fetch it
|
||||
|
|
|
@ -41,7 +41,7 @@ impl Perform for SavePost {
|
|||
let post_view = PostView::read(context.conn().await?, post_id, Some(person_id), None).await?;
|
||||
|
||||
// Mark the post as read
|
||||
mark_post_as_read(person_id, post_id, &mut *context.conn().await?).await?;
|
||||
mark_post_as_read(person_id, post_id, context.conn().await?).await?;
|
||||
|
||||
Ok(PostResponse { post_view })
|
||||
}
|
||||
|
|
|
@ -33,12 +33,7 @@ impl Perform for CreatePostReport {
|
|||
let post_id = data.post_id;
|
||||
let post_view = PostView::read(context.conn().await?, post_id, None, None).await?;
|
||||
|
||||
check_community_ban(
|
||||
person_id,
|
||||
post_view.community.id,
|
||||
&mut *context.conn().await?,
|
||||
)
|
||||
.await?;
|
||||
check_community_ban(person_id, post_view.community.id, context.conn().await?).await?;
|
||||
|
||||
let report_form = PostReportForm {
|
||||
creator_id: person_id,
|
||||
|
@ -61,7 +56,7 @@ impl Perform for CreatePostReport {
|
|||
send_new_report_email_to_admins(
|
||||
&post_report_view.creator.name,
|
||||
&post_report_view.post_creator.name,
|
||||
&mut *context.conn().await?,
|
||||
context.conn().await?,
|
||||
context.settings(),
|
||||
)
|
||||
.await?;
|
||||
|
|
|
@ -36,7 +36,7 @@ impl Perform for MarkPrivateMessageAsRead {
|
|||
let private_message_id = data.private_message_id;
|
||||
let read = data.read;
|
||||
PrivateMessage::update(
|
||||
&mut *context.conn().await?,
|
||||
context.conn().await?,
|
||||
private_message_id,
|
||||
&PrivateMessageUpdateForm::builder().read(Some(read)).build(),
|
||||
)
|
||||
|
|
|
@ -51,7 +51,7 @@ impl Perform for CreatePrivateMessageReport {
|
|||
send_new_report_email_to_admins(
|
||||
&private_message_report_view.creator.name,
|
||||
&private_message_report_view.private_message_creator.name,
|
||||
&mut *context.conn().await?,
|
||||
context.conn().await?,
|
||||
context.settings(),
|
||||
)
|
||||
.await?;
|
||||
|
|
|
@ -38,7 +38,7 @@ impl Perform for LeaveAdmin {
|
|||
|
||||
let person_id = local_user_view.person.id;
|
||||
Person::update(
|
||||
&mut *context.conn().await?,
|
||||
context.conn().await?,
|
||||
person_id,
|
||||
&PersonUpdateForm::builder().admin(Some(false)).build(),
|
||||
)
|
||||
|
|
|
@ -56,11 +56,7 @@ impl Perform for GetModlog {
|
|||
None => CommunityId(-1),
|
||||
};
|
||||
let is_mod_of_community = data.community_id.is_some()
|
||||
&& is_mod_or_admin(
|
||||
&mut *context.conn().await?,
|
||||
local_person_id,
|
||||
community_id_value,
|
||||
)
|
||||
&& is_mod_or_admin(context.conn().await?, local_person_id, community_id_value)
|
||||
.await
|
||||
.is_ok();
|
||||
let hide_modlog_names = local_site.hide_modlog_mod_names && !is_mod_of_community && !is_admin;
|
||||
|
|
|
@ -46,7 +46,7 @@ impl Perform for PurgeCommunity {
|
|||
|
||||
purge_image_posts_for_community(
|
||||
community_id,
|
||||
&mut *context.conn().await?,
|
||||
context.conn().await?,
|
||||
context.settings(),
|
||||
context.client(),
|
||||
)
|
||||
|
|
|
@ -45,7 +45,7 @@ impl Perform for PurgePerson {
|
|||
|
||||
purge_image_posts_for_person(
|
||||
person_id,
|
||||
&mut *context.conn().await?,
|
||||
context.conn().await?,
|
||||
context.settings(),
|
||||
context.client(),
|
||||
)
|
||||
|
|
|
@ -45,12 +45,7 @@ impl Perform for ApproveRegistrationApplication {
|
|||
.build();
|
||||
|
||||
let approved_user_id = registration_application.local_user_id;
|
||||
LocalUser::update(
|
||||
&mut *context.conn().await?,
|
||||
approved_user_id,
|
||||
&local_user_form,
|
||||
)
|
||||
.await?;
|
||||
LocalUser::update(context.conn().await?, approved_user_id, &local_user_form).await?;
|
||||
|
||||
if data.approve {
|
||||
let approved_local_user_view =
|
||||
|
|
|
@ -23,10 +23,8 @@ impl Perform for GetUnreadRegistrationApplicationCount {
|
|||
|
||||
let verified_email_only = local_site.require_email_verification;
|
||||
|
||||
let registration_applications = RegistrationApplicationView::get_unread_count(
|
||||
&mut *context.conn().await?,
|
||||
verified_email_only,
|
||||
)
|
||||
let registration_applications =
|
||||
RegistrationApplicationView::get_unread_count(context.conn().await?, verified_email_only)
|
||||
.await?;
|
||||
|
||||
Ok(Self::Response {
|
||||
|
|
|
@ -44,7 +44,7 @@ pub async fn build_community_response(
|
|||
community_id: CommunityId,
|
||||
) -> Result<CommunityResponse, LemmyError> {
|
||||
let is_mod_or_admin = is_mod_or_admin(
|
||||
&mut *context.conn().await?,
|
||||
context.conn().await?,
|
||||
local_user_view.person.id,
|
||||
community_id,
|
||||
)
|
||||
|
@ -52,7 +52,7 @@ pub async fn build_community_response(
|
|||
.is_ok();
|
||||
let person_id = local_user_view.person.id;
|
||||
let community_view = CommunityView::read(
|
||||
&mut *context.conn().await?,
|
||||
context.conn().await?,
|
||||
community_id,
|
||||
Some(person_id),
|
||||
Some(is_mod_or_admin),
|
||||
|
@ -76,7 +76,7 @@ pub async fn build_post_response(
|
|||
.await
|
||||
.is_ok();
|
||||
let post_view = PostView::read(
|
||||
&mut *context.conn().await?,
|
||||
context.conn().await?,
|
||||
post_id,
|
||||
Some(person_id),
|
||||
Some(is_mod_or_admin),
|
||||
|
@ -144,8 +144,7 @@ pub async fn send_local_notifs(
|
|||
let parent_creator_id = parent_comment.creator_id;
|
||||
|
||||
// Only add to recipients if that person isn't blocked
|
||||
let creator_blocked =
|
||||
check_person_block(person.id, parent_creator_id, &mut *context.conn().await?)
|
||||
let creator_blocked = check_person_block(person.id, parent_creator_id, context.conn().await?)
|
||||
.await
|
||||
.is_err();
|
||||
|
||||
|
@ -181,8 +180,7 @@ pub async fn send_local_notifs(
|
|||
} else {
|
||||
// If there's no parent, its the post creator
|
||||
// Only add to recipients if that person isn't blocked
|
||||
let creator_blocked =
|
||||
check_person_block(person.id, post.creator_id, &mut *context.conn().await?)
|
||||
let creator_blocked = check_person_block(person.id, post.creator_id, context.conn().await?)
|
||||
.await
|
||||
.is_err();
|
||||
|
||||
|
|
|
@ -53,16 +53,16 @@ impl PerformCrud for CreateComment {
|
|||
|
||||
// Check for a community ban
|
||||
let post_id = data.post_id;
|
||||
let post = get_post(post_id, &mut *context.conn().await?).await?;
|
||||
let post = get_post(post_id, context.conn().await?).await?;
|
||||
let community_id = post.community_id;
|
||||
|
||||
check_community_ban(
|
||||
local_user_view.person.id,
|
||||
community_id,
|
||||
&mut *context.conn().await?,
|
||||
context.conn().await?,
|
||||
)
|
||||
.await?;
|
||||
check_community_deleted_or_removed(community_id, &mut *context.conn().await?).await?;
|
||||
check_community_deleted_or_removed(community_id, context.conn().await?).await?;
|
||||
check_post_deleted_or_removed(&post)?;
|
||||
|
||||
// Check if post is locked, no new comments
|
||||
|
@ -94,7 +94,7 @@ impl PerformCrud for CreateComment {
|
|||
let language_id = data.language_id.unwrap_or(parent_language);
|
||||
|
||||
CommunityLanguage::is_allowed_community_language(
|
||||
&mut *context.conn().await?,
|
||||
context.conn().await?,
|
||||
Some(language_id),
|
||||
community_id,
|
||||
)
|
||||
|
@ -109,11 +109,8 @@ impl PerformCrud for CreateComment {
|
|||
|
||||
// Create the comment
|
||||
let parent_path = parent_opt.clone().map(|t| t.path);
|
||||
let inserted_comment = Comment::create(
|
||||
&mut *context.conn().await?,
|
||||
&comment_form,
|
||||
parent_path.as_ref(),
|
||||
)
|
||||
let inserted_comment =
|
||||
Comment::create(context.conn().await?, &comment_form, parent_path.as_ref())
|
||||
.await
|
||||
.map_err(|e| LemmyError::from_error_message(e, "couldnt_create_comment"))?;
|
||||
|
||||
|
@ -127,7 +124,7 @@ impl PerformCrud for CreateComment {
|
|||
&protocol_and_hostname,
|
||||
)?;
|
||||
let updated_comment = Comment::update(
|
||||
&mut *context.conn().await?,
|
||||
context.conn().await?,
|
||||
inserted_comment_id,
|
||||
&CommentUpdateForm::builder().ap_id(Some(apub_id)).build(),
|
||||
)
|
||||
|
@ -164,7 +161,7 @@ impl PerformCrud for CreateComment {
|
|||
let comment_reply = CommentReply::read_by_comment(context.conn().await?, parent_id).await;
|
||||
if let Ok(reply) = comment_reply {
|
||||
CommentReply::update(
|
||||
&mut *context.conn().await?,
|
||||
context.conn().await?,
|
||||
reply.id,
|
||||
&CommentReplyUpdateForm { read: Some(true) },
|
||||
)
|
||||
|
@ -174,15 +171,12 @@ impl PerformCrud for CreateComment {
|
|||
|
||||
// If the parent has PersonMentions mark them as read too
|
||||
let person_id = local_user_view.person.id;
|
||||
let person_mention = PersonMention::read_by_comment_and_person(
|
||||
&mut *context.conn().await?,
|
||||
parent_id,
|
||||
person_id,
|
||||
)
|
||||
let person_mention =
|
||||
PersonMention::read_by_comment_and_person(context.conn().await?, parent_id, person_id)
|
||||
.await;
|
||||
if let Ok(mention) = person_mention {
|
||||
PersonMention::update(
|
||||
&mut *context.conn().await?,
|
||||
context.conn().await?,
|
||||
mention.id,
|
||||
&PersonMentionUpdateForm { read: Some(true) },
|
||||
)
|
||||
|
|
|
@ -36,7 +36,7 @@ impl PerformCrud for DeleteComment {
|
|||
check_community_ban(
|
||||
local_user_view.person.id,
|
||||
orig_comment.community.id,
|
||||
&mut *context.conn().await?,
|
||||
context.conn().await?,
|
||||
)
|
||||
.await?;
|
||||
|
||||
|
@ -48,7 +48,7 @@ impl PerformCrud for DeleteComment {
|
|||
// Do the delete
|
||||
let deleted = data.deleted;
|
||||
let updated_comment = Comment::update(
|
||||
&mut *context.conn().await?,
|
||||
context.conn().await?,
|
||||
comment_id,
|
||||
&CommentUpdateForm::builder().deleted(Some(deleted)).build(),
|
||||
)
|
||||
|
|
|
@ -32,13 +32,13 @@ impl PerformCrud for RemoveComment {
|
|||
check_community_ban(
|
||||
local_user_view.person.id,
|
||||
orig_comment.community.id,
|
||||
&mut *context.conn().await?,
|
||||
context.conn().await?,
|
||||
)
|
||||
.await?;
|
||||
|
||||
// Verify that only a mod or admin can remove
|
||||
is_mod_or_admin(
|
||||
&mut *context.conn().await?,
|
||||
context.conn().await?,
|
||||
local_user_view.person.id,
|
||||
orig_comment.community.id,
|
||||
)
|
||||
|
@ -47,7 +47,7 @@ impl PerformCrud for RemoveComment {
|
|||
// Do the remove
|
||||
let removed = data.removed;
|
||||
let updated_comment = Comment::update(
|
||||
&mut *context.conn().await?,
|
||||
context.conn().await?,
|
||||
comment_id,
|
||||
&CommentUpdateForm::builder().removed(Some(removed)).build(),
|
||||
)
|
||||
|
|
|
@ -41,7 +41,7 @@ impl PerformCrud for EditComment {
|
|||
check_community_ban(
|
||||
local_user_view.person.id,
|
||||
orig_comment.community.id,
|
||||
&mut *context.conn().await?,
|
||||
context.conn().await?,
|
||||
)
|
||||
.await?;
|
||||
|
||||
|
@ -52,7 +52,7 @@ impl PerformCrud for EditComment {
|
|||
|
||||
let language_id = self.language_id;
|
||||
CommunityLanguage::is_allowed_community_language(
|
||||
&mut *context.conn().await?,
|
||||
context.conn().await?,
|
||||
language_id,
|
||||
orig_comment.community.id,
|
||||
)
|
||||
|
|
|
@ -34,7 +34,7 @@ impl PerformCrud for DeleteCommunity {
|
|||
let community_id = data.community_id;
|
||||
let deleted = data.deleted;
|
||||
Community::update(
|
||||
&mut *context.conn().await?,
|
||||
context.conn().await?,
|
||||
community_id,
|
||||
&CommunityUpdateForm::builder()
|
||||
.deleted(Some(deleted))
|
||||
|
|
|
@ -31,7 +31,7 @@ impl PerformCrud for RemoveCommunity {
|
|||
let community_id = data.community_id;
|
||||
let removed = data.removed;
|
||||
Community::update(
|
||||
&mut *context.conn().await?,
|
||||
context.conn().await?,
|
||||
community_id,
|
||||
&CommunityUpdateForm::builder()
|
||||
.removed(Some(removed))
|
||||
|
|
|
@ -62,17 +62,17 @@ impl PerformCrud for CreatePost {
|
|||
check_community_ban(
|
||||
local_user_view.person.id,
|
||||
data.community_id,
|
||||
&mut *context.conn().await?,
|
||||
context.conn().await?,
|
||||
)
|
||||
.await?;
|
||||
check_community_deleted_or_removed(data.community_id, &mut *context.conn().await?).await?;
|
||||
check_community_deleted_or_removed(data.community_id, context.conn().await?).await?;
|
||||
|
||||
let community_id = data.community_id;
|
||||
let community = Community::read(context.conn().await?, community_id).await?;
|
||||
if community.posting_restricted_to_mods {
|
||||
let community_id = data.community_id;
|
||||
let is_mod = CommunityView::is_mod_or_admin(
|
||||
&mut *context.conn().await?,
|
||||
context.conn().await?,
|
||||
local_user_view.local_user.person_id,
|
||||
community_id,
|
||||
)
|
||||
|
@ -93,7 +93,7 @@ impl PerformCrud for CreatePost {
|
|||
Some(lid) => Some(lid),
|
||||
None => {
|
||||
default_post_language(
|
||||
&mut *context.conn().await?,
|
||||
context.conn().await?,
|
||||
community_id,
|
||||
local_user_view.local_user.id,
|
||||
)
|
||||
|
@ -101,7 +101,7 @@ impl PerformCrud for CreatePost {
|
|||
}
|
||||
};
|
||||
CommunityLanguage::is_allowed_community_language(
|
||||
&mut *context.conn().await?,
|
||||
context.conn().await?,
|
||||
language_id,
|
||||
community_id,
|
||||
)
|
||||
|
@ -142,7 +142,7 @@ impl PerformCrud for CreatePost {
|
|||
&protocol_and_hostname,
|
||||
)?;
|
||||
let updated_post = Post::update(
|
||||
&mut *context.conn().await?,
|
||||
context.conn().await?,
|
||||
inserted_post_id,
|
||||
&PostUpdateForm::builder().ap_id(Some(apub_id)).build(),
|
||||
)
|
||||
|
@ -163,7 +163,7 @@ impl PerformCrud for CreatePost {
|
|||
.map_err(|e| LemmyError::from_error_message(e, "couldnt_like_post"))?;
|
||||
|
||||
// Mark the post as read
|
||||
mark_post_as_read(person_id, post_id, &mut *context.conn().await?).await?;
|
||||
mark_post_as_read(person_id, post_id, context.conn().await?).await?;
|
||||
|
||||
if let Some(url) = &updated_post.url {
|
||||
let mut webmention =
|
||||
|
|
|
@ -32,10 +32,10 @@ impl PerformCrud for DeletePost {
|
|||
check_community_ban(
|
||||
local_user_view.person.id,
|
||||
orig_post.community_id,
|
||||
&mut *context.conn().await?,
|
||||
context.conn().await?,
|
||||
)
|
||||
.await?;
|
||||
check_community_deleted_or_removed(orig_post.community_id, &mut *context.conn().await?).await?;
|
||||
check_community_deleted_or_removed(orig_post.community_id, context.conn().await?).await?;
|
||||
|
||||
// Verify that only the creator can delete
|
||||
if !Post::is_post_creator(local_user_view.person.id, orig_post.creator_id) {
|
||||
|
@ -46,7 +46,7 @@ impl PerformCrud for DeletePost {
|
|||
let post_id = data.post_id;
|
||||
let deleted = data.deleted;
|
||||
Post::update(
|
||||
&mut *context.conn().await?,
|
||||
context.conn().await?,
|
||||
post_id,
|
||||
&PostUpdateForm::builder().deleted(Some(deleted)).build(),
|
||||
)
|
||||
|
|
|
@ -50,7 +50,7 @@ impl PerformCrud for GetPost {
|
|||
.await?
|
||||
.community_id;
|
||||
let is_mod_or_admin = is_mod_or_admin_opt(
|
||||
&mut *context.conn().await?,
|
||||
context.conn().await?,
|
||||
local_user_view.as_ref(),
|
||||
Some(community_id),
|
||||
)
|
||||
|
@ -58,7 +58,7 @@ impl PerformCrud for GetPost {
|
|||
.is_ok();
|
||||
|
||||
let post_view = PostView::read(
|
||||
&mut *context.conn().await?,
|
||||
context.conn().await?,
|
||||
post_id,
|
||||
person_id,
|
||||
Some(is_mod_or_admin),
|
||||
|
@ -69,12 +69,12 @@ impl PerformCrud for GetPost {
|
|||
// Mark the post as read
|
||||
let post_id = post_view.post.id;
|
||||
if let Some(person_id) = person_id {
|
||||
mark_post_as_read(person_id, post_id, &mut *context.conn().await?).await?;
|
||||
mark_post_as_read(person_id, post_id, context.conn().await?).await?;
|
||||
}
|
||||
|
||||
// Necessary for the sidebar subscribed
|
||||
let community_view = CommunityView::read(
|
||||
&mut *context.conn().await?,
|
||||
context.conn().await?,
|
||||
community_id,
|
||||
person_id,
|
||||
Some(is_mod_or_admin),
|
||||
|
|
|
@ -30,13 +30,13 @@ impl PerformCrud for RemovePost {
|
|||
check_community_ban(
|
||||
local_user_view.person.id,
|
||||
orig_post.community_id,
|
||||
&mut *context.conn().await?,
|
||||
context.conn().await?,
|
||||
)
|
||||
.await?;
|
||||
|
||||
// Verify that only the mods can remove
|
||||
is_mod_or_admin(
|
||||
&mut *context.conn().await?,
|
||||
context.conn().await?,
|
||||
local_user_view.person.id,
|
||||
orig_post.community_id,
|
||||
)
|
||||
|
@ -46,7 +46,7 @@ impl PerformCrud for RemovePost {
|
|||
let post_id = data.post_id;
|
||||
let removed = data.removed;
|
||||
Post::update(
|
||||
&mut *context.conn().await?,
|
||||
context.conn().await?,
|
||||
post_id,
|
||||
&PostUpdateForm::builder().removed(Some(removed)).build(),
|
||||
)
|
||||
|
|
|
@ -57,7 +57,7 @@ impl PerformCrud for EditPost {
|
|||
check_community_ban(
|
||||
local_user_view.person.id,
|
||||
orig_post.community_id,
|
||||
&mut *context.conn().await?,
|
||||
context.conn().await?,
|
||||
)
|
||||
.await?;
|
||||
|
||||
|
@ -76,7 +76,7 @@ impl PerformCrud for EditPost {
|
|||
|
||||
let language_id = self.language_id;
|
||||
CommunityLanguage::is_allowed_community_language(
|
||||
&mut *context.conn().await?,
|
||||
context.conn().await?,
|
||||
language_id,
|
||||
orig_post.community_id,
|
||||
)
|
||||
|
|
|
@ -48,7 +48,7 @@ impl PerformCrud for CreatePrivateMessage {
|
|||
check_person_block(
|
||||
local_user_view.person.id,
|
||||
data.recipient_id,
|
||||
&mut *context.conn().await?,
|
||||
context.conn().await?,
|
||||
)
|
||||
.await?;
|
||||
|
||||
|
@ -77,7 +77,7 @@ impl PerformCrud for CreatePrivateMessage {
|
|||
&protocol_and_hostname,
|
||||
)?;
|
||||
PrivateMessage::update(
|
||||
&mut *context.conn().await?,
|
||||
context.conn().await?,
|
||||
inserted_private_message.id,
|
||||
&PrivateMessageUpdateForm::builder()
|
||||
.ap_id(Some(apub_id))
|
||||
|
|
|
@ -36,7 +36,7 @@ impl PerformCrud for DeletePrivateMessage {
|
|||
let private_message_id = data.private_message_id;
|
||||
let deleted = data.deleted;
|
||||
PrivateMessage::update(
|
||||
&mut *context.conn().await?,
|
||||
context.conn().await?,
|
||||
private_message_id,
|
||||
&PrivateMessageUpdateForm::builder()
|
||||
.deleted(Some(deleted))
|
||||
|
|
|
@ -46,7 +46,7 @@ impl PerformCrud for EditPrivateMessage {
|
|||
|
||||
let private_message_id = data.private_message_id;
|
||||
PrivateMessage::update(
|
||||
&mut *context.conn().await?,
|
||||
context.conn().await?,
|
||||
private_message_id,
|
||||
&PrivateMessageUpdateForm::builder()
|
||||
.content(Some(content_slurs_removed))
|
||||
|
|
|
@ -56,12 +56,7 @@ impl PerformCrud for EditSite {
|
|||
validate_update_payload(&local_site, data)?;
|
||||
|
||||
if let Some(discussion_languages) = data.discussion_languages.clone() {
|
||||
SiteLanguage::update(
|
||||
&mut *context.conn().await?,
|
||||
discussion_languages.clone(),
|
||||
&site,
|
||||
)
|
||||
.await?;
|
||||
SiteLanguage::update(context.conn().await?, discussion_languages.clone(), &site).await?;
|
||||
}
|
||||
|
||||
let site_form = SiteUpdateForm::builder()
|
||||
|
|
|
@ -76,7 +76,7 @@ impl PerformCrud for Register {
|
|||
if let Some(captcha_uuid) = &data.captcha_uuid {
|
||||
let uuid = uuid::Uuid::parse_str(captcha_uuid)?;
|
||||
let check = CaptchaAnswer::check_captcha(
|
||||
&mut *context.conn().await?,
|
||||
context.conn().await?,
|
||||
CheckCaptchaAnswer {
|
||||
uuid,
|
||||
answer: data.captcha_answer.clone().unwrap_or_default(),
|
||||
|
@ -157,11 +157,7 @@ impl PerformCrud for Register {
|
|||
|
||||
// Email the admins
|
||||
if local_site.application_email_admins {
|
||||
send_new_applicant_email_to_admins(
|
||||
&data.username,
|
||||
&mut *context.conn().await?,
|
||||
context.settings(),
|
||||
)
|
||||
send_new_applicant_email_to_admins(&data.username, context.conn().await?, context.settings())
|
||||
.await?;
|
||||
}
|
||||
|
||||
|
@ -200,7 +196,7 @@ impl PerformCrud for Register {
|
|||
send_verification_email(
|
||||
&local_user_view,
|
||||
&email,
|
||||
&mut *context.conn().await?,
|
||||
context.conn().await?,
|
||||
context.settings(),
|
||||
)
|
||||
.await?;
|
||||
|
|
|
@ -60,7 +60,7 @@ impl BlockUser {
|
|||
actor: mod_.id().into(),
|
||||
to: vec![public()],
|
||||
object: user.id().into(),
|
||||
cc: generate_cc(target, &mut *context.conn().await?).await?,
|
||||
cc: generate_cc(target, context.conn().await?).await?,
|
||||
target: target.id(),
|
||||
kind: BlockType::Block,
|
||||
remove_data,
|
||||
|
@ -155,7 +155,7 @@ impl ActivityHandler for BlockUser {
|
|||
match target {
|
||||
SiteOrCommunity::Site(_site) => {
|
||||
let blocked_person = Person::update(
|
||||
&mut *context.conn().await?,
|
||||
context.conn().await?,
|
||||
blocked_person.id,
|
||||
&PersonUpdateForm::builder()
|
||||
.banned(Some(true))
|
||||
|
@ -166,7 +166,7 @@ impl ActivityHandler for BlockUser {
|
|||
if self.remove_data.unwrap_or(false) {
|
||||
remove_user_data(
|
||||
blocked_person.id,
|
||||
&mut *context.conn().await?,
|
||||
context.conn().await?,
|
||||
context.settings(),
|
||||
context.client(),
|
||||
)
|
||||
|
@ -202,11 +202,7 @@ impl ActivityHandler for BlockUser {
|
|||
.ok();
|
||||
|
||||
if self.remove_data.unwrap_or(false) {
|
||||
remove_user_data_in_community(
|
||||
community.id,
|
||||
blocked_person.id,
|
||||
&mut *context.conn().await?,
|
||||
)
|
||||
remove_user_data_in_community(community.id, blocked_person.id, context.conn().await?)
|
||||
.await?;
|
||||
}
|
||||
|
||||
|
|
|
@ -53,7 +53,7 @@ impl UndoBlockUser {
|
|||
actor: mod_.id().into(),
|
||||
to: vec![public()],
|
||||
object: block,
|
||||
cc: generate_cc(target, &mut *context.conn().await?).await?,
|
||||
cc: generate_cc(target, context.conn().await?).await?,
|
||||
kind: UndoType::Undo,
|
||||
id: id.clone(),
|
||||
audience,
|
||||
|
@ -103,7 +103,7 @@ impl ActivityHandler for UndoBlockUser {
|
|||
match self.object.target.dereference(context).await? {
|
||||
SiteOrCommunity::Site(_site) => {
|
||||
let blocked_person = Person::update(
|
||||
&mut *context.conn().await?,
|
||||
context.conn().await?,
|
||||
blocked_person.id,
|
||||
&PersonUpdateForm::builder()
|
||||
.banned(Some(false))
|
||||
|
|
|
@ -129,10 +129,8 @@ impl ActivityHandler for CollectionAdd {
|
|||
// If we had to refetch the community while parsing the activity, then the new mod has already
|
||||
// been added. Skip it here as it would result in a duplicate key error.
|
||||
let new_mod_id = new_mod.id;
|
||||
let moderated_communities = CommunityModerator::get_person_moderated_communities(
|
||||
&mut *context.conn().await?,
|
||||
new_mod_id,
|
||||
)
|
||||
let moderated_communities =
|
||||
CommunityModerator::get_person_moderated_communities(context.conn().await?, new_mod_id)
|
||||
.await?;
|
||||
if !moderated_communities.contains(&community.id) {
|
||||
let form = CommunityModeratorForm {
|
||||
|
|
|
@ -97,12 +97,7 @@ impl ActivityHandler for UpdateCommunity {
|
|||
|
||||
let community_update_form = self.object.into_update_form();
|
||||
|
||||
Community::update(
|
||||
&mut *context.conn().await?,
|
||||
community.id,
|
||||
&community_update_form,
|
||||
)
|
||||
.await?;
|
||||
Community::update(context.conn().await?, community.id, &community_update_form).await?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -121,7 +121,7 @@ pub(in crate::activities) async fn receive_remove_action(
|
|||
};
|
||||
ModRemoveCommunity::create(context.conn().await?, &form).await?;
|
||||
Community::update(
|
||||
&mut *context.conn().await?,
|
||||
context.conn().await?,
|
||||
community.id,
|
||||
&CommunityUpdateForm::builder().removed(Some(true)).build(),
|
||||
)
|
||||
|
@ -136,7 +136,7 @@ pub(in crate::activities) async fn receive_remove_action(
|
|||
};
|
||||
ModRemovePost::create(context.conn().await?, &form).await?;
|
||||
Post::update(
|
||||
&mut *context.conn().await?,
|
||||
context.conn().await?,
|
||||
post.id,
|
||||
&PostUpdateForm::builder().removed(Some(true)).build(),
|
||||
)
|
||||
|
@ -151,7 +151,7 @@ pub(in crate::activities) async fn receive_remove_action(
|
|||
};
|
||||
ModRemoveComment::create(context.conn().await?, &form).await?;
|
||||
Comment::update(
|
||||
&mut *context.conn().await?,
|
||||
context.conn().await?,
|
||||
comment.id,
|
||||
&CommentUpdateForm::builder().removed(Some(true)).build(),
|
||||
)
|
||||
|
|
|
@ -32,7 +32,7 @@ impl SendActivity for DeleteAccount {
|
|||
let actor: ApubPerson = local_user_view.person.into();
|
||||
delete_user_account(
|
||||
actor.id,
|
||||
&mut *context.conn().await?,
|
||||
context.conn().await?,
|
||||
context.settings(),
|
||||
context.client(),
|
||||
)
|
||||
|
@ -84,7 +84,7 @@ impl ActivityHandler for DeleteUser {
|
|||
let actor = self.actor.dereference(context).await?;
|
||||
delete_user_account(
|
||||
actor.id,
|
||||
&mut *context.conn().await?,
|
||||
context.conn().await?,
|
||||
context.settings(),
|
||||
context.client(),
|
||||
)
|
||||
|
|
|
@ -113,11 +113,7 @@ impl SendActivity for DeleteComment {
|
|||
) -> Result<(), LemmyError> {
|
||||
let community_id = response.comment_view.community.id;
|
||||
let community = Community::read(context.conn().await?, community_id).await?;
|
||||
let person = Person::read(
|
||||
&mut *context.conn().await?,
|
||||
response.comment_view.creator.id,
|
||||
)
|
||||
.await?;
|
||||
let person = Person::read(context.conn().await?, 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
|
||||
|
@ -135,11 +131,8 @@ impl SendActivity for RemoveComment {
|
|||
) -> Result<(), LemmyError> {
|
||||
let local_user_view = local_user_view_from_jwt(&request.auth, context).await?;
|
||||
let comment = Comment::read(context.conn().await?, request.comment_id).await?;
|
||||
let community = Community::read(
|
||||
&mut *context.conn().await?,
|
||||
response.comment_view.community.id,
|
||||
)
|
||||
.await?;
|
||||
let community =
|
||||
Community::read(context.conn().await?, response.comment_view.community.id).await?;
|
||||
let deletable = DeletableObjects::Comment(comment.into());
|
||||
send_apub_delete_in_community(
|
||||
local_user_view.person,
|
||||
|
@ -398,7 +391,7 @@ async fn receive_delete_action(
|
|||
}
|
||||
|
||||
Community::update(
|
||||
&mut *context.conn().await?,
|
||||
context.conn().await?,
|
||||
community.id,
|
||||
&CommunityUpdateForm::builder()
|
||||
.deleted(Some(deleted))
|
||||
|
@ -409,7 +402,7 @@ async fn receive_delete_action(
|
|||
DeletableObjects::Post(post) => {
|
||||
if deleted != post.deleted {
|
||||
Post::update(
|
||||
&mut *context.conn().await?,
|
||||
context.conn().await?,
|
||||
post.id,
|
||||
&PostUpdateForm::builder().deleted(Some(deleted)).build(),
|
||||
)
|
||||
|
@ -419,7 +412,7 @@ async fn receive_delete_action(
|
|||
DeletableObjects::Comment(comment) => {
|
||||
if deleted != comment.deleted {
|
||||
Comment::update(
|
||||
&mut *context.conn().await?,
|
||||
context.conn().await?,
|
||||
comment.id,
|
||||
&CommentUpdateForm::builder().deleted(Some(deleted)).build(),
|
||||
)
|
||||
|
@ -428,7 +421,7 @@ async fn receive_delete_action(
|
|||
}
|
||||
DeletableObjects::PrivateMessage(pm) => {
|
||||
PrivateMessage::update(
|
||||
&mut *context.conn().await?,
|
||||
context.conn().await?,
|
||||
pm.id,
|
||||
&PrivateMessageUpdateForm::builder()
|
||||
.deleted(Some(deleted))
|
||||
|
|
|
@ -113,7 +113,7 @@ impl UndoDelete {
|
|||
};
|
||||
ModRemoveCommunity::create(context.conn().await?, &form).await?;
|
||||
Community::update(
|
||||
&mut *context.conn().await?,
|
||||
context.conn().await?,
|
||||
community.id,
|
||||
&CommunityUpdateForm::builder().removed(Some(false)).build(),
|
||||
)
|
||||
|
@ -128,7 +128,7 @@ impl UndoDelete {
|
|||
};
|
||||
ModRemovePost::create(context.conn().await?, &form).await?;
|
||||
Post::update(
|
||||
&mut *context.conn().await?,
|
||||
context.conn().await?,
|
||||
post.id,
|
||||
&PostUpdateForm::builder().removed(Some(false)).build(),
|
||||
)
|
||||
|
@ -143,7 +143,7 @@ impl UndoDelete {
|
|||
};
|
||||
ModRemoveComment::create(context.conn().await?, &form).await?;
|
||||
Comment::update(
|
||||
&mut *context.conn().await?,
|
||||
context.conn().await?,
|
||||
comment.id,
|
||||
&CommentUpdateForm::builder().removed(Some(false)).build(),
|
||||
)
|
||||
|
|
|
@ -42,7 +42,7 @@ impl PerformApub for GetPosts {
|
|||
let listing_type = listing_type_with_default(data.type_, &local_site, community_id)?;
|
||||
|
||||
let is_mod_or_admin = is_mod_or_admin_opt(
|
||||
&mut *context.conn().await?,
|
||||
context.conn().await?,
|
||||
local_user_view.as_ref(),
|
||||
community_id,
|
||||
)
|
||||
|
|
|
@ -51,7 +51,7 @@ impl PerformApub for GetCommunity {
|
|||
};
|
||||
|
||||
let is_mod_or_admin = is_mod_or_admin_opt(
|
||||
&mut *context.conn().await?,
|
||||
context.conn().await?,
|
||||
local_user_view.as_ref(),
|
||||
Some(community_id),
|
||||
)
|
||||
|
@ -59,7 +59,7 @@ impl PerformApub for GetCommunity {
|
|||
.is_ok();
|
||||
|
||||
let community_view = CommunityView::read(
|
||||
&mut *context.conn().await?,
|
||||
context.conn().await?,
|
||||
community_id,
|
||||
person_id,
|
||||
Some(is_mod_or_admin),
|
||||
|
|
|
@ -31,7 +31,7 @@ impl PerformApub for ResolveObject {
|
|||
let res = search_query_to_object_id(&self.q, context)
|
||||
.await
|
||||
.map_err(|e| e.with_message("couldnt_find_object"))?;
|
||||
convert_response(res, person_id, &mut *context.conn().await?)
|
||||
convert_response(res, person_id, context.conn().await?)
|
||||
.await
|
||||
.map_err(|e| e.with_message("couldnt_find_object"))
|
||||
}
|
||||
|
|
|
@ -129,10 +129,8 @@ mod tests {
|
|||
let community = parse_lemmy_community(&context).await;
|
||||
let community_id = community.id;
|
||||
|
||||
let inserted_instance = Instance::read_or_create(
|
||||
&mut *context.conn().await.unwrap(),
|
||||
"my_domain.tld".to_string(),
|
||||
)
|
||||
let inserted_instance =
|
||||
Instance::read_or_create(context.conn().await.unwrap(), "my_domain.tld".to_string())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
|
@ -150,10 +148,7 @@ mod tests {
|
|||
person_id: old_mod.id,
|
||||
};
|
||||
|
||||
CommunityModerator::join(
|
||||
&mut *context.conn().await.unwrap(),
|
||||
&community_moderator_form,
|
||||
)
|
||||
CommunityModerator::join(context.conn().await.unwrap(), &community_moderator_form)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
|
|
|
@ -98,7 +98,7 @@ impl Object for ApubComment {
|
|||
} else {
|
||||
post.ap_id.into()
|
||||
};
|
||||
let language = LanguageTag::new_single(self.language_id, &mut *context.conn().await?).await?;
|
||||
let language = LanguageTag::new_single(self.language_id, context.conn().await?).await?;
|
||||
let maa = collect_non_local_mentions(&self, community.actor_id.clone().into(), context).await?;
|
||||
|
||||
let note = Note {
|
||||
|
@ -163,7 +163,7 @@ impl Object for ApubComment {
|
|||
let slur_regex = &local_site_opt_to_slur_regex(&local_site);
|
||||
let content_slurs_removed = remove_slurs(&content, slur_regex);
|
||||
let language_id =
|
||||
LanguageTag::to_language_id_single(note.language, &mut *context.conn().await?).await?;
|
||||
LanguageTag::to_language_id_single(note.language, context.conn().await?).await?;
|
||||
|
||||
let form = CommentInsertForm {
|
||||
creator_id: creator.id,
|
||||
|
@ -179,12 +179,8 @@ impl Object for ApubComment {
|
|||
language_id,
|
||||
};
|
||||
let parent_comment_path = parent_comment.map(|t| t.0.path);
|
||||
let comment = Comment::create(
|
||||
&mut *context.conn().await?,
|
||||
&form,
|
||||
parent_comment_path.as_ref(),
|
||||
)
|
||||
.await?;
|
||||
let comment =
|
||||
Comment::create(context.conn().await?, &form, parent_comment_path.as_ref()).await?;
|
||||
Ok(comment.into())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -132,7 +132,7 @@ impl Object for ApubCommunity {
|
|||
|
||||
let form = Group::into_insert_form(group.clone(), instance_id);
|
||||
let languages =
|
||||
LanguageTag::to_language_id_multiple(group.language, &mut *context.conn().await?).await?;
|
||||
LanguageTag::to_language_id_multiple(group.language, context.conn().await?).await?;
|
||||
|
||||
let community = Community::create(context.conn().await?, &form).await?;
|
||||
CommunityLanguage::update(context.conn().await?, languages, community.id).await?;
|
||||
|
|
|
@ -105,7 +105,7 @@ impl Object for ApubPost {
|
|||
let creator = Person::read(context.conn().await?, creator_id).await?;
|
||||
let community_id = self.community_id;
|
||||
let community = Community::read(context.conn().await?, community_id).await?;
|
||||
let language = LanguageTag::new_single(self.language_id, &mut *context.conn().await?).await?;
|
||||
let language = LanguageTag::new_single(self.language_id, context.conn().await?).await?;
|
||||
|
||||
let page = Page {
|
||||
kind: PageType::Page,
|
||||
|
@ -230,7 +230,7 @@ impl Object for ApubPost {
|
|||
read_from_string_or_source_opt(&page.content, &page.media_type, &page.source)
|
||||
.map(|s| remove_slurs(&s, slur_regex));
|
||||
let language_id =
|
||||
LanguageTag::to_language_id_single(page.language, &mut *context.conn().await?).await?;
|
||||
LanguageTag::to_language_id_single(page.language, context.conn().await?).await?;
|
||||
|
||||
PostInsertForm {
|
||||
name,
|
||||
|
|
|
@ -124,7 +124,7 @@ impl Object for ApubPrivateMessage {
|
|||
) -> Result<ApubPrivateMessage, LemmyError> {
|
||||
let creator = note.attributed_to.dereference(context).await?;
|
||||
let recipient = note.to[0].dereference(context).await?;
|
||||
check_person_block(creator.id, recipient.id, &mut *context.conn().await?).await?;
|
||||
check_person_block(creator.id, recipient.id, context.conn().await?).await?;
|
||||
|
||||
let form = PrivateMessageInsertForm {
|
||||
creator_id: creator.id,
|
||||
|
|
|
@ -23,7 +23,6 @@ use diesel_async::{
|
|||
deadpool::{Object as PooledConnection, Pool},
|
||||
AsyncDieselConnectionManager,
|
||||
},
|
||||
AsyncConnection,
|
||||
};
|
||||
use diesel_migrations::EmbeddedMigrations;
|
||||
use futures_util::{future::BoxFuture, FutureExt};
|
||||
|
|
|
@ -179,7 +179,7 @@ async fn get_feed(
|
|||
let builder = match request_type {
|
||||
RequestType::User => {
|
||||
get_feed_user(
|
||||
&mut *context.conn().await?,
|
||||
context.conn().await?,
|
||||
&info.sort_type()?,
|
||||
&info.get_limit(),
|
||||
&info.get_page(),
|
||||
|
@ -190,7 +190,7 @@ async fn get_feed(
|
|||
}
|
||||
RequestType::Community => {
|
||||
get_feed_community(
|
||||
&mut *context.conn().await?,
|
||||
context.conn().await?,
|
||||
&info.sort_type()?,
|
||||
&info.get_limit(),
|
||||
&info.get_page(),
|
||||
|
@ -201,7 +201,7 @@ async fn get_feed(
|
|||
}
|
||||
RequestType::Front => {
|
||||
get_feed_front(
|
||||
&mut *context.conn().await?,
|
||||
context.conn().await?,
|
||||
&jwt_secret,
|
||||
&info.sort_type()?,
|
||||
&info.get_limit(),
|
||||
|
@ -213,7 +213,7 @@ async fn get_feed(
|
|||
}
|
||||
RequestType::Inbox => {
|
||||
get_feed_inbox(
|
||||
&mut *context.conn().await?,
|
||||
context.conn().await?,
|
||||
&jwt_secret,
|
||||
¶m,
|
||||
&protocol_and_hostname,
|
||||
|
|
Loading…
Reference in a new issue