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