Use non-borrowed forms

pull/3707/head
dull b 2023-07-24 19:04:30 +00:00
parent 78c1530601
commit d2dd442563
57 changed files with 158 additions and 161 deletions

View File

@ -44,7 +44,7 @@ impl Perform for DistinguishComment {
let form = CommentUpdateForm::builder()
.distinguished(Some(data.distinguished))
.build();
Comment::update(&mut context.pool(), comment_id, &form)
Comment::update(&mut context.pool(), comment_id, form)
.await
.with_lemmy_type(LemmyErrorType::CouldntUpdateComment)?;

View File

@ -59,7 +59,7 @@ impl Perform for AddModToCommunity {
removed: Some(!data.added),
};
ModAddCommunity::create(&mut context.pool(), &form).await?;
ModAddCommunity::create(&mut context.pool(), form).await?;
// Note: in case a remote mod is added, this returns the old moderators list, it will only get
// updated once we receive an activity from the community (like `Announce/Add/Moderator`)

View File

@ -51,7 +51,7 @@ impl Perform for BanFromCommunity {
};
if data.ban {
CommunityPersonBan::ban(&mut context.pool(), &community_user_ban_form)
CommunityPersonBan::ban(&mut context.pool(), community_user_ban_form)
.await
.with_lemmy_type(LemmyErrorType::CommunityUserAlreadyBanned)?;
@ -66,7 +66,7 @@ impl Perform for BanFromCommunity {
.await
.ok();
} else {
CommunityPersonBan::unban(&mut context.pool(), &community_user_ban_form)
CommunityPersonBan::unban(&mut context.pool(), community_user_ban_form)
.await
.with_lemmy_type(LemmyErrorType::CommunityUserAlreadyBanned)?;
}
@ -86,7 +86,7 @@ impl Perform for BanFromCommunity {
expires,
};
ModBanFromCommunity::create(&mut context.pool(), &form).await?;
ModBanFromCommunity::create(&mut context.pool(), form).await?;
let person_id = data.person_id;
let person_view = PersonView::read(&mut context.pool(), person_id).await?;

View File

@ -79,7 +79,7 @@ impl Perform for TransferCommunity {
community_id: data.community_id,
};
ModTransferCommunity::create(&mut context.pool(), &form).await?;
ModTransferCommunity::create(&mut context.pool(), form).await?;
let community_id = data.community_id;
let person_id = local_user_view.person.id;

View File

@ -44,7 +44,7 @@ impl Perform for AddAdmin {
removed: Some(!data.added),
};
ModAdd::create(&mut context.pool(), &form).await?;
ModAdd::create(&mut context.pool(), form).await?;
let admins = PersonView::admins(&mut context.pool()).await?;

View File

@ -68,7 +68,7 @@ impl Perform for BanPerson {
expires,
};
ModBan::create(&mut context.pool(), &form).await?;
ModBan::create(&mut context.pool(), form).await?;
let person_id = data.person_id;
let person_view = PersonView::read(&mut context.pool(), person_id).await?;

View File

@ -36,7 +36,7 @@ impl Perform for MarkPersonMentionAsRead {
PersonMention::update(
&mut context.pool(),
person_mention_id,
&PersonMentionUpdateForm { read },
PersonMentionUpdateForm { read },
)
.await
.with_lemmy_type(LemmyErrorType::CouldntUpdateComment)?;

View File

@ -37,7 +37,7 @@ impl Perform for MarkCommentReplyAsRead {
CommentReply::update(
&mut context.pool(),
comment_reply_id,
&CommentReplyUpdateForm { read },
CommentReplyUpdateForm { read },
)
.await
.with_lemmy_type(LemmyErrorType::CouldntUpdateComment)?;

View File

@ -31,7 +31,7 @@ impl Perform for VerifyEmail {
.build();
let local_user_id = verification.local_user_id;
LocalUser::update(&mut context.pool(), local_user_id, &form).await?;
LocalUser::update(&mut context.pool(), local_user_id, form).await?;
EmailVerification::delete_old_tokens_for_local_user(&mut context.pool(), local_user_id).await?;

View File

@ -75,7 +75,7 @@ impl Perform for FeaturePost {
is_featured_community: data.feature_type == PostFeatureType::Community,
};
ModFeaturePost::create(&mut context.pool(), &form).await?;
ModFeaturePost::create(&mut context.pool(), form).await?;
build_post_response(
context,

View File

@ -64,7 +64,7 @@ impl Perform for LockPost {
post_id: data.post_id,
locked: Some(locked),
};
ModLockPost::create(&mut context.pool(), &form).await?;
ModLockPost::create(&mut context.pool(), form).await?;
build_post_response(
context,

View File

@ -54,7 +54,7 @@ impl Perform for LeaveAdmin {
removed: Some(true),
};
ModAdd::create(&mut context.pool(), &form).await?;
ModAdd::create(&mut context.pool(), form).await?;
// Reread site and admins
let site_view = SiteView::read_local(&mut context.pool()).await?;

View File

@ -45,7 +45,7 @@ impl Perform for PurgeComment {
post_id,
};
AdminPurgeComment::create(&mut context.pool(), &form).await?;
AdminPurgeComment::create(&mut context.pool(), form).await?;
Ok(PurgeItemResponse { success: true })
}

View File

@ -61,7 +61,7 @@ impl Perform for PurgeCommunity {
reason,
};
AdminPurgeCommunity::create(&mut context.pool(), &form).await?;
AdminPurgeCommunity::create(&mut context.pool(), form).await?;
Ok(PurgeItemResponse { success: true })
}

View File

@ -60,7 +60,7 @@ impl Perform for PurgePerson {
reason,
};
AdminPurgePerson::create(&mut context.pool(), &form).await?;
AdminPurgePerson::create(&mut context.pool(), form).await?;
Ok(PurgeItemResponse { success: true })
}

View File

@ -57,7 +57,7 @@ impl Perform for PurgePost {
community_id,
};
AdminPurgePost::create(&mut context.pool(), &form).await?;
AdminPurgePost::create(&mut context.pool(), form).await?;
Ok(PurgeItemResponse { success: true })
}

View File

@ -372,7 +372,7 @@ pub async fn send_verification_email(
settings.get_protocol_and_hostname(),
&form.verification_token
);
EmailVerification::create(pool, &form).await?;
EmailVerification::create(pool, form).await?;
let lang = get_interface_language(user);
let subject = lang.verify_email_subject(&settings.hostname);

View File

@ -166,7 +166,7 @@ impl PerformCrud for CreateComment {
CommentReply::update(
&mut context.pool(),
reply.id,
&CommentReplyUpdateForm { read: Some(true) },
CommentReplyUpdateForm { read: Some(true) },
)
.await
.with_lemmy_type(LemmyErrorType::CouldntUpdateReplies)?;
@ -180,7 +180,7 @@ impl PerformCrud for CreateComment {
PersonMention::update(
&mut context.pool(),
mention.id,
&PersonMentionUpdateForm { read: Some(true) },
PersonMentionUpdateForm { read: Some(true) },
)
.await
.with_lemmy_type(LemmyErrorType::CouldntUpdatePersonMentions)?;

View File

@ -61,7 +61,7 @@ impl PerformCrud for RemoveComment {
removed: Some(removed),
reason: data.reason.clone(),
};
ModRemoveComment::create(&mut context.pool(), &form).await?;
ModRemoveComment::create(&mut context.pool(), form).await?;
let post_id = updated_comment.post_id;
let post = Post::read(&mut context.pool(), post_id).await?;

View File

@ -72,7 +72,7 @@ impl PerformCrud for EditComment {
.language_id(data.language_id)
.updated(Some(Some(naive_now())))
.build();
let updated_comment = Comment::update(&mut context.pool(), comment_id, &form)
let updated_comment = Comment::update(&mut context.pool(), comment_id, form)
.await
.with_lemmy_type(LemmyErrorType::CouldntUpdateComment)?;

View File

@ -52,7 +52,7 @@ impl PerformCrud for RemoveCommunity {
reason: data.reason.clone(),
expires,
};
ModRemoveCommunity::create(&mut context.pool(), &form).await?;
ModRemoveCommunity::create(&mut context.pool(), form).await?;
build_community_response(context, local_user_view, community_id).await
}

View File

@ -59,7 +59,7 @@ impl PerformCrud for RemovePost {
removed: Some(removed),
reason: data.reason.clone(),
};
ModRemovePost::create(&mut context.pool(), &form).await?;
ModRemovePost::create(&mut context.pool(), form).await?;
build_post_response(
context,

View File

@ -151,7 +151,7 @@ impl PerformCrud for Register {
answer: data.answer.clone().expect("must have an answer"),
};
RegistrationApplication::create(&mut context.pool(), &form).await?;
RegistrationApplication::create(&mut context.pool(), form).await?;
}
// Email the admins

View File

@ -181,7 +181,7 @@ impl ActivityHandler for BlockUser {
banned: Some(true),
expires,
};
ModBan::create(&mut context.pool(), &form).await?;
ModBan::create(&mut context.pool(), form).await?;
}
SiteOrCommunity::Community(community) => {
let community_user_ban_form = CommunityPersonBanForm {
@ -189,7 +189,7 @@ impl ActivityHandler for BlockUser {
person_id: blocked_person.id,
expires: Some(expires),
};
CommunityPersonBan::ban(&mut context.pool(), &community_user_ban_form).await?;
CommunityPersonBan::ban(&mut context.pool(), community_user_ban_form).await?;
// Also unsubscribe them from the community, if they are subscribed
let community_follower_form = CommunityFollowerForm {
@ -215,7 +215,7 @@ impl ActivityHandler for BlockUser {
banned: Some(true),
expires,
};
ModBanFromCommunity::create(&mut context.pool(), &form).await?;
ModBanFromCommunity::create(&mut context.pool(), form).await?;
}
}

View File

@ -120,7 +120,7 @@ impl ActivityHandler for UndoBlockUser {
banned: Some(false),
expires,
};
ModBan::create(&mut context.pool(), &form).await?;
ModBan::create(&mut context.pool(), form).await?;
}
SiteOrCommunity::Community(community) => {
let community_user_ban_form = CommunityPersonBanForm {
@ -128,7 +128,7 @@ impl ActivityHandler for UndoBlockUser {
person_id: blocked_person.id,
expires: None,
};
CommunityPersonBan::unban(&mut context.pool(), &community_user_ban_form).await?;
CommunityPersonBan::unban(&mut context.pool(), community_user_ban_form).await?;
// write to mod log
let form = ModBanFromCommunityForm {
@ -139,7 +139,7 @@ impl ActivityHandler for UndoBlockUser {
banned: Some(false),
expires,
};
ModBanFromCommunity::create(&mut context.pool(), &form).await?;
ModBanFromCommunity::create(&mut context.pool(), form).await?;
}
}

View File

@ -137,7 +137,7 @@ impl ActivityHandler for CollectionAdd {
community_id: community.id,
person_id: new_mod.id,
};
CommunityModerator::join(&mut context.pool(), &form).await?;
CommunityModerator::join(&mut context.pool(), form).await?;
// write mod log
let actor = self.actor.dereference(context).await?;
@ -147,7 +147,7 @@ impl ActivityHandler for CollectionAdd {
community_id: community.id,
removed: Some(false),
};
ModAddCommunity::create(&mut context.pool(), &form).await?;
ModAddCommunity::create(&mut context.pool(), form).await?;
}
// TODO: send websocket notification about added mod
}
@ -158,7 +158,7 @@ impl ActivityHandler for CollectionAdd {
let form = PostUpdateForm::builder()
.featured_community(Some(true))
.build();
Post::update(&mut context.pool(), post.id, &form).await?;
Post::update(&mut context.pool(), post.id, form).await?;
}
}
Ok(())

View File

@ -123,7 +123,7 @@ impl ActivityHandler for CollectionRemove {
community_id: community.id,
person_id: remove_mod.id,
};
CommunityModerator::leave(&mut context.pool(), &form).await?;
CommunityModerator::leave(&mut context.pool(), form).await?;
// write mod log
let actor = self.actor.dereference(context).await?;
@ -133,7 +133,7 @@ impl ActivityHandler for CollectionRemove {
community_id: community.id,
removed: Some(true),
};
ModAddCommunity::create(&mut context.pool(), &form).await?;
ModAddCommunity::create(&mut context.pool(), form).await?;
// TODO: send websocket notification about removed mod
}
@ -144,7 +144,7 @@ impl ActivityHandler for CollectionRemove {
let form = PostUpdateForm::builder()
.featured_community(Some(false))
.build();
Post::update(&mut context.pool(), post.id, &form).await?;
Post::update(&mut context.pool(), post.id, form).await?;
}
}
Ok(())

View File

@ -60,7 +60,7 @@ impl ActivityHandler for LockPage {
async fn receive(self, context: &Data<Self::DataType>) -> Result<(), Self::Error> {
let form = PostUpdateForm::builder().locked(Some(true)).build();
let post = self.object.dereference(context).await?;
Post::update(&mut context.pool(), post.id, &form).await?;
Post::update(&mut context.pool(), post.id, form).await?;
Ok(())
}
}
@ -97,7 +97,7 @@ impl ActivityHandler for UndoLockPage {
async fn receive(self, context: &Data<Self::DataType>) -> Result<(), Self::Error> {
let form = PostUpdateForm::builder().locked(Some(false)).build();
let post = self.object.object.dereference(context).await?;
Post::update(&mut context.pool(), post.id, &form).await?;
Post::update(&mut context.pool(), post.id, form).await?;
Ok(())
}
}

View File

@ -117,7 +117,7 @@ pub(in crate::activities) async fn receive_remove_action(
reason,
expires: None,
};
ModRemoveCommunity::create(&mut context.pool(), &form).await?;
ModRemoveCommunity::create(&mut context.pool(), form).await?;
Community::update(
&mut context.pool(),
community.id,
@ -132,7 +132,7 @@ pub(in crate::activities) async fn receive_remove_action(
removed: Some(true),
reason,
};
ModRemovePost::create(&mut context.pool(), &form).await?;
ModRemovePost::create(&mut context.pool(), form).await?;
Post::update(
&mut context.pool(),
post.id,
@ -147,7 +147,7 @@ pub(in crate::activities) async fn receive_remove_action(
removed: Some(true),
reason,
};
ModRemoveComment::create(&mut context.pool(), &form).await?;
ModRemoveComment::create(&mut context.pool(), form).await?;
Comment::update(
&mut context.pool(),
comment.id,

View File

@ -109,7 +109,7 @@ impl UndoDelete {
reason: None,
expires: None,
};
ModRemoveCommunity::create(&mut context.pool(), &form).await?;
ModRemoveCommunity::create(&mut context.pool(), form).await?;
Community::update(
&mut context.pool(),
community.id,
@ -124,7 +124,7 @@ impl UndoDelete {
removed: Some(false),
reason: None,
};
ModRemovePost::create(&mut context.pool(), &form).await?;
ModRemovePost::create(&mut context.pool(), form).await?;
Post::update(
&mut context.pool(),
post.id,
@ -139,7 +139,7 @@ impl UndoDelete {
removed: Some(false),
reason: None,
};
ModRemoveComment::create(&mut context.pool(), &form).await?;
ModRemoveComment::create(&mut context.pool(), form).await?;
Comment::update(
&mut context.pool(),
comment.id,

View File

@ -113,7 +113,7 @@ impl ActivityHandler for Follow {
follower_id: actor.id,
pending: false,
};
PersonFollower::follow(&mut context.pool(), &form).await?;
PersonFollower::follow(&mut context.pool(), form).await?;
}
UserOrCommunity::Community(c) => {
let form = CommunityFollowerForm {
@ -121,7 +121,7 @@ impl ActivityHandler for Follow {
person_id: actor.id,
pending: false,
};
CommunityFollower::follow(&mut context.pool(), &form).await?;
CommunityFollower::follow(&mut context.pool(), form).await?;
}
}

View File

@ -82,7 +82,7 @@ impl ActivityHandler for UndoFollow {
follower_id: person.id,
pending: false,
};
PersonFollower::unfollow(&mut context.pool(), &form).await?;
PersonFollower::unfollow(&mut context.pool(), form).await?;
}
UserOrCommunity::Community(c) => {
let form = CommunityFollowerForm {
@ -90,7 +90,7 @@ impl ActivityHandler for UndoFollow {
person_id: person.id,
pending: false,
};
CommunityFollower::unfollow(&mut context.pool(), &form).await?;
CommunityFollower::unfollow(&mut context.pool(), form).await?;
}
}

View File

@ -76,7 +76,7 @@ impl Object for ApubComment {
async fn delete(self, context: &Data<Self::DataType>) -> Result<(), LemmyError> {
if !self.deleted {
let form = CommentUpdateForm::builder().deleted(Some(true)).build();
Comment::update(&mut context.pool(), self.id, &form).await?;
Comment::update(&mut context.pool(), self.id, form).await?;
}
Ok(())
}

View File

@ -75,7 +75,7 @@ impl Object for ApubCommunity {
#[tracing::instrument(skip_all)]
async fn delete(self, context: &Data<Self::DataType>) -> Result<(), LemmyError> {
let form = CommunityUpdateForm::builder().deleted(Some(true)).build();
Community::update(&mut context.pool(), self.id, &form).await?;
Community::update(&mut context.pool(), self.id, form).await?;
Ok(())
}
@ -133,7 +133,7 @@ impl Object for ApubCommunity {
let languages =
LanguageTag::to_language_id_multiple(group.language, &mut context.pool()).await?;
let community = Community::create(&mut context.pool(), &form).await?;
let community = Community::create(&mut context.pool(), form).await?;
CommunityLanguage::update(&mut context.pool(), languages, community.id).await?;
let community: ApubCommunity = community.into();

View File

@ -78,7 +78,7 @@ impl Object for ApubPerson {
#[tracing::instrument(skip_all)]
async fn delete(self, context: &Data<Self::DataType>) -> Result<(), LemmyError> {
let form = PersonUpdateForm::builder().deleted(Some(true)).build();
DbPerson::update(&mut context.pool(), self.id, &form).await?;
DbPerson::update(&mut context.pool(), self.id, form).await?;
Ok(())
}

View File

@ -94,7 +94,7 @@ impl Object for ApubPost {
async fn delete(self, context: &Data<Self::DataType>) -> Result<(), LemmyError> {
if !self.deleted {
let form = PostUpdateForm::builder().deleted(Some(true)).build();
Post::update(&mut context.pool(), self.id, &form).await?;
Post::update(&mut context.pool(), self.id, form).await?;
}
Ok(())
}
@ -262,7 +262,7 @@ impl Object for ApubPost {
.build()
};
let post = Post::create(&mut context.pool(), &form).await?;
let post = Post::create(&mut context.pool(), form).await?;
// write mod log entry for lock
if Page::is_locked_changed(&old_post, &page.comments_enabled) {
@ -271,7 +271,7 @@ impl Object for ApubPost {
post_id: post.id,
locked: Some(post.locked),
};
ModLockPost::create(&mut context.pool(), &form).await?;
ModLockPost::create(&mut context.pool(), form).await?;
}
Ok(post.into())

View File

@ -129,7 +129,7 @@ impl Object for ApubPrivateMessage {
ap_id: Some(note.id.into()),
local: Some(false),
};
let pm = PrivateMessage::create(&mut context.pool(), &form).await?;
let pm = PrivateMessage::create(&mut context.pool(), form).await?;
Ok(pm.into())
}
}

View File

@ -67,7 +67,7 @@ mod tests {
let inserted = CaptchaAnswer::insert(
pool,
&CaptchaAnswerForm {
CaptchaAnswerForm {
answer: "XYZ".to_string(),
},
)
@ -95,7 +95,7 @@ mod tests {
let inserted = CaptchaAnswer::insert(
pool,
&CaptchaAnswerForm {
CaptchaAnswerForm {
answer: "XYZ".to_string(),
},
)

View File

@ -158,14 +158,14 @@ impl Crud for Comment {
type IdType = CommentId;
/// This is unimplemented, use [[Comment::create]]
async fn create(_pool: &mut DbPool<'_>, _comment_form: &Self::InsertForm) -> Result<Self, Error> {
async fn create(_pool: &mut DbPool<'_>, _comment_form: Self::InsertForm) -> Result<Self, Error> {
unimplemented!();
}
async fn update(
pool: &mut DbPool<'_>,
comment_id: CommentId,
comment_form: &Self::UpdateForm,
comment_form: Self::UpdateForm,
) -> Result<Self, Error> {
let conn = &mut get_conn(pool).await?;
diesel::update(comment.find(comment_id))
@ -179,7 +179,7 @@ impl Crud for Comment {
impl Likeable for CommentLike {
type Form = CommentLikeForm;
type IdType = CommentId;
async fn like(pool: &mut DbPool<'_>, comment_like_form: &CommentLikeForm) -> Result<Self, Error> {
async fn like(pool: &mut DbPool<'_>, comment_like_form: CommentLikeForm) -> Result<Self, Error> {
use crate::schema::comment_like::dsl::{comment_id, comment_like, person_id};
let conn = &mut get_conn(pool).await?;
insert_into(comment_like)
@ -212,7 +212,7 @@ impl Saveable for CommentSaved {
type Form = CommentSavedForm;
async fn save(
pool: &mut DbPool<'_>,
comment_saved_form: &CommentSavedForm,
comment_saved_form: CommentSavedForm,
) -> Result<Self, Error> {
use crate::schema::comment_saved::dsl::{comment_id, comment_saved, person_id};
let conn = &mut get_conn(pool).await?;
@ -226,7 +226,7 @@ impl Saveable for CommentSaved {
}
async fn unsave(
pool: &mut DbPool<'_>,
comment_saved_form: &CommentSavedForm,
comment_saved_form: CommentSavedForm,
) -> Result<usize, Error> {
use crate::schema::comment_saved::dsl::{comment_id, comment_saved, person_id};
let conn = &mut get_conn(pool).await?;

View File

@ -16,7 +16,7 @@ impl Crud for CommentReply {
async fn create(
pool: &mut DbPool<'_>,
comment_reply_form: &Self::InsertForm,
comment_reply_form: Self::InsertForm,
) -> Result<Self, Error> {
let conn = &mut get_conn(pool).await?;
@ -34,7 +34,7 @@ impl Crud for CommentReply {
async fn update(
pool: &mut DbPool<'_>,
comment_reply_id: CommentReplyId,
comment_reply_form: &Self::UpdateForm,
comment_reply_form: Self::UpdateForm,
) -> Result<Self, Error> {
let conn = &mut get_conn(pool).await?;
diesel::update(comment_reply.find(comment_reply_id))

View File

@ -23,7 +23,7 @@ impl Reportable for CommentReport {
/// * `comment_report_form` - the filled CommentReportForm to insert
async fn report(
pool: &mut DbPool<'_>,
comment_report_form: &CommentReportForm,
comment_report_form: CommentReportForm,
) -> Result<Self, Error> {
let conn = &mut get_conn(pool).await?;
insert_into(comment_report)

View File

@ -28,7 +28,7 @@ impl Crud for Community {
type UpdateForm = CommunityUpdateForm;
type IdType = CommunityId;
async fn create(pool: &mut DbPool<'_>, form: &Self::InsertForm) -> Result<Self, Error> {
async fn create(pool: &mut DbPool<'_>, form: Self::InsertForm) -> Result<Self, Error> {
let is_new_community = match &form.actor_id {
Some(id) => Community::read_from_apub_id(pool, id).await?.is_none(),
None => true,
@ -55,7 +55,7 @@ impl Crud for Community {
async fn update(
pool: &mut DbPool<'_>,
community_id: CommunityId,
form: &Self::UpdateForm,
form: Self::UpdateForm,
) -> Result<Self, Error> {
let conn = &mut get_conn(pool).await?;
diesel::update(community::table.find(community_id))
@ -70,7 +70,7 @@ impl Joinable for CommunityModerator {
type Form = CommunityModeratorForm;
async fn join(
pool: &mut DbPool<'_>,
community_moderator_form: &CommunityModeratorForm,
community_moderator_form: CommunityModeratorForm,
) -> Result<Self, Error> {
use crate::schema::community_moderator::dsl::community_moderator;
let conn = &mut get_conn(pool).await?;
@ -82,7 +82,7 @@ impl Joinable for CommunityModerator {
async fn leave(
pool: &mut DbPool<'_>,
community_moderator_form: &CommunityModeratorForm,
community_moderator_form: CommunityModeratorForm,
) -> Result<usize, Error> {
use crate::schema::community_moderator::dsl::{community_id, community_moderator, person_id};
let conn = &mut get_conn(pool).await?;
@ -171,7 +171,7 @@ impl Bannable for CommunityPersonBan {
type Form = CommunityPersonBanForm;
async fn ban(
pool: &mut DbPool<'_>,
community_person_ban_form: &CommunityPersonBanForm,
community_person_ban_form: CommunityPersonBanForm,
) -> Result<Self, Error> {
use crate::schema::community_person_ban::dsl::{community_id, community_person_ban, person_id};
let conn = &mut get_conn(pool).await?;
@ -186,7 +186,7 @@ impl Bannable for CommunityPersonBan {
async fn unban(
pool: &mut DbPool<'_>,
community_person_ban_form: &CommunityPersonBanForm,
community_person_ban_form: CommunityPersonBanForm,
) -> Result<usize, Error> {
use crate::schema::community_person_ban::dsl::{community_id, community_person_ban, person_id};
let conn = &mut get_conn(pool).await?;
@ -219,7 +219,7 @@ impl CommunityFollower {
#[async_trait]
impl Followable for CommunityFollower {
type Form = CommunityFollowerForm;
async fn follow(pool: &mut DbPool<'_>, form: &CommunityFollowerForm) -> Result<Self, Error> {
async fn follow(pool: &mut DbPool<'_>, form: CommunityFollowerForm) -> Result<Self, Error> {
use crate::schema::community_follower::dsl::{community_follower, community_id, person_id};
let conn = &mut get_conn(pool).await?;
insert_into(community_follower)
@ -251,7 +251,7 @@ impl Followable for CommunityFollower {
.get_result::<Self>(conn)
.await
}
async fn unfollow(pool: &mut DbPool<'_>, form: &CommunityFollowerForm) -> Result<usize, Error> {
async fn unfollow(pool: &mut DbPool<'_>, form: CommunityFollowerForm) -> Result<usize, Error> {
use crate::schema::community_follower::dsl::{community_follower, community_id, person_id};
let conn = &mut get_conn(pool).await?;
diesel::delete(
@ -435,7 +435,7 @@ mod tests {
expires: None,
};
let inserted_community_person_ban = CommunityPersonBan::ban(pool, &community_person_ban_form)
let inserted_community_person_ban = CommunityPersonBan::ban(pool, community_person_ban_form)
.await
.unwrap();
@ -462,7 +462,7 @@ mod tests {
let left_community = CommunityModerator::leave(pool, &community_moderator_form)
.await
.unwrap();
let unban = CommunityPersonBan::unban(pool, &community_person_ban_form)
let unban = CommunityPersonBan::unban(pool, community_person_ban_form)
.await
.unwrap();
let num_deleted = Community::delete(pool, inserted_community.id)

View File

@ -10,7 +10,7 @@ use diesel_async::RunQueryDsl;
#[async_trait]
impl Blockable for CommunityBlock {
type Form = CommunityBlockForm;
async fn block(pool: &mut DbPool<'_>, community_block_form: &Self::Form) -> Result<Self, Error> {
async fn block(pool: &mut DbPool<'_>, community_block_form: Self::Form) -> Result<Self, Error> {
let conn = &mut get_conn(pool).await?;
insert_into(community_block)
.values(community_block_form)
@ -22,7 +22,7 @@ impl Blockable for CommunityBlock {
}
async fn unblock(
pool: &mut DbPool<'_>,
community_block_form: &Self::Form,
community_block_form: Self::Form,
) -> Result<usize, Error> {
let conn = &mut get_conn(pool).await?;
diesel::delete(

View File

@ -70,7 +70,7 @@ impl Crud for LocalUser {
type UpdateForm = LocalUserUpdateForm;
type IdType = LocalUserId;
async fn create(pool: &mut DbPool<'_>, form: &Self::InsertForm) -> Result<Self, Error> {
async fn create(pool: &mut DbPool<'_>, form: Self::InsertForm) -> Result<Self, Error> {
let conn = &mut get_conn(pool).await?;
let mut form_with_encrypted_password = form.clone();
let password_hash =
@ -97,7 +97,7 @@ impl Crud for LocalUser {
async fn update(
pool: &mut DbPool<'_>,
local_user_id: LocalUserId,
form: &Self::UpdateForm,
form: Self::UpdateForm,
) -> Result<Self, Error> {
let conn = &mut get_conn(pool).await?;
diesel::update(local_user.find(local_user_id))

View File

@ -43,7 +43,7 @@ impl Crud for ModRemovePost {
type UpdateForm = ModRemovePostForm;
type IdType = i32;
async fn create(pool: &mut DbPool<'_>, form: &ModRemovePostForm) -> Result<Self, Error> {
async fn create(pool: &mut DbPool<'_>, form: ModRemovePostForm) -> Result<Self, Error> {
use crate::schema::mod_remove_post::dsl::mod_remove_post;
let conn = &mut get_conn(pool).await?;
insert_into(mod_remove_post)
@ -55,7 +55,7 @@ impl Crud for ModRemovePost {
async fn update(
pool: &mut DbPool<'_>,
from_id: i32,
form: &ModRemovePostForm,
form: ModRemovePostForm,
) -> Result<Self, Error> {
use crate::schema::mod_remove_post::dsl::mod_remove_post;
let conn = &mut get_conn(pool).await?;
@ -72,7 +72,7 @@ impl Crud for ModLockPost {
type UpdateForm = ModLockPostForm;
type IdType = i32;
async fn create(pool: &mut DbPool<'_>, form: &ModLockPostForm) -> Result<Self, Error> {
async fn create(pool: &mut DbPool<'_>, form: ModLockPostForm) -> Result<Self, Error> {
use crate::schema::mod_lock_post::dsl::mod_lock_post;
let conn = &mut get_conn(pool).await?;
insert_into(mod_lock_post)
@ -84,7 +84,7 @@ impl Crud for ModLockPost {
async fn update(
pool: &mut DbPool<'_>,
from_id: i32,
form: &ModLockPostForm,
form: ModLockPostForm,
) -> Result<Self, Error> {
use crate::schema::mod_lock_post::dsl::mod_lock_post;
let conn = &mut get_conn(pool).await?;
@ -101,7 +101,7 @@ impl Crud for ModFeaturePost {
type UpdateForm = ModFeaturePostForm;
type IdType = i32;
async fn create(pool: &mut DbPool<'_>, form: &ModFeaturePostForm) -> Result<Self, Error> {
async fn create(pool: &mut DbPool<'_>, form: ModFeaturePostForm) -> Result<Self, Error> {
use crate::schema::mod_feature_post::dsl::mod_feature_post;
let conn = &mut get_conn(pool).await?;
insert_into(mod_feature_post)
@ -113,7 +113,7 @@ impl Crud for ModFeaturePost {
async fn update(
pool: &mut DbPool<'_>,
from_id: i32,
form: &ModFeaturePostForm,
form: ModFeaturePostForm,
) -> Result<Self, Error> {
use crate::schema::mod_feature_post::dsl::mod_feature_post;
let conn = &mut get_conn(pool).await?;
@ -130,7 +130,7 @@ impl Crud for ModRemoveComment {
type UpdateForm = ModRemoveCommentForm;
type IdType = i32;
async fn create(pool: &mut DbPool<'_>, form: &ModRemoveCommentForm) -> Result<Self, Error> {
async fn create(pool: &mut DbPool<'_>, form: ModRemoveCommentForm) -> Result<Self, Error> {
use crate::schema::mod_remove_comment::dsl::mod_remove_comment;
let conn = &mut get_conn(pool).await?;
insert_into(mod_remove_comment)
@ -142,7 +142,7 @@ impl Crud for ModRemoveComment {
async fn update(
pool: &mut DbPool<'_>,
from_id: i32,
form: &ModRemoveCommentForm,
form: ModRemoveCommentForm,
) -> Result<Self, Error> {
use crate::schema::mod_remove_comment::dsl::mod_remove_comment;
let conn = &mut get_conn(pool).await?;
@ -159,7 +159,7 @@ impl Crud for ModRemoveCommunity {
type UpdateForm = ModRemoveCommunityForm;
type IdType = i32;
async fn create(pool: &mut DbPool<'_>, form: &ModRemoveCommunityForm) -> Result<Self, Error> {
async fn create(pool: &mut DbPool<'_>, form: ModRemoveCommunityForm) -> Result<Self, Error> {
use crate::schema::mod_remove_community::dsl::mod_remove_community;
let conn = &mut get_conn(pool).await?;
insert_into(mod_remove_community)
@ -171,7 +171,7 @@ impl Crud for ModRemoveCommunity {
async fn update(
pool: &mut DbPool<'_>,
from_id: i32,
form: &ModRemoveCommunityForm,
form: ModRemoveCommunityForm,
) -> Result<Self, Error> {
use crate::schema::mod_remove_community::dsl::mod_remove_community;
let conn = &mut get_conn(pool).await?;
@ -188,7 +188,7 @@ impl Crud for ModBanFromCommunity {
type UpdateForm = ModBanFromCommunityForm;
type IdType = i32;
async fn create(pool: &mut DbPool<'_>, form: &ModBanFromCommunityForm) -> Result<Self, Error> {
async fn create(pool: &mut DbPool<'_>, form: ModBanFromCommunityForm) -> Result<Self, Error> {
use crate::schema::mod_ban_from_community::dsl::mod_ban_from_community;
let conn = &mut get_conn(pool).await?;
insert_into(mod_ban_from_community)
@ -200,7 +200,7 @@ impl Crud for ModBanFromCommunity {
async fn update(
pool: &mut DbPool<'_>,
from_id: i32,
form: &ModBanFromCommunityForm,
form: ModBanFromCommunityForm,
) -> Result<Self, Error> {
use crate::schema::mod_ban_from_community::dsl::mod_ban_from_community;
let conn = &mut get_conn(pool).await?;
@ -217,7 +217,7 @@ impl Crud for ModBan {
type UpdateForm = ModBanForm;
type IdType = i32;
async fn create(pool: &mut DbPool<'_>, form: &ModBanForm) -> Result<Self, Error> {
async fn create(pool: &mut DbPool<'_>, form: ModBanForm) -> Result<Self, Error> {
use crate::schema::mod_ban::dsl::mod_ban;
let conn = &mut get_conn(pool).await?;
insert_into(mod_ban)
@ -226,7 +226,7 @@ impl Crud for ModBan {
.await
}
async fn update(pool: &mut DbPool<'_>, from_id: i32, form: &ModBanForm) -> Result<Self, Error> {
async fn update(pool: &mut DbPool<'_>, from_id: i32, form: ModBanForm) -> Result<Self, Error> {
use crate::schema::mod_ban::dsl::mod_ban;
let conn = &mut get_conn(pool).await?;
diesel::update(mod_ban.find(from_id))
@ -242,7 +242,7 @@ impl Crud for ModHideCommunity {
type UpdateForm = ModHideCommunityForm;
type IdType = i32;
async fn create(pool: &mut DbPool<'_>, form: &ModHideCommunityForm) -> Result<Self, Error> {
async fn create(pool: &mut DbPool<'_>, form: ModHideCommunityForm) -> Result<Self, Error> {
use crate::schema::mod_hide_community::dsl::mod_hide_community;
let conn = &mut get_conn(pool).await?;
insert_into(mod_hide_community)
@ -254,7 +254,7 @@ impl Crud for ModHideCommunity {
async fn update(
pool: &mut DbPool<'_>,
from_id: i32,
form: &ModHideCommunityForm,
form: ModHideCommunityForm,
) -> Result<Self, Error> {
use crate::schema::mod_hide_community::dsl::mod_hide_community;
let conn = &mut get_conn(pool).await?;
@ -271,7 +271,7 @@ impl Crud for ModAddCommunity {
type UpdateForm = ModAddCommunityForm;
type IdType = i32;
async fn create(pool: &mut DbPool<'_>, form: &ModAddCommunityForm) -> Result<Self, Error> {
async fn create(pool: &mut DbPool<'_>, form: ModAddCommunityForm) -> Result<Self, Error> {
use crate::schema::mod_add_community::dsl::mod_add_community;
let conn = &mut get_conn(pool).await?;
insert_into(mod_add_community)
@ -283,7 +283,7 @@ impl Crud for ModAddCommunity {
async fn update(
pool: &mut DbPool<'_>,
from_id: i32,
form: &ModAddCommunityForm,
form: ModAddCommunityForm,
) -> Result<Self, Error> {
use crate::schema::mod_add_community::dsl::mod_add_community;
let conn = &mut get_conn(pool).await?;
@ -300,7 +300,7 @@ impl Crud for ModTransferCommunity {
type UpdateForm = ModTransferCommunityForm;
type IdType = i32;
async fn create(pool: &mut DbPool<'_>, form: &ModTransferCommunityForm) -> Result<Self, Error> {
async fn create(pool: &mut DbPool<'_>, form: ModTransferCommunityForm) -> Result<Self, Error> {
use crate::schema::mod_transfer_community::dsl::mod_transfer_community;
let conn = &mut get_conn(pool).await?;
insert_into(mod_transfer_community)
@ -312,7 +312,7 @@ impl Crud for ModTransferCommunity {
async fn update(
pool: &mut DbPool<'_>,
from_id: i32,
form: &ModTransferCommunityForm,
form: ModTransferCommunityForm,
) -> Result<Self, Error> {
use crate::schema::mod_transfer_community::dsl::mod_transfer_community;
let conn = &mut get_conn(pool).await?;
@ -329,7 +329,7 @@ impl Crud for ModAdd {
type UpdateForm = ModAddForm;
type IdType = i32;
async fn create(pool: &mut DbPool<'_>, form: &ModAddForm) -> Result<Self, Error> {
async fn create(pool: &mut DbPool<'_>, form: ModAddForm) -> Result<Self, Error> {
use crate::schema::mod_add::dsl::mod_add;
let conn = &mut get_conn(pool).await?;
insert_into(mod_add)
@ -338,7 +338,7 @@ impl Crud for ModAdd {
.await
}
async fn update(pool: &mut DbPool<'_>, from_id: i32, form: &ModAddForm) -> Result<Self, Error> {
async fn update(pool: &mut DbPool<'_>, from_id: i32, form: ModAddForm) -> Result<Self, Error> {
use crate::schema::mod_add::dsl::mod_add;
let conn = &mut get_conn(pool).await?;
diesel::update(mod_add.find(from_id))
@ -354,7 +354,7 @@ impl Crud for AdminPurgePerson {
type UpdateForm = AdminPurgePersonForm;
type IdType = i32;
async fn create(pool: &mut DbPool<'_>, form: &Self::InsertForm) -> Result<Self, Error> {
async fn create(pool: &mut DbPool<'_>, form: Self::InsertForm) -> Result<Self, Error> {
use crate::schema::admin_purge_person::dsl::admin_purge_person;
let conn = &mut get_conn(pool).await?;
insert_into(admin_purge_person)
@ -366,7 +366,7 @@ impl Crud for AdminPurgePerson {
async fn update(
pool: &mut DbPool<'_>,
from_id: i32,
form: &Self::InsertForm,
form: Self::InsertForm,
) -> Result<Self, Error> {
use crate::schema::admin_purge_person::dsl::admin_purge_person;
let conn = &mut get_conn(pool).await?;
@ -383,7 +383,7 @@ impl Crud for AdminPurgeCommunity {
type UpdateForm = AdminPurgeCommunityForm;
type IdType = i32;
async fn create(pool: &mut DbPool<'_>, form: &Self::InsertForm) -> Result<Self, Error> {
async fn create(pool: &mut DbPool<'_>, form: Self::InsertForm) -> Result<Self, Error> {
use crate::schema::admin_purge_community::dsl::admin_purge_community;
let conn = &mut get_conn(pool).await?;
insert_into(admin_purge_community)
@ -395,7 +395,7 @@ impl Crud for AdminPurgeCommunity {
async fn update(
pool: &mut DbPool<'_>,
from_id: i32,
form: &Self::InsertForm,
form: Self::InsertForm,
) -> Result<Self, Error> {
use crate::schema::admin_purge_community::dsl::admin_purge_community;
let conn = &mut get_conn(pool).await?;
@ -412,7 +412,7 @@ impl Crud for AdminPurgePost {
type UpdateForm = AdminPurgePostForm;
type IdType = i32;
async fn create(pool: &mut DbPool<'_>, form: &Self::InsertForm) -> Result<Self, Error> {
async fn create(pool: &mut DbPool<'_>, form: Self::InsertForm) -> Result<Self, Error> {
use crate::schema::admin_purge_post::dsl::admin_purge_post;
let conn = &mut get_conn(pool).await?;
insert_into(admin_purge_post)
@ -424,7 +424,7 @@ impl Crud for AdminPurgePost {
async fn update(
pool: &mut DbPool<'_>,
from_id: i32,
form: &Self::InsertForm,
form: Self::InsertForm,
) -> Result<Self, Error> {
use crate::schema::admin_purge_post::dsl::admin_purge_post;
let conn = &mut get_conn(pool).await?;
@ -441,7 +441,7 @@ impl Crud for AdminPurgeComment {
type UpdateForm = AdminPurgeCommentForm;
type IdType = i32;
async fn create(pool: &mut DbPool<'_>, form: &Self::InsertForm) -> Result<Self, Error> {
async fn create(pool: &mut DbPool<'_>, form: Self::InsertForm) -> Result<Self, Error> {
use crate::schema::admin_purge_comment::dsl::admin_purge_comment;
let conn = &mut get_conn(pool).await?;
insert_into(admin_purge_comment)
@ -453,7 +453,7 @@ impl Crud for AdminPurgeComment {
async fn update(
pool: &mut DbPool<'_>,
from_id: i32,
form: &Self::InsertForm,
form: Self::InsertForm,
) -> Result<Self, Error> {
use crate::schema::admin_purge_comment::dsl::admin_purge_comment;
let conn = &mut get_conn(pool).await?;

View File

@ -25,7 +25,7 @@ impl Crud for PasswordResetRequest {
type UpdateForm = PasswordResetRequestForm;
type IdType = i32;
async fn create(pool: &mut DbPool<'_>, form: &PasswordResetRequestForm) -> Result<Self, Error> {
async fn create(pool: &mut DbPool<'_>, form: PasswordResetRequestForm) -> Result<Self, Error> {
let conn = &mut get_conn(pool).await?;
insert_into(password_reset_request)
.values(form)
@ -35,7 +35,7 @@ impl Crud for PasswordResetRequest {
async fn update(
pool: &mut DbPool<'_>,
password_reset_request_id: i32,
form: &PasswordResetRequestForm,
form: PasswordResetRequestForm,
) -> Result<Self, Error> {
let conn = &mut get_conn(pool).await?;
diesel::update(password_reset_request.find(password_reset_request_id))
@ -60,7 +60,7 @@ impl PasswordResetRequest {
token_encrypted: token_hash,
};
Self::create(pool, &form).await
Self::create(pool, form).await
}
pub async fn read_from_token(
pool: &mut DbPool<'_>,

View File

@ -28,7 +28,7 @@ impl Crud for Person {
.await
}
async fn create(pool: &mut DbPool<'_>, form: &PersonInsertForm) -> Result<Self, Error> {
async fn create(pool: &mut DbPool<'_>, form: PersonInsertForm) -> Result<Self, Error> {
let conn = &mut get_conn(pool).await?;
insert_into(person::table)
.values(form)
@ -38,7 +38,7 @@ impl Crud for Person {
async fn update(
pool: &mut DbPool<'_>,
person_id: PersonId,
form: &PersonUpdateForm,
form: PersonUpdateForm,
) -> Result<Self, Error> {
let conn = &mut get_conn(pool).await?;
diesel::update(person::table.find(person_id))
@ -151,7 +151,7 @@ impl ApubActor for Person {
#[async_trait]
impl Followable for PersonFollower {
type Form = PersonFollowerForm;
async fn follow(pool: &mut DbPool<'_>, form: &PersonFollowerForm) -> Result<Self, Error> {
async fn follow(pool: &mut DbPool<'_>, form: PersonFollowerForm) -> Result<Self, Error> {
use crate::schema::person_follower::dsl::{follower_id, person_follower, person_id};
let conn = &mut get_conn(pool).await?;
insert_into(person_follower)
@ -165,7 +165,7 @@ impl Followable for PersonFollower {
async fn follow_accepted(_: &mut DbPool<'_>, _: CommunityId, _: PersonId) -> Result<Self, Error> {
unimplemented!()
}
async fn unfollow(pool: &mut DbPool<'_>, form: &PersonFollowerForm) -> Result<usize, Error> {
async fn unfollow(pool: &mut DbPool<'_>, form: PersonFollowerForm) -> Result<usize, Error> {
use crate::schema::person_follower::dsl::{follower_id, person_follower, person_id};
let conn = &mut get_conn(pool).await?;
diesel::delete(

View File

@ -26,10 +26,7 @@ impl PersonBlock {
#[async_trait]
impl Blockable for PersonBlock {
type Form = PersonBlockForm;
async fn block(
pool: &mut DbPool<'_>,
person_block_form: &PersonBlockForm,
) -> Result<Self, Error> {
async fn block(pool: &mut DbPool<'_>, person_block_form: PersonBlockForm) -> Result<Self, Error> {
let conn = &mut get_conn(pool).await?;
insert_into(person_block)
.values(person_block_form)
@ -39,7 +36,7 @@ impl Blockable for PersonBlock {
.get_result::<Self>(conn)
.await
}
async fn unblock(pool: &mut DbPool<'_>, person_block_form: &Self::Form) -> Result<usize, Error> {
async fn unblock(pool: &mut DbPool<'_>, person_block_form: Self::Form) -> Result<usize, Error> {
let conn = &mut get_conn(pool).await?;
diesel::delete(
person_block

View File

@ -16,7 +16,7 @@ impl Crud for PersonMention {
async fn create(
pool: &mut DbPool<'_>,
person_mention_form: &Self::InsertForm,
person_mention_form: Self::InsertForm,
) -> Result<Self, Error> {
let conn = &mut get_conn(pool).await?;
// since the return here isnt utilized, we dont need to do an update
@ -33,7 +33,7 @@ impl Crud for PersonMention {
async fn update(
pool: &mut DbPool<'_>,
person_mention_id: PersonMentionId,
person_mention_form: &Self::UpdateForm,
person_mention_form: Self::UpdateForm,
) -> Result<Self, Error> {
let conn = &mut get_conn(pool).await?;
diesel::update(person_mention.find(person_mention_id))

View File

@ -39,7 +39,7 @@ impl Crud for Post {
type UpdateForm = PostUpdateForm;
type IdType = PostId;
async fn create(pool: &mut DbPool<'_>, form: &Self::InsertForm) -> Result<Self, Error> {
async fn create(pool: &mut DbPool<'_>, form: Self::InsertForm) -> Result<Self, Error> {
let conn = &mut get_conn(pool).await?;
insert_into(post)
.values(form)
@ -53,7 +53,7 @@ impl Crud for Post {
async fn update(
pool: &mut DbPool<'_>,
post_id: PostId,
new_post: &Self::UpdateForm,
new_post: Self::UpdateForm,
) -> Result<Self, Error> {
let conn = &mut get_conn(pool).await?;
diesel::update(post.find(post_id))
@ -229,7 +229,7 @@ impl Post {
impl Likeable for PostLike {
type Form = PostLikeForm;
type IdType = PostId;
async fn like(pool: &mut DbPool<'_>, post_like_form: &PostLikeForm) -> Result<Self, Error> {
async fn like(pool: &mut DbPool<'_>, post_like_form: PostLikeForm) -> Result<Self, Error> {
use crate::schema::post_like::dsl::{person_id, post_id, post_like};
let conn = &mut get_conn(pool).await?;
insert_into(post_like)
@ -260,7 +260,7 @@ impl Likeable for PostLike {
#[async_trait]
impl Saveable for PostSaved {
type Form = PostSavedForm;
async fn save(pool: &mut DbPool<'_>, post_saved_form: &PostSavedForm) -> Result<Self, Error> {
async fn save(pool: &mut DbPool<'_>, post_saved_form: PostSavedForm) -> Result<Self, Error> {
use crate::schema::post_saved::dsl::{person_id, post_id, post_saved};
let conn = &mut get_conn(pool).await?;
insert_into(post_saved)
@ -271,7 +271,7 @@ impl Saveable for PostSaved {
.get_result::<Self>(conn)
.await
}
async fn unsave(pool: &mut DbPool<'_>, post_saved_form: &PostSavedForm) -> Result<usize, Error> {
async fn unsave(pool: &mut DbPool<'_>, post_saved_form: PostSavedForm) -> Result<usize, Error> {
use crate::schema::post_saved::dsl::{person_id, post_id, post_saved};
let conn = &mut get_conn(pool).await?;
diesel::delete(
@ -289,7 +289,7 @@ impl Readable for PostRead {
type Form = PostReadForm;
async fn mark_as_read(
pool: &mut DbPool<'_>,
post_read_form: &PostReadForm,
post_read_form: PostReadForm,
) -> Result<Self, Error> {
use crate::schema::post_read::dsl::{person_id, post_id, post_read};
let conn = &mut get_conn(pool).await?;
@ -304,7 +304,7 @@ impl Readable for PostRead {
async fn mark_as_unread(
pool: &mut DbPool<'_>,
post_read_form: &PostReadForm,
post_read_form: PostReadForm,
) -> Result<usize, Error> {
use crate::schema::post_read::dsl::{person_id, post_id, post_read};
let conn = &mut get_conn(pool).await?;

View File

@ -18,7 +18,7 @@ impl Reportable for PostReport {
type Form = PostReportForm;
type IdType = PostReportId;
async fn report(pool: &mut DbPool<'_>, post_report_form: &PostReportForm) -> Result<Self, Error> {
async fn report(pool: &mut DbPool<'_>, post_report_form: PostReportForm) -> Result<Self, Error> {
let conn = &mut get_conn(pool).await?;
insert_into(post_report)
.values(post_report_form)

View File

@ -16,7 +16,7 @@ impl Crud for PrivateMessage {
type UpdateForm = PrivateMessageUpdateForm;
type IdType = PrivateMessageId;
async fn create(pool: &mut DbPool<'_>, form: &Self::InsertForm) -> Result<Self, Error> {
async fn create(pool: &mut DbPool<'_>, form: Self::InsertForm) -> Result<Self, Error> {
let conn = &mut get_conn(pool).await?;
insert_into(private_message)
.values(form)
@ -30,7 +30,7 @@ impl Crud for PrivateMessage {
async fn update(
pool: &mut DbPool<'_>,
private_message_id: PrivateMessageId,
form: &Self::UpdateForm,
form: Self::UpdateForm,
) -> Result<Self, Error> {
let conn = &mut get_conn(pool).await?;
diesel::update(private_message.find(private_message_id))

View File

@ -20,7 +20,7 @@ impl Reportable for PrivateMessageReport {
async fn report(
pool: &mut DbPool<'_>,
pm_report_form: &PrivateMessageReportForm,
pm_report_form: PrivateMessageReportForm,
) -> Result<Self, Error> {
let conn = &mut get_conn(pool).await?;
insert_into(private_message_report)

View File

@ -18,7 +18,7 @@ impl Crud for RegistrationApplication {
type UpdateForm = RegistrationApplicationUpdateForm;
type IdType = i32;
async fn create(pool: &mut DbPool<'_>, form: &Self::InsertForm) -> Result<Self, Error> {
async fn create(pool: &mut DbPool<'_>, form: Self::InsertForm) -> Result<Self, Error> {
let conn = &mut get_conn(pool).await?;
insert_into(registration_application)
.values(form)
@ -29,7 +29,7 @@ impl Crud for RegistrationApplication {
async fn update(
pool: &mut DbPool<'_>,
id_: Self::IdType,
form: &Self::UpdateForm,
form: Self::UpdateForm,
) -> Result<Self, Error> {
let conn = &mut get_conn(pool).await?;
diesel::update(registration_application.find(id_))

View File

@ -18,7 +18,7 @@ impl Crud for Site {
type UpdateForm = SiteUpdateForm;
type IdType = SiteId;
async fn create(pool: &mut DbPool<'_>, form: &Self::InsertForm) -> Result<Self, Error> {
async fn create(pool: &mut DbPool<'_>, form: Self::InsertForm) -> Result<Self, Error> {
let is_new_site = match &form.actor_id {
Some(id_) => Site::read_from_apub_id(pool, id_).await?.is_none(),
None => true,
@ -45,7 +45,7 @@ impl Crud for Site {
async fn update(
pool: &mut DbPool<'_>,
site_id: SiteId,
new_site: &Self::UpdateForm,
new_site: Self::UpdateForm,
) -> Result<Self, Error> {
let conn = &mut get_conn(pool).await?;
diesel::update(site.find(site_id))

View File

@ -57,7 +57,7 @@ where
+ Sized
+ Send
+ AsExpression<<<Self::Table as Table>::PrimaryKey as Expression>::SqlType>;
async fn create(pool: &mut DbPool<'_>, form: &Self::InsertForm) -> Result<Self, Error>;
async fn create(pool: &mut DbPool<'_>, form: Self::InsertForm) -> Result<Self, Error>;
/*{
let query = insert_into(Self::table()).values(form);
let conn = &mut *get_conn(pool).await?;
@ -72,7 +72,7 @@ where
async fn update(
pool: &mut DbPool<'_>,
id: Self::IdType,
form: &Self::UpdateForm,
form: Self::UpdateForm,
) -> Result<Self, Error>;
/*{
let conn = &mut get_conn(pool).await?;
@ -97,7 +97,7 @@ where
//type FollowerColumn: Column + Default + Send;
//type TargetColumn: Column + Default + Send;
type Form;
async fn follow(pool: &mut DbPool<'_>, form: &Self::Form) -> Result<Self, Error>
async fn follow(pool: &mut DbPool<'_>, form: Self::Form) -> Result<Self, Error>
where
Self: Sized;
/*{
@ -120,7 +120,7 @@ where
) -> Result<Self, Error>
where
Self: Sized;
async fn unfollow(pool: &mut DbPool<'_>, form: &Self::Form) -> Result<usize, Error>
async fn unfollow(pool: &mut DbPool<'_>, form: Self::Form) -> Result<usize, Error>
where
Self: Sized;
}
@ -128,10 +128,10 @@ where
#[async_trait]
pub trait Joinable {
type Form;
async fn join(pool: &mut DbPool<'_>, form: &Self::Form) -> Result<Self, Error>
async fn join(pool: &mut DbPool<'_>, form: Self::Form) -> Result<Self, Error>
where
Self: Sized;
async fn leave(pool: &mut DbPool<'_>, form: &Self::Form) -> Result<usize, Error>
async fn leave(pool: &mut DbPool<'_>, form: Self::Form) -> Result<usize, Error>
where
Self: Sized;
}
@ -140,7 +140,7 @@ pub trait Joinable {
pub trait Likeable {
type Form;
type IdType;
async fn like(pool: &mut DbPool<'_>, form: &Self::Form) -> Result<Self, Error>
async fn like(pool: &mut DbPool<'_>, form: Self::Form) -> Result<Self, Error>
where
Self: Sized;
async fn remove(
@ -155,10 +155,10 @@ pub trait Likeable {
#[async_trait]
pub trait Bannable {
type Form;
async fn ban(pool: &mut DbPool<'_>, form: &Self::Form) -> Result<Self, Error>
async fn ban(pool: &mut DbPool<'_>, form: Self::Form) -> Result<Self, Error>
where
Self: Sized;
async fn unban(pool: &mut DbPool<'_>, form: &Self::Form) -> Result<usize, Error>
async fn unban(pool: &mut DbPool<'_>, form: Self::Form) -> Result<usize, Error>
where
Self: Sized;
}
@ -166,10 +166,10 @@ pub trait Bannable {
#[async_trait]
pub trait Saveable {
type Form;
async fn save(pool: &mut DbPool<'_>, form: &Self::Form) -> Result<Self, Error>
async fn save(pool: &mut DbPool<'_>, form: Self::Form) -> Result<Self, Error>
where
Self: Sized;
async fn unsave(pool: &mut DbPool<'_>, form: &Self::Form) -> Result<usize, Error>
async fn unsave(pool: &mut DbPool<'_>, form: Self::Form) -> Result<usize, Error>
where
Self: Sized;
}
@ -177,10 +177,10 @@ pub trait Saveable {
#[async_trait]
pub trait Blockable {
type Form;
async fn block(pool: &mut DbPool<'_>, form: &Self::Form) -> Result<Self, Error>
async fn block(pool: &mut DbPool<'_>, form: Self::Form) -> Result<Self, Error>
where
Self: Sized;
async fn unblock(pool: &mut DbPool<'_>, form: &Self::Form) -> Result<usize, Error>
async fn unblock(pool: &mut DbPool<'_>, form: Self::Form) -> Result<usize, Error>
where
Self: Sized;
}
@ -188,10 +188,10 @@ pub trait Blockable {
#[async_trait]
pub trait Readable {
type Form;
async fn mark_as_read(pool: &mut DbPool<'_>, form: &Self::Form) -> Result<Self, Error>
async fn mark_as_read(pool: &mut DbPool<'_>, form: Self::Form) -> Result<Self, Error>
where
Self: Sized;
async fn mark_as_unread(pool: &mut DbPool<'_>, form: &Self::Form) -> Result<usize, Error>
async fn mark_as_unread(pool: &mut DbPool<'_>, form: Self::Form) -> Result<usize, Error>
where
Self: Sized;
}
@ -200,7 +200,7 @@ pub trait Readable {
pub trait Reportable {
type Form;
type IdType;
async fn report(pool: &mut DbPool<'_>, form: &Self::Form) -> Result<Self, Error>
async fn report(pool: &mut DbPool<'_>, form: Self::Form) -> Result<Self, Error>
where
Self: Sized;
async fn resolve(

View File

@ -88,7 +88,7 @@ async fn user_updates_2020_04_02(
.last_refreshed_at(Some(naive_now()))
.build();
Person::update(pool, cperson.id, &form).await?;
Person::update(pool, cperson.id, form).await?;
}
info!("{} person rows updated.", incorrect_persons.len());
@ -127,7 +127,7 @@ async fn community_updates_2020_04_02(
.last_refreshed_at(Some(naive_now()))
.build();
Community::update(pool, ccommunity.id, &form).await?;
Community::update(pool, ccommunity.id, form).await?;
}
info!("{} community rows updated.", incorrect_communities.len());
@ -383,7 +383,7 @@ async fn regenerate_public_keys_2022_07_05(pool: &mut DbPool<'_>) -> Result<(),
.public_key(Some(key_pair.public_key))
.private_key(Some(Some(key_pair.private_key)))
.build();
Community::update(&mut conn.into(), community_.id, &form).await?;
Community::update(&mut conn.into(), community_.id, form).await?;
}
}
@ -405,7 +405,7 @@ async fn regenerate_public_keys_2022_07_05(pool: &mut DbPool<'_>) -> Result<(),
.public_key(Some(key_pair.public_key))
.private_key(Some(Some(key_pair.private_key)))
.build();
Person::update(pool, person_.id, &form).await?;
Person::update(pool, person_.id, form).await?;
}
}
Ok(())