Merge different AlreadyExists errors (fixes #5897) (#5900)

* Merge different `AlreadyExists` errors (fixes #5897)

* rename email errors

* Merge CouldntCreate and CouldntUpdate errors
This commit is contained in:
Nutomic 2025-07-30 15:39:23 +00:00 committed by GitHub
parent 5dcf69f0b5
commit 3dacf7e2be
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
47 changed files with 180 additions and 239 deletions

View file

@ -394,7 +394,7 @@ test("Delete a post", async () => {
// Make sure lemmy beta cannot delete the post
await expect(deletePost(beta, true, betaPost2.post)).rejects.toStrictEqual(
new LemmyError("no_post_edit_allowed"),
new LemmyError("couldnt_update"),
);
});

View file

@ -32,7 +32,7 @@ pub async fn create_pm_report(
// Make sure that only the recipient of the private message can create a report
if person.id != private_message.recipient_id {
Err(LemmyErrorType::CouldntCreateReport)?
Err(LemmyErrorType::CouldntCreate)?
}
let report_form = PrivateMessageReportForm {

View file

@ -86,7 +86,7 @@ pub async fn create_comment(
// Strange issue where sometimes the post ID of the parent comment is incorrect
if let Some(parent) = parent_opt.as_ref() {
if parent.post_id != post_id {
Err(LemmyErrorType::CouldntCreateComment)?
Err(LemmyErrorType::CouldntCreate)?
}
check_comment_depth(parent)?;
}

View file

@ -34,7 +34,7 @@ pub async fn delete_comment(
// Dont delete it if its already been deleted.
if orig_comment.comment.deleted == data.deleted {
Err(LemmyErrorType::CouldntUpdateComment)?
Err(LemmyErrorType::CouldntUpdate)?
}
check_community_user_action(

View file

@ -56,7 +56,7 @@ pub async fn remove_comment(
// Don't allow removing or restoring comment which was deleted by user, as it would reveal
// the comment text in mod log.
if orig_comment.comment.deleted {
return Err(LemmyErrorType::CouldntUpdateComment.into());
return Err(LemmyErrorType::CouldntUpdate.into());
}
// Do the remove

View file

@ -81,7 +81,7 @@ pub async fn create_community(
let community_ap_id = Community::generate_local_actor_url(&data.name, context.settings())?;
let community_dupe = Community::read_from_apub_id(&mut context.pool(), &community_ap_id).await?;
if community_dupe.is_some() {
Err(LemmyErrorType::CommunityAlreadyExists)?
Err(LemmyErrorType::AlreadyExists)?
}
let keypair = generate_actor_keypair()?;

View file

@ -27,7 +27,7 @@ pub async fn delete_post(
// Dont delete it if its already been deleted.
if orig_post.deleted == data.deleted {
Err(LemmyErrorType::CouldntUpdatePost)?
Err(LemmyErrorType::CouldntUpdate)?
}
let community = Community::read(&mut context.pool(), orig_post.community_id).await?;

View file

@ -147,7 +147,7 @@ pub async fn create_site(
fn validate_create_payload(local_site: &LocalSite, create_site: &CreateSite) -> LemmyResult<()> {
// Make sure the site hasn't already been set up...
if local_site.site_setup {
Err(LemmyErrorType::SiteAlreadyExists)?
Err(LemmyErrorType::AlreadyExists)?
};
// Check that the slur regex compiles, and returns the regex if valid...
@ -197,7 +197,7 @@ mod tests {
let invalid_payloads = [
(
"CreateSite attempted on set up LocalSite",
LemmyErrorType::SiteAlreadyExists,
LemmyErrorType::AlreadyExists,
&LocalSite {
site_setup: true,
private_instance: true,

View file

@ -335,7 +335,7 @@ pub async fn authenticate_with_oauth(
user_view.local_user.clone()
} else {
return Err(LemmyErrorType::EmailAlreadyExists)?;
return Err(LemmyErrorType::EmailAlreadyTaken)?;
}
} else {
// No user was found by email => Register as new user

View file

@ -359,7 +359,7 @@ pub fn check_private_instance(
/// If private messages are disabled, dont allow them to be sent / received
pub fn check_private_messages_enabled(local_user_view: &LocalUserView) -> Result<(), LemmyError> {
if !local_user_view.local_user.enable_private_messages {
Err(LemmyErrorType::CouldntCreatePrivateMessage)?
Err(LemmyErrorType::CouldntCreate)?
} else {
Ok(())
}
@ -746,12 +746,12 @@ pub async fn purge_user_account(
// Comments
Comment::permadelete_for_creator(pool, person_id)
.await
.with_lemmy_type(LemmyErrorType::CouldntUpdateComment)?;
.with_lemmy_type(LemmyErrorType::CouldntUpdate)?;
// Posts
Post::permadelete_for_creator(pool, person_id)
.await
.with_lemmy_type(LemmyErrorType::CouldntUpdatePost)?;
.with_lemmy_type(LemmyErrorType::CouldntUpdate)?;
// Leave communities they mod
CommunityActions::leave_mod_team_for_all_communities(pool, person_id).await?;

View file

@ -16,7 +16,7 @@ impl SentActivity {
.values(form)
.get_result::<Self>(conn)
.await
.with_lemmy_type(LemmyErrorType::CouldntInsertActivity)
.with_lemmy_type(LemmyErrorType::CouldntCreate)
}
pub async fn read_from_apub_id(pool: &mut DbPool<'_>, object_id: &DbUrl) -> LemmyResult<Self> {
@ -53,7 +53,7 @@ impl ReceivedActivity {
// new activity inserted successfully
Ok(())
} else {
Err(LemmyErrorType::CouldntInsertActivity.into())
Err(LemmyErrorType::CouldntCreate.into())
}
}
}

View file

@ -78,7 +78,7 @@ impl LocalUserLanguage {
.filter(local_user_language::language_id.ne_all(&lang_ids))
.execute(conn)
.await
.with_lemmy_type(LemmyErrorType::CouldntUpdateLanguages)?;
.with_lemmy_type(LemmyErrorType::CouldntUpdate)?;
let forms = lang_ids
.iter()
@ -98,7 +98,7 @@ impl LocalUserLanguage {
.do_nothing()
.execute(conn)
.await
.with_lemmy_type(LemmyErrorType::CouldntUpdateLanguages)
.with_lemmy_type(LemmyErrorType::CouldntUpdate)
}
.scope_boxed()
})
@ -156,7 +156,7 @@ impl SiteLanguage {
.filter(site_language::language_id.ne_all(&lang_ids))
.execute(conn)
.await
.with_lemmy_type(LemmyErrorType::CouldntUpdateLanguages)?;
.with_lemmy_type(LemmyErrorType::CouldntUpdate)?;
let forms = lang_ids
.iter()
@ -173,7 +173,7 @@ impl SiteLanguage {
.do_nothing()
.execute(conn)
.await
.with_lemmy_type(LemmyErrorType::CouldntUpdateLanguages)?;
.with_lemmy_type(LemmyErrorType::CouldntUpdate)?;
CommunityLanguage::limit_languages(conn, instance_id).await?;
@ -291,7 +291,7 @@ impl CommunityLanguage {
.filter(community_language::language_id.ne_all(&lang_ids))
.execute(conn)
.await
.with_lemmy_type(LemmyErrorType::CouldntUpdateLanguages)?;
.with_lemmy_type(LemmyErrorType::CouldntUpdate)?;
// Insert new languages
insert_into(community_language::table)
@ -303,7 +303,7 @@ impl CommunityLanguage {
.do_nothing()
.execute(conn)
.await
.with_lemmy_type(LemmyErrorType::CouldntUpdateLanguages)
.with_lemmy_type(LemmyErrorType::CouldntUpdate)
}
.scope_boxed()
})

View file

@ -15,7 +15,7 @@ impl CaptchaAnswer {
.values(captcha)
.get_result::<Self>(conn)
.await
.with_lemmy_type(LemmyErrorType::CouldntCreateCaptchaAnswer)
.with_lemmy_type(LemmyErrorType::CouldntCreate)
}
pub async fn check_captcha(

View file

@ -52,7 +52,7 @@ impl Comment {
))
.get_results::<Self>(conn)
.await
.with_lemmy_type(LemmyErrorType::CouldntUpdateComment)
.with_lemmy_type(LemmyErrorType::CouldntUpdate)
}
pub async fn update_removed_for_creator(
@ -68,7 +68,7 @@ impl Comment {
))
.get_results::<Self>(conn)
.await
.with_lemmy_type(LemmyErrorType::CouldntUpdateComment)
.with_lemmy_type(LemmyErrorType::CouldntUpdate)
}
/// Diesel can't update from join unfortunately, so you'll need to loop over these
@ -178,14 +178,13 @@ impl Comment {
.set(comment_form)
.get_result::<Self>(conn)
.await
.with_lemmy_type(LemmyErrorType::CouldntCreateComment)
} else {
insert_into(comment::table)
.values(comment_form)
.get_result::<Self>(conn)
.await
.with_lemmy_type(LemmyErrorType::CouldntCreateComment)
}
.with_lemmy_type(LemmyErrorType::CouldntCreate)
}
pub async fn read_from_apub_id(
@ -219,7 +218,7 @@ impl Comment {
.set(comment::hot_rank.eq(hot_rank(comment::score, comment::published_at)))
.get_result::<Self>(conn)
.await
.with_lemmy_type(LemmyErrorType::CouldntUpdateComment)
.with_lemmy_type(LemmyErrorType::CouldntUpdate)
}
pub fn local_url(&self, settings: &Settings) -> LemmyResult<Url> {
let domain = settings.get_protocol_and_hostname();
@ -260,7 +259,7 @@ impl Crud for Comment {
.set(comment_form)
.get_result::<Self>(conn)
.await
.with_lemmy_type(LemmyErrorType::CouldntUpdateComment)
.with_lemmy_type(LemmyErrorType::CouldntUpdate)
}
}
@ -271,7 +270,7 @@ impl Likeable for CommentActions {
async fn like(pool: &mut DbPool<'_>, form: &Self::Form) -> LemmyResult<Self> {
let conn = &mut get_conn(pool).await?;
validate_like(form.like_score).with_lemmy_type(LemmyErrorType::CouldntLikeComment)?;
validate_like(form.like_score).with_lemmy_type(LemmyErrorType::CouldntCreate)?;
insert_into(comment_actions::table)
.values(form)
@ -281,7 +280,7 @@ impl Likeable for CommentActions {
.returning(Self::as_select())
.get_result::<Self>(conn)
.await
.with_lemmy_type(LemmyErrorType::CouldntLikeComment)
.with_lemmy_type(LemmyErrorType::CouldntCreate)
}
async fn remove_like(
pool: &mut DbPool<'_>,
@ -294,7 +293,7 @@ impl Likeable for CommentActions {
.set_null(comment_actions::liked_at)
.get_result(conn)
.await
.with_lemmy_type(LemmyErrorType::CouldntLikeComment)
.with_lemmy_type(LemmyErrorType::CouldntCreate)
}
async fn remove_all_likes(
@ -308,7 +307,7 @@ impl Likeable for CommentActions {
.set_null(comment_actions::liked_at)
.get_result(conn)
.await
.with_lemmy_type(LemmyErrorType::CouldntUpdateComment)
.with_lemmy_type(LemmyErrorType::CouldntUpdate)
}
async fn remove_likes_in_community(
@ -326,7 +325,7 @@ impl Likeable for CommentActions {
.set_null(comment_actions::liked_at)
.get_result(conn)
.await
.with_lemmy_type(LemmyErrorType::CouldntUpdateComment)
.with_lemmy_type(LemmyErrorType::CouldntUpdate)
}
}
@ -342,7 +341,7 @@ impl Saveable for CommentActions {
.returning(Self::as_select())
.get_result::<Self>(conn)
.await
.with_lemmy_type(LemmyErrorType::CouldntSaveComment)
.with_lemmy_type(LemmyErrorType::CouldntCreate)
}
async fn unsave(pool: &mut DbPool<'_>, form: &Self::Form) -> LemmyResult<UpleteCount> {
let conn = &mut get_conn(pool).await?;
@ -350,7 +349,7 @@ impl Saveable for CommentActions {
.set_null(comment_actions::saved_at)
.get_result(conn)
.await
.with_lemmy_type(LemmyErrorType::CouldntSaveComment)
.with_lemmy_type(LemmyErrorType::CouldntUpdate)
}
}

View file

@ -29,7 +29,7 @@ impl Reportable for CommentReport {
.values(form)
.get_result::<Self>(conn)
.await
.with_lemmy_type(LemmyErrorType::CouldntCreateReport)
.with_lemmy_type(LemmyErrorType::CouldntCreate)
}
/// resolve a comment report
@ -52,7 +52,7 @@ impl Reportable for CommentReport {
))
.execute(conn)
.await
.with_lemmy_type(LemmyErrorType::CouldntResolveReport)
.with_lemmy_type(LemmyErrorType::CouldntUpdate)
}
async fn resolve_apub(
@ -76,7 +76,7 @@ impl Reportable for CommentReport {
))
.execute(conn)
.await
.with_lemmy_type(LemmyErrorType::CouldntResolveReport)
.with_lemmy_type(LemmyErrorType::CouldntUpdate)
}
async fn resolve_all_for_object(
@ -93,6 +93,6 @@ impl Reportable for CommentReport {
))
.execute(conn)
.await
.with_lemmy_type(LemmyErrorType::CouldntResolveReport)
.with_lemmy_type(LemmyErrorType::CouldntUpdate)
}
}

View file

@ -78,7 +78,7 @@ impl Crud for Community {
.set(form)
.get_result::<Self>(conn)
.await
.with_lemmy_type(LemmyErrorType::CouldntUpdateCommunity)
.with_lemmy_type(LemmyErrorType::CouldntUpdate)
}
}
@ -96,7 +96,7 @@ impl CommunityActions {
.returning(Self::as_select())
.get_result::<Self>(conn)
.await
.with_lemmy_type(LemmyErrorType::CommunityModeratorAlreadyExists)
.with_lemmy_type(LemmyErrorType::AlreadyExists)
}
pub async fn leave(
@ -108,7 +108,7 @@ impl CommunityActions {
.set_null(community_actions::became_moderator_at)
.get_result(conn)
.await
.with_lemmy_type(LemmyErrorType::CommunityModeratorAlreadyExists)
.with_lemmy_type(LemmyErrorType::AlreadyExists)
}
}
@ -276,7 +276,7 @@ impl Community {
.set(community::dsl::subscribers.eq(new_subscribers))
.get_result(conn)
.await
.with_lemmy_type(LemmyErrorType::CouldntUpdateCommunity)
.with_lemmy_type(LemmyErrorType::CouldntUpdate)
}
}
@ -480,7 +480,7 @@ impl Bannable for CommunityActions {
.returning(Self::as_select())
.get_result::<Self>(conn)
.await
.with_lemmy_type(LemmyErrorType::CommunityUserAlreadyBanned)
.with_lemmy_type(LemmyErrorType::CouldntUpdate)
}
async fn unban(pool: &mut DbPool<'_>, form: &Self::Form) -> LemmyResult<UpleteCount> {
@ -490,7 +490,7 @@ impl Bannable for CommunityActions {
.set_null(community_actions::ban_expires_at)
.get_result(conn)
.await
.with_lemmy_type(LemmyErrorType::CommunityUserAlreadyBanned)
.with_lemmy_type(LemmyErrorType::CouldntUpdate)
}
}
@ -511,7 +511,7 @@ impl Followable for CommunityActions {
.returning(Self::as_select())
.get_result::<Self>(conn)
.await
.with_lemmy_type(LemmyErrorType::CommunityFollowerAlreadyExists)
.with_lemmy_type(LemmyErrorType::CouldntUpdate)
}
async fn follow_accepted(
pool: &mut DbPool<'_>,
@ -527,7 +527,7 @@ impl Followable for CommunityActions {
.returning(Self::as_select())
.get_result::<Self>(conn)
.await
.with_lemmy_type(LemmyErrorType::CommunityFollowerAlreadyExists)
.with_lemmy_type(LemmyErrorType::CouldntUpdate)
}
async fn unfollow(
@ -542,7 +542,7 @@ impl Followable for CommunityActions {
.set_null(community_actions::follow_approver_id)
.get_result(conn)
.await
.with_lemmy_type(LemmyErrorType::CommunityFollowerAlreadyExists)
.with_lemmy_type(LemmyErrorType::CouldntUpdate)
}
}
@ -564,7 +564,7 @@ impl Blockable for CommunityActions {
.returning(Self::as_select())
.get_result::<Self>(conn)
.await
.with_lemmy_type(LemmyErrorType::CommunityBlockAlreadyExists)
.with_lemmy_type(LemmyErrorType::CouldntUpdate)
}
async fn unblock(
pool: &mut DbPool<'_>,
@ -578,7 +578,7 @@ impl Blockable for CommunityActions {
.set_null(community_actions::blocked_at)
.get_result(conn)
.await
.with_lemmy_type(LemmyErrorType::CommunityBlockAlreadyExists)
.with_lemmy_type(LemmyErrorType::CouldntUpdate)
}
async fn read_block(

View file

@ -29,7 +29,7 @@ impl Reportable for CommunityReport {
.values(form)
.get_result::<Self>(conn)
.await
.with_lemmy_type(LemmyErrorType::CouldntCreateReport)
.with_lemmy_type(LemmyErrorType::CouldntCreate)
}
/// resolve a community report
@ -52,7 +52,7 @@ impl Reportable for CommunityReport {
))
.execute(conn)
.await
.with_lemmy_type(LemmyErrorType::CouldntResolveReport)
.with_lemmy_type(LemmyErrorType::CouldntUpdate)
}
async fn resolve_apub(
@ -76,7 +76,7 @@ impl Reportable for CommunityReport {
))
.execute(conn)
.await
.with_lemmy_type(LemmyErrorType::CouldntResolveReport)
.with_lemmy_type(LemmyErrorType::CouldntUpdate)
}
async fn resolve_all_for_object(
@ -93,6 +93,6 @@ impl Reportable for CommunityReport {
))
.execute(conn)
.await
.with_lemmy_type(LemmyErrorType::CouldntResolveReport)
.with_lemmy_type(LemmyErrorType::CouldntUpdate)
}
}

View file

@ -26,7 +26,7 @@ impl Crud for CustomEmoji {
.values(form)
.get_result::<Self>(conn)
.await
.with_lemmy_type(LemmyErrorType::CouldntCreateEmoji)
.with_lemmy_type(LemmyErrorType::CouldntCreate)
}
async fn update(
@ -39,7 +39,7 @@ impl Crud for CustomEmoji {
.set(new_custom_emoji)
.get_result::<Self>(conn)
.await
.with_lemmy_type(LemmyErrorType::CouldntUpdateEmoji)
.with_lemmy_type(LemmyErrorType::CouldntUpdate)
}
}
@ -53,7 +53,7 @@ impl CustomEmojiKeyword {
.values(form)
.get_results::<Self>(conn)
.await
.with_lemmy_type(LemmyErrorType::CouldntCreateEmoji)
.with_lemmy_type(LemmyErrorType::CouldntCreate)
}
pub async fn delete(pool: &mut DbPool<'_>, emoji_id: CustomEmojiId) -> LemmyResult<usize> {
let conn = &mut get_conn(pool).await?;

View file

@ -15,7 +15,7 @@ impl EmailVerification {
.values(form)
.get_result(conn)
.await
.with_lemmy_type(LemmyErrorType::CouldntCreateEmailVerification)
.with_lemmy_type(LemmyErrorType::CouldntCreate)
}
pub async fn read_for_token(pool: &mut DbPool<'_>, token: &str) -> LemmyResult<Self> {

View file

@ -15,7 +15,7 @@ impl FederationAllowList {
.values(form)
.get_result::<Self>(conn)
.await
.with_lemmy_type(LemmyErrorType::CouldntAllowInstance)
.with_lemmy_type(LemmyErrorType::CouldntCreate)
}
pub async fn unallow(pool: &mut DbPool<'_>, instance_id_: InstanceId) -> LemmyResult<usize> {
let conn = &mut get_conn(pool).await?;

View file

@ -15,7 +15,7 @@ impl FederationBlockList {
.values(form)
.get_result::<Self>(conn)
.await
.with_lemmy_type(LemmyErrorType::CouldntBlockInstance)
.with_lemmy_type(LemmyErrorType::CouldntCreate)
}
pub async fn unblock(pool: &mut DbPool<'_>, instance_id_: InstanceId) -> LemmyResult<usize> {
let conn = &mut get_conn(pool).await?;

View file

@ -38,6 +38,6 @@ impl FederationQueueState {
.set(state)
.execute(conn)
.await
.with_lemmy_type(LemmyErrorType::CouldntUpdateFederationQueueState)
.with_lemmy_type(LemmyErrorType::CouldntUpdate)
}
}

View file

@ -30,7 +30,7 @@ impl LocalImage {
.values(form)
.get_result::<Self>(conn)
.await
.with_lemmy_type(LemmyErrorType::CouldntCreateImage);
.with_lemmy_type(LemmyErrorType::CouldntCreate);
ImageDetails::create(&mut conn.into(), image_details_form).await?;
@ -91,7 +91,7 @@ impl RemoteImage {
.on_conflict_do_nothing()
.execute(conn)
.await
.with_lemmy_type(LemmyErrorType::CouldntCreateImage)
.with_lemmy_type(LemmyErrorType::CouldntCreate)
}
pub async fn validate(pool: &mut DbPool<'_>, link_: DbUrl) -> LemmyResult<()> {
@ -116,6 +116,6 @@ impl ImageDetails {
.on_conflict_do_nothing()
.execute(conn)
.await
.with_lemmy_type(LemmyErrorType::CouldntCreateImage)
.with_lemmy_type(LemmyErrorType::CouldntCreate)
}
}

View file

@ -74,7 +74,7 @@ impl Instance {
.set(&form)
.get_result::<Self>(conn)
.await
.with_lemmy_type(LemmyErrorType::CouldntCreateSite)
.with_lemmy_type(LemmyErrorType::CouldntCreate)
}
}
}
@ -97,7 +97,7 @@ impl Instance {
.set(form)
.execute(conn)
.await
.with_lemmy_type(LemmyErrorType::CouldntUpdateSite)
.with_lemmy_type(LemmyErrorType::CouldntUpdate)
}
pub async fn delete(pool: &mut DbPool<'_>, instance_id: InstanceId) -> LemmyResult<usize> {
@ -227,7 +227,7 @@ impl InstanceActions {
.returning(Self::as_select())
.get_result::<Self>(conn)
.await
.with_lemmy_type(LemmyErrorType::InstanceBlockCommunitiesAlreadyExists)
.with_lemmy_type(LemmyErrorType::AlreadyExists)
}
pub async fn unblock_communities(
@ -239,7 +239,7 @@ impl InstanceActions {
.set_null(instance_actions::blocked_communities_at)
.get_result(conn)
.await
.with_lemmy_type(LemmyErrorType::InstanceBlockCommunitiesAlreadyExists)
.with_lemmy_type(LemmyErrorType::AlreadyExists)
}
/// Checks to see if there's a block for the instances communities
@ -288,7 +288,7 @@ impl InstanceActions {
.returning(Self::as_select())
.get_result::<Self>(conn)
.await
.with_lemmy_type(LemmyErrorType::InstanceBlockPersonsAlreadyExists)
.with_lemmy_type(LemmyErrorType::AlreadyExists)
}
pub async fn unblock_persons(
@ -300,7 +300,7 @@ impl InstanceActions {
.set_null(instance_actions::blocked_persons_at)
.get_result(conn)
.await
.with_lemmy_type(LemmyErrorType::InstanceBlockPersonsAlreadyExists)
.with_lemmy_type(LemmyErrorType::AlreadyExists)
}
/// Checks to see if there's a block either from the instance person.

View file

@ -37,7 +37,7 @@ impl LocalUserKeywordBlock {
.filter(local_user_keyword_block::keyword.ne_all(&blocking_keywords))
.execute(conn)
.await
.with_lemmy_type(LemmyErrorType::CouldntUpdateKeywords)?;
.with_lemmy_type(LemmyErrorType::CouldntUpdate)?;
let forms = blocking_keywords
.into_iter()
.map(|k| LocalUserKeywordBlockForm {
@ -50,7 +50,7 @@ impl LocalUserKeywordBlock {
.on_conflict_do_nothing()
.execute(conn)
.await
.with_lemmy_type(LemmyErrorType::CouldntUpdateKeywords)
.with_lemmy_type(LemmyErrorType::CouldntUpdate)
}
.scope_boxed()
})

View file

@ -14,7 +14,7 @@ impl LocalSite {
.values(form)
.get_result::<Self>(conn)
.await
.with_lemmy_type(LemmyErrorType::CouldntCreateSite)
.with_lemmy_type(LemmyErrorType::CouldntCreate)
}
pub async fn update(pool: &mut DbPool<'_>, form: &LocalSiteUpdateForm) -> LemmyResult<Self> {
@ -23,7 +23,7 @@ impl LocalSite {
.set(form)
.get_result::<Self>(conn)
.await
.with_lemmy_type(LemmyErrorType::CouldntUpdateSite)
.with_lemmy_type(LemmyErrorType::CouldntUpdate)
}
pub async fn delete(pool: &mut DbPool<'_>) -> LemmyResult<usize> {

View file

@ -31,7 +31,7 @@ impl LocalSiteRateLimit {
.values(form)
.get_result::<Self>(conn)
.await
.with_lemmy_type(LemmyErrorType::CouldntCreateRateLimit)
.with_lemmy_type(LemmyErrorType::CouldntCreate)
}
pub async fn update(
pool: &mut DbPool<'_>,

View file

@ -28,7 +28,7 @@ impl LocalSiteUrlBlocklist {
.values(forms)
.execute(conn)
.await
.with_lemmy_type(LemmyErrorType::CouldntUpdateLocalSiteUrlBlocklist)
.with_lemmy_type(LemmyErrorType::CouldntUpdate)
}
.scope_boxed()
})

View file

@ -67,7 +67,7 @@ impl LocalUser {
Err(Error::QueryBuilderError(_)) => Ok(0),
other => other,
}
.with_lemmy_type(LemmyErrorType::CouldntUpdateUser)
.with_lemmy_type(LemmyErrorType::CouldntUpdate)
}
pub async fn delete(pool: &mut DbPool<'_>, id: LocalUserId) -> LemmyResult<usize> {
@ -90,7 +90,7 @@ impl LocalUser {
.set((local_user::password_encrypted.eq(password_hash),))
.get_result::<Self>(conn)
.await
.with_lemmy_type(LemmyErrorType::CouldntUpdateUser)
.with_lemmy_type(LemmyErrorType::CouldntUpdate)
}
pub async fn set_all_users_email_verified(pool: &mut DbPool<'_>) -> LemmyResult<Vec<Self>> {
@ -99,7 +99,7 @@ impl LocalUser {
.set(local_user::email_verified.eq(true))
.get_results::<Self>(conn)
.await
.with_lemmy_type(LemmyErrorType::CouldntUpdateUser)
.with_lemmy_type(LemmyErrorType::CouldntUpdate)
}
pub async fn set_all_users_registration_applications_accepted(
@ -110,7 +110,7 @@ impl LocalUser {
.set(local_user::accepted_application.eq(true))
.get_results::<Self>(conn)
.await
.with_lemmy_type(LemmyErrorType::CouldntUpdateUser)
.with_lemmy_type(LemmyErrorType::CouldntUpdate)
}
pub async fn delete_old_denied_local_users(pool: &mut DbPool<'_>) -> LemmyResult<usize> {
@ -150,7 +150,7 @@ impl LocalUser {
.get_result::<bool>(conn)
.await?
.then_some(())
.ok_or(LemmyErrorType::EmailAlreadyExists.into())
.ok_or(LemmyErrorType::EmailAlreadyTaken.into())
}
// TODO: maybe move this and pass in LocalUserView

View file

@ -16,7 +16,7 @@ impl LoginToken {
.values(form)
.get_result::<Self>(conn)
.await
.with_lemmy_type(LemmyErrorType::CouldntCreateLoginToken)
.with_lemmy_type(LemmyErrorType::CouldntCreate)
}
/// Check if the given token is valid for user.

View file

@ -59,7 +59,7 @@ impl Crud for AdminPurgePerson {
.values(form)
.get_result::<Self>(conn)
.await
.with_lemmy_type(LemmyErrorType::CouldntCreateModlog)
.with_lemmy_type(LemmyErrorType::CouldntCreate)
}
async fn update(
@ -72,7 +72,7 @@ impl Crud for AdminPurgePerson {
.set(form)
.get_result::<Self>(conn)
.await
.with_lemmy_type(LemmyErrorType::CouldntUpdateModlog)
.with_lemmy_type(LemmyErrorType::CouldntUpdate)
}
}
@ -87,7 +87,7 @@ impl Crud for AdminPurgeCommunity {
.values(form)
.get_result::<Self>(conn)
.await
.with_lemmy_type(LemmyErrorType::CouldntCreateModlog)
.with_lemmy_type(LemmyErrorType::CouldntCreate)
}
async fn update(
@ -100,7 +100,7 @@ impl Crud for AdminPurgeCommunity {
.set(form)
.get_result::<Self>(conn)
.await
.with_lemmy_type(LemmyErrorType::CouldntUpdateModlog)
.with_lemmy_type(LemmyErrorType::CouldntUpdate)
}
}
@ -115,7 +115,7 @@ impl Crud for AdminPurgePost {
.values(form)
.get_result::<Self>(conn)
.await
.with_lemmy_type(LemmyErrorType::CouldntCreateModlog)
.with_lemmy_type(LemmyErrorType::CouldntCreate)
}
async fn update(
@ -128,7 +128,7 @@ impl Crud for AdminPurgePost {
.set(form)
.get_result::<Self>(conn)
.await
.with_lemmy_type(LemmyErrorType::CouldntUpdateModlog)
.with_lemmy_type(LemmyErrorType::CouldntUpdate)
}
}
@ -143,7 +143,7 @@ impl Crud for AdminPurgeComment {
.values(form)
.get_result::<Self>(conn)
.await
.with_lemmy_type(LemmyErrorType::CouldntCreateModlog)
.with_lemmy_type(LemmyErrorType::CouldntCreate)
}
async fn update(
@ -156,7 +156,7 @@ impl Crud for AdminPurgeComment {
.set(form)
.get_result::<Self>(conn)
.await
.with_lemmy_type(LemmyErrorType::CouldntUpdateModlog)
.with_lemmy_type(LemmyErrorType::CouldntUpdate)
}
}
@ -171,7 +171,7 @@ impl Crud for AdminAllowInstance {
.values(form)
.get_result::<Self>(conn)
.await
.with_lemmy_type(LemmyErrorType::CouldntCreateModlog)
.with_lemmy_type(LemmyErrorType::CouldntCreate)
}
async fn update(
@ -184,7 +184,7 @@ impl Crud for AdminAllowInstance {
.set(form)
.get_result::<Self>(conn)
.await
.with_lemmy_type(LemmyErrorType::CouldntUpdateModlog)
.with_lemmy_type(LemmyErrorType::CouldntUpdate)
}
}
@ -199,7 +199,7 @@ impl Crud for AdminBlockInstance {
.values(form)
.get_result::<Self>(conn)
.await
.with_lemmy_type(LemmyErrorType::CouldntCreateModlog)
.with_lemmy_type(LemmyErrorType::CouldntCreate)
}
async fn update(
@ -212,7 +212,7 @@ impl Crud for AdminBlockInstance {
.set(form)
.get_result::<Self>(conn)
.await
.with_lemmy_type(LemmyErrorType::CouldntUpdateModlog)
.with_lemmy_type(LemmyErrorType::CouldntUpdate)
}
}
@ -227,7 +227,7 @@ impl Crud for AdminRemoveCommunity {
.values(form)
.get_result::<Self>(conn)
.await
.with_lemmy_type(LemmyErrorType::CouldntCreateModlog)
.with_lemmy_type(LemmyErrorType::CouldntCreate)
}
async fn update(
@ -240,7 +240,7 @@ impl Crud for AdminRemoveCommunity {
.set(form)
.get_result::<Self>(conn)
.await
.with_lemmy_type(LemmyErrorType::CouldntUpdateModlog)
.with_lemmy_type(LemmyErrorType::CouldntUpdate)
}
}
@ -255,7 +255,7 @@ impl Crud for AdminBan {
.values(form)
.get_result::<Self>(conn)
.await
.with_lemmy_type(LemmyErrorType::CouldntCreateModlog)
.with_lemmy_type(LemmyErrorType::CouldntCreate)
}
async fn update(
@ -268,7 +268,7 @@ impl Crud for AdminBan {
.set(form)
.get_result::<Self>(conn)
.await
.with_lemmy_type(LemmyErrorType::CouldntUpdateModlog)
.with_lemmy_type(LemmyErrorType::CouldntUpdate)
}
}
@ -283,7 +283,7 @@ impl Crud for AdminAdd {
.values(form)
.get_result::<Self>(conn)
.await
.with_lemmy_type(LemmyErrorType::CouldntCreateModlog)
.with_lemmy_type(LemmyErrorType::CouldntCreate)
}
async fn update(
@ -296,6 +296,6 @@ impl Crud for AdminAdd {
.set(form)
.get_result::<Self>(conn)
.await
.with_lemmy_type(LemmyErrorType::CouldntUpdateModlog)
.with_lemmy_type(LemmyErrorType::CouldntUpdate)
}
}

View file

@ -55,7 +55,7 @@ impl Crud for ModRemovePost {
.values(form)
.get_result::<Self>(conn)
.await
.with_lemmy_type(LemmyErrorType::CouldntCreateModlog)
.with_lemmy_type(LemmyErrorType::CouldntCreate)
}
async fn update(
@ -68,7 +68,7 @@ impl Crud for ModRemovePost {
.set(form)
.get_result::<Self>(conn)
.await
.with_lemmy_type(LemmyErrorType::CouldntUpdateModlog)
.with_lemmy_type(LemmyErrorType::CouldntUpdate)
}
}
@ -82,7 +82,7 @@ impl ModRemovePost {
.values(forms)
.execute(conn)
.await
.with_lemmy_type(LemmyErrorType::CouldntCreateModlog)
.with_lemmy_type(LemmyErrorType::CouldntCreate)
}
}
@ -97,7 +97,7 @@ impl Crud for ModLockPost {
.values(form)
.get_result::<Self>(conn)
.await
.with_lemmy_type(LemmyErrorType::CouldntCreateModlog)
.with_lemmy_type(LemmyErrorType::CouldntCreate)
}
async fn update(
@ -110,7 +110,7 @@ impl Crud for ModLockPost {
.set(form)
.get_result::<Self>(conn)
.await
.with_lemmy_type(LemmyErrorType::CouldntUpdateModlog)
.with_lemmy_type(LemmyErrorType::CouldntUpdate)
}
}
@ -125,7 +125,7 @@ impl Crud for ModFeaturePost {
.values(form)
.get_result::<Self>(conn)
.await
.with_lemmy_type(LemmyErrorType::CouldntCreateModlog)
.with_lemmy_type(LemmyErrorType::CouldntCreate)
}
async fn update(
@ -138,7 +138,7 @@ impl Crud for ModFeaturePost {
.set(form)
.get_result::<Self>(conn)
.await
.with_lemmy_type(LemmyErrorType::CouldntUpdateModlog)
.with_lemmy_type(LemmyErrorType::CouldntUpdate)
}
}
@ -153,7 +153,7 @@ impl Crud for ModRemoveComment {
.values(form)
.get_result::<Self>(conn)
.await
.with_lemmy_type(LemmyErrorType::CouldntCreateModlog)
.with_lemmy_type(LemmyErrorType::CouldntCreate)
}
async fn update(
@ -166,7 +166,7 @@ impl Crud for ModRemoveComment {
.set(form)
.get_result::<Self>(conn)
.await
.with_lemmy_type(LemmyErrorType::CouldntUpdateModlog)
.with_lemmy_type(LemmyErrorType::CouldntUpdate)
}
}
@ -180,7 +180,7 @@ impl ModRemoveComment {
.values(forms)
.execute(conn)
.await
.with_lemmy_type(LemmyErrorType::CouldntCreateModlog)
.with_lemmy_type(LemmyErrorType::CouldntCreate)
}
}
@ -195,7 +195,7 @@ impl Crud for ModBanFromCommunity {
.values(form)
.get_result::<Self>(conn)
.await
.with_lemmy_type(LemmyErrorType::CouldntCreateModlog)
.with_lemmy_type(LemmyErrorType::CouldntCreate)
}
async fn update(
@ -208,7 +208,7 @@ impl Crud for ModBanFromCommunity {
.set(form)
.get_result::<Self>(conn)
.await
.with_lemmy_type(LemmyErrorType::CouldntUpdateModlog)
.with_lemmy_type(LemmyErrorType::CouldntUpdate)
}
}
@ -223,7 +223,7 @@ impl Crud for ModChangeCommunityVisibility {
.values(form)
.get_result::<Self>(conn)
.await
.with_lemmy_type(LemmyErrorType::CouldntCreateModlog)
.with_lemmy_type(LemmyErrorType::CouldntCreate)
}
async fn update(
@ -236,7 +236,7 @@ impl Crud for ModChangeCommunityVisibility {
.set(form)
.get_result::<Self>(conn)
.await
.with_lemmy_type(LemmyErrorType::CouldntUpdateModlog)
.with_lemmy_type(LemmyErrorType::CouldntUpdate)
}
}
@ -251,7 +251,7 @@ impl Crud for ModAddToCommunity {
.values(form)
.get_result::<Self>(conn)
.await
.with_lemmy_type(LemmyErrorType::CouldntCreateModlog)
.with_lemmy_type(LemmyErrorType::CouldntCreate)
}
async fn update(
@ -264,7 +264,7 @@ impl Crud for ModAddToCommunity {
.set(form)
.get_result::<Self>(conn)
.await
.with_lemmy_type(LemmyErrorType::CouldntUpdateModlog)
.with_lemmy_type(LemmyErrorType::CouldntUpdate)
}
}
@ -279,7 +279,7 @@ impl Crud for ModTransferCommunity {
.values(form)
.get_result::<Self>(conn)
.await
.with_lemmy_type(LemmyErrorType::CouldntCreateModlog)
.with_lemmy_type(LemmyErrorType::CouldntCreate)
}
async fn update(
@ -292,6 +292,6 @@ impl Crud for ModTransferCommunity {
.set(form)
.get_result::<Self>(conn)
.await
.with_lemmy_type(LemmyErrorType::CouldntUpdateModlog)
.with_lemmy_type(LemmyErrorType::CouldntUpdate)
}
}

View file

@ -20,7 +20,7 @@ impl Notification {
.on_conflict_do_nothing()
.get_result::<Self>(conn)
.await
.with_lemmy_type(LemmyErrorType::CouldntCreateNotification)
.with_lemmy_type(LemmyErrorType::CouldntCreate)
}
pub async fn read_by_comment_id(
@ -48,7 +48,7 @@ impl Notification {
.set(notification::read.eq(true))
.execute(conn)
.await
.with_lemmy_type(LemmyErrorType::CouldntUpdateNotification)
.with_lemmy_type(LemmyErrorType::CouldntUpdate)
}
pub async fn mark_read_by_id_and_person(

View file

@ -15,7 +15,7 @@ impl OAuthAccount {
.values(form)
.get_result::<Self>(conn)
.await
.with_lemmy_type(LemmyErrorType::CouldntCreateOauthAccount)
.with_lemmy_type(LemmyErrorType::CouldntCreate)
}
pub async fn delete_user_accounts(

View file

@ -25,7 +25,7 @@ impl Crud for OAuthProvider {
.values(form)
.get_result::<Self>(conn)
.await
.with_lemmy_type(LemmyErrorType::CouldntCreateOauthProvider)
.with_lemmy_type(LemmyErrorType::CouldntCreate)
}
async fn update(
@ -38,7 +38,7 @@ impl Crud for OAuthProvider {
.set(form)
.get_result::<Self>(conn)
.await
.with_lemmy_type(LemmyErrorType::CouldntUpdateOauthProvider)
.with_lemmy_type(LemmyErrorType::CouldntUpdate)
}
}

View file

@ -29,7 +29,7 @@ impl PasswordResetRequest {
.values(form)
.get_result::<Self>(conn)
.await
.with_lemmy_type(LemmyErrorType::CouldntCreatePasswordResetRequest)
.with_lemmy_type(LemmyErrorType::CouldntCreate)
}
pub async fn read_and_delete(pool: &mut DbPool<'_>, token_: &str) -> LemmyResult<Self> {

View file

@ -58,7 +58,7 @@ impl Crud for Person {
.values(form)
.get_result::<Self>(conn)
.await
.with_lemmy_type(LemmyErrorType::CouldntCreatePerson)
.with_lemmy_type(LemmyErrorType::CouldntCreate)
}
async fn update(
pool: &mut DbPool<'_>,
@ -70,7 +70,7 @@ impl Crud for Person {
.set(form)
.get_result::<Self>(conn)
.await
.with_lemmy_type(LemmyErrorType::CouldntUpdatePerson)
.with_lemmy_type(LemmyErrorType::CouldntUpdate)
}
}
@ -88,7 +88,7 @@ impl Person {
.set(form)
.get_result::<Self>(conn)
.await
.with_lemmy_type(LemmyErrorType::CouldntUpdatePerson)
.with_lemmy_type(LemmyErrorType::CouldntUpdate)
}
pub async fn delete_account(
@ -133,7 +133,7 @@ impl Person {
))
.get_result::<Self>(conn)
.await
.with_lemmy_type(LemmyErrorType::CouldntUpdatePerson)
.with_lemmy_type(LemmyErrorType::CouldntUpdate)
}
pub async fn check_username_taken(pool: &mut DbPool<'_>, username: &str) -> LemmyResult<()> {
@ -146,7 +146,7 @@ impl Person {
.get_result::<bool>(conn)
.await?
.then_some(())
.ok_or(LemmyErrorType::UsernameAlreadyExists.into())
.ok_or(LemmyErrorType::UsernameAlreadyTaken.into())
}
}
@ -238,7 +238,7 @@ impl Followable for PersonActions {
.returning(Self::as_select())
.get_result::<Self>(conn)
.await
.with_lemmy_type(LemmyErrorType::CommunityFollowerAlreadyExists)
.with_lemmy_type(LemmyErrorType::AlreadyExists)
}
/// Currently no user following
@ -257,7 +257,7 @@ impl Followable for PersonActions {
.set_null(person_actions::follow_pending)
.get_result(conn)
.await
.with_lemmy_type(LemmyErrorType::CommunityFollowerAlreadyExists)
.with_lemmy_type(LemmyErrorType::AlreadyExists)
}
}
@ -276,7 +276,7 @@ impl Blockable for PersonActions {
.returning(Self::as_select())
.get_result::<Self>(conn)
.await
.with_lemmy_type(LemmyErrorType::PersonBlockAlreadyExists)
.with_lemmy_type(LemmyErrorType::AlreadyExists)
}
async fn unblock(pool: &mut DbPool<'_>, form: &Self::Form) -> LemmyResult<UpleteCount> {
@ -285,7 +285,7 @@ impl Blockable for PersonActions {
.set_null(person_actions::blocked_at)
.get_result(conn)
.await
.with_lemmy_type(LemmyErrorType::PersonBlockAlreadyExists)
.with_lemmy_type(LemmyErrorType::AlreadyExists)
}
async fn read_block(

View file

@ -59,7 +59,7 @@ impl Crud for Post {
.values(form)
.get_result::<Self>(conn)
.await
.with_lemmy_type(LemmyErrorType::CouldntCreatePost)
.with_lemmy_type(LemmyErrorType::CouldntCreate)
}
async fn update(
@ -72,7 +72,7 @@ impl Crud for Post {
.set(new_post)
.get_result::<Self>(conn)
.await
.with_lemmy_type(LemmyErrorType::CouldntUpdatePost)
.with_lemmy_type(LemmyErrorType::CouldntUpdate)
}
}
@ -100,7 +100,7 @@ impl Post {
.set(form)
.get_result::<Self>(conn)
.await
.with_lemmy_type(LemmyErrorType::CouldntCreatePost)
.with_lemmy_type(LemmyErrorType::CouldntCreate)
}
pub async fn list_featured_for_community(
@ -153,7 +153,7 @@ impl Post {
))
.get_results::<Self>(conn)
.await
.with_lemmy_type(LemmyErrorType::CouldntUpdatePost)
.with_lemmy_type(LemmyErrorType::CouldntUpdate)
}
async fn creator_post_ids_in_community(
@ -205,7 +205,7 @@ impl Post {
.set((post::removed.eq(removed), post::updated_at.eq(Utc::now())))
.get_results::<Self>(conn)
.await
.with_lemmy_type(LemmyErrorType::CouldntUpdatePost)
.with_lemmy_type(LemmyErrorType::CouldntUpdate)
}
pub async fn update_removed_for_creator_and_instance(
@ -223,7 +223,7 @@ impl Post {
.set((post::removed.eq(removed), post::updated_at.eq(Utc::now())))
.get_results::<Self>(conn)
.await
.with_lemmy_type(LemmyErrorType::CouldntUpdatePost)
.with_lemmy_type(LemmyErrorType::CouldntUpdate)
}
pub async fn update_removed_for_creator(
@ -238,7 +238,7 @@ impl Post {
.set((post::removed.eq(removed), post::updated_at.eq(Utc::now())))
.get_results::<Self>(conn)
.await
.with_lemmy_type(LemmyErrorType::CouldntUpdatePost)
.with_lemmy_type(LemmyErrorType::CouldntUpdate)
}
pub fn is_post_creator(person_id: PersonId, post_creator_id: PersonId) -> bool {
@ -271,7 +271,7 @@ impl Post {
.set(post::deleted.eq(true))
.get_results::<Self>(conn)
.await
.with_lemmy_type(LemmyErrorType::CouldntUpdatePost)
.with_lemmy_type(LemmyErrorType::CouldntUpdate)
}
pub async fn user_scheduled_post_count(
@ -323,7 +323,7 @@ impl Post {
))
.get_result::<Self>(conn)
.await
.with_lemmy_type(LemmyErrorType::CouldntUpdatePost)
.with_lemmy_type(LemmyErrorType::CouldntUpdate)
}
pub fn local_url(&self, settings: &Settings) -> LemmyResult<Url> {
let domain = settings.get_protocol_and_hostname();
@ -350,7 +350,7 @@ impl Likeable for PostActions {
async fn like(pool: &mut DbPool<'_>, form: &Self::Form) -> LemmyResult<Self> {
let conn = &mut get_conn(pool).await?;
validate_like(form.like_score).with_lemmy_type(LemmyErrorType::CouldntLikePost)?;
validate_like(form.like_score).with_lemmy_type(LemmyErrorType::CouldntCreate)?;
insert_into(post_actions::table)
.values(form)
@ -360,7 +360,7 @@ impl Likeable for PostActions {
.returning(Self::as_select())
.get_result::<Self>(conn)
.await
.with_lemmy_type(LemmyErrorType::CouldntLikePost)
.with_lemmy_type(LemmyErrorType::CouldntCreate)
}
async fn remove_like(
@ -374,7 +374,7 @@ impl Likeable for PostActions {
.set_null(post_actions::liked_at)
.get_result(conn)
.await
.with_lemmy_type(LemmyErrorType::CouldntLikePost)
.with_lemmy_type(LemmyErrorType::CouldntUpdate)
}
async fn remove_all_likes(
@ -388,7 +388,7 @@ impl Likeable for PostActions {
.set_null(post_actions::liked_at)
.get_result(conn)
.await
.with_lemmy_type(LemmyErrorType::CouldntUpdatePost)
.with_lemmy_type(LemmyErrorType::CouldntUpdate)
}
async fn remove_likes_in_community(
@ -405,7 +405,7 @@ impl Likeable for PostActions {
.set_null(post_actions::liked_at)
.get_result(conn)
.await
.with_lemmy_type(LemmyErrorType::CouldntUpdatePost)
.with_lemmy_type(LemmyErrorType::CouldntUpdate)
}
}
@ -421,7 +421,7 @@ impl Saveable for PostActions {
.returning(Self::as_select())
.get_result::<Self>(conn)
.await
.with_lemmy_type(LemmyErrorType::CouldntSavePost)
.with_lemmy_type(LemmyErrorType::CouldntUpdate)
}
async fn unsave(pool: &mut DbPool<'_>, form: &Self::Form) -> LemmyResult<UpleteCount> {
let conn = &mut get_conn(pool).await?;
@ -429,7 +429,7 @@ impl Saveable for PostActions {
.set_null(post_actions::saved_at)
.get_result(conn)
.await
.with_lemmy_type(LemmyErrorType::CouldntSavePost)
.with_lemmy_type(LemmyErrorType::CouldntUpdate)
}
}
@ -452,7 +452,7 @@ impl PostActions {
.set_null(post_actions::read_at)
.get_result(conn)
.await
.with_lemmy_type(LemmyErrorType::CouldntMarkPostAsRead)
.with_lemmy_type(LemmyErrorType::CouldntUpdate)
}
pub async fn mark_many_as_read(
@ -468,7 +468,7 @@ impl PostActions {
.set(post_actions::read_at.eq(now().nullable()))
.execute(conn)
.await
.with_lemmy_type(LemmyErrorType::CouldntMarkPostAsRead)
.with_lemmy_type(LemmyErrorType::CouldntUpdate)
}
}
@ -483,7 +483,7 @@ impl PostActions {
.set(form)
.get_result::<Self>(conn)
.await
.with_lemmy_type(LemmyErrorType::CouldntHidePost)
.with_lemmy_type(LemmyErrorType::CouldntUpdate)
}
pub async fn unhide(pool: &mut DbPool<'_>, form: &PostHideForm) -> LemmyResult<UpleteCount> {
@ -497,7 +497,7 @@ impl PostActions {
.set_null(post_actions::hidden_at)
.get_result(conn)
.await
.with_lemmy_type(LemmyErrorType::CouldntHidePost)
.with_lemmy_type(LemmyErrorType::CouldntUpdate)
}
}
@ -515,7 +515,7 @@ impl PostActions {
.set(form)
.get_result::<Self>(conn)
.await
.with_lemmy_type(LemmyErrorType::CouldntUpdateReadComments)
.with_lemmy_type(LemmyErrorType::CouldntUpdate)
}
}

View file

@ -26,7 +26,7 @@ impl Reportable for PostReport {
.values(form)
.get_result::<Self>(conn)
.await
.with_lemmy_type(LemmyErrorType::CouldntCreateReport)
.with_lemmy_type(LemmyErrorType::CouldntCreate)
}
async fn update_resolved(
@ -44,7 +44,7 @@ impl Reportable for PostReport {
))
.execute(conn)
.await
.with_lemmy_type(LemmyErrorType::CouldntResolveReport)
.with_lemmy_type(LemmyErrorType::CouldntUpdate)
}
async fn resolve_apub(
@ -68,7 +68,7 @@ impl Reportable for PostReport {
))
.execute(conn)
.await
.with_lemmy_type(LemmyErrorType::CouldntResolveReport)
.with_lemmy_type(LemmyErrorType::CouldntUpdate)
}
async fn resolve_all_for_object(
@ -85,7 +85,7 @@ impl Reportable for PostReport {
))
.execute(conn)
.await
.with_lemmy_type(LemmyErrorType::CouldntResolveReport)
.with_lemmy_type(LemmyErrorType::CouldntUpdate)
}
}

View file

@ -26,7 +26,7 @@ impl Crud for PrivateMessage {
.values(form)
.get_result::<Self>(conn)
.await
.with_lemmy_type(LemmyErrorType::CouldntCreatePrivateMessage)
.with_lemmy_type(LemmyErrorType::CouldntCreate)
}
async fn update(
@ -39,7 +39,7 @@ impl Crud for PrivateMessage {
.set(form)
.get_result::<Self>(conn)
.await
.with_lemmy_type(LemmyErrorType::CouldntUpdatePrivateMessage)
.with_lemmy_type(LemmyErrorType::CouldntUpdate)
}
}
@ -60,7 +60,7 @@ impl PrivateMessage {
.set(form)
.get_result::<Self>(conn)
.await
.with_lemmy_type(LemmyErrorType::CouldntCreatePrivateMessage)
.with_lemmy_type(LemmyErrorType::CouldntCreate)
}
pub async fn read_from_apub_id(
@ -94,7 +94,7 @@ impl PrivateMessage {
))
.get_results::<Self>(conn)
.await
.with_lemmy_type(LemmyErrorType::CouldntUpdatePrivateMessage)
.with_lemmy_type(LemmyErrorType::CouldntUpdate)
}
}

View file

@ -25,7 +25,7 @@ impl Reportable for PrivateMessageReport {
.values(form)
.get_result::<Self>(conn)
.await
.with_lemmy_type(LemmyErrorType::CouldntCreateReport)
.with_lemmy_type(LemmyErrorType::CouldntCreate)
}
async fn update_resolved(
@ -43,7 +43,7 @@ impl Reportable for PrivateMessageReport {
))
.execute(conn)
.await
.with_lemmy_type(LemmyErrorType::CouldntResolveReport)
.with_lemmy_type(LemmyErrorType::CouldntUpdate)
}
async fn resolve_apub(
_pool: &mut DbPool<'_>,

View file

@ -24,7 +24,7 @@ impl Crud for RegistrationApplication {
.values(form)
.get_result::<Self>(conn)
.await
.with_lemmy_type(LemmyErrorType::CouldntCreateRegistrationApplication)
.with_lemmy_type(LemmyErrorType::CouldntCreate)
}
async fn update(
@ -37,7 +37,7 @@ impl Crud for RegistrationApplication {
.set(form)
.get_result::<Self>(conn)
.await
.with_lemmy_type(LemmyErrorType::CouldntUpdateRegistrationApplication)
.with_lemmy_type(LemmyErrorType::CouldntUpdate)
}
}

View file

@ -57,7 +57,7 @@ impl Crud for Site {
.set(new_site)
.get_result::<Self>(conn)
.await
.with_lemmy_type(LemmyErrorType::CouldntUpdateSite)
.with_lemmy_type(LemmyErrorType::CouldntUpdate)
}
}

View file

@ -35,7 +35,7 @@ impl Crud for Tag {
.values(form)
.get_result::<Self>(conn)
.await
.with_lemmy_type(LemmyErrorType::CouldntCreateTag)
.with_lemmy_type(LemmyErrorType::CouldntCreate)
}
async fn update(pool: &mut DbPool<'_>, pid: TagId, form: &Self::UpdateForm) -> LemmyResult<Self> {
@ -44,7 +44,7 @@ impl Crud for Tag {
.set(form)
.get_result::<Self>(conn)
.await
.with_lemmy_type(LemmyErrorType::CouldntUpdateTag)
.with_lemmy_type(LemmyErrorType::CouldntUpdate)
}
}
@ -183,7 +183,7 @@ impl PostTag {
.returning(Self::as_select())
.get_results(conn)
.await
.with_lemmy_type(LemmyErrorType::CouldntCreatePostTag)
.with_lemmy_type(LemmyErrorType::CouldntCreate)
}
.scope_boxed()
})

View file

@ -21,7 +21,7 @@ impl Crud for Tagline {
.values(form)
.get_result::<Self>(conn)
.await
.with_lemmy_type(LemmyErrorType::CouldntCreateTagline)
.with_lemmy_type(LemmyErrorType::CouldntCreate)
}
async fn update(
@ -34,7 +34,7 @@ impl Crud for Tagline {
.set(form)
.get_result::<Self>(conn)
.await
.with_lemmy_type(LemmyErrorType::CouldntUpdateTagline)
.with_lemmy_type(LemmyErrorType::CouldntUpdate)
}
}

View file

@ -12,7 +12,8 @@ use strum::{Display, EnumIter};
pub enum LemmyErrorType {
BlockKeywordTooShort,
BlockKeywordTooLong,
CouldntUpdateKeywords,
CouldntUpdate,
CouldntCreate,
ReportReasonRequired,
ReportTooLong,
NotAModerator,
@ -20,11 +21,9 @@ pub enum LemmyErrorType {
CantBlockYourself,
CantNoteYourself,
CantBlockAdmin,
CouldntUpdateUser,
PasswordsDoNotMatch,
EmailNotVerified,
EmailRequired,
CouldntUpdateComment,
CannotLeaveAdmin,
PictrsResponseError(String),
PictrsPurgeResponseError(String),
@ -52,25 +51,21 @@ pub enum LemmyErrorType {
HoneypotFailed,
RegistrationApplicationIsPending,
Locked,
CouldntCreateComment,
MaxCommentDepthReached,
NoCommentEditAllowed,
OnlyAdminsCanCreateCommunities,
CommunityAlreadyExists,
AlreadyExists,
LanguageNotAllowed,
CouldntUpdateLanguages,
CouldntUpdatePost,
NoPostEditAllowed,
NsfwNotAllowed,
EditPrivateMessageNotAllowed,
SiteAlreadyExists,
ApplicationQuestionRequired,
InvalidDefaultPostListingType,
RegistrationClosed,
RegistrationApplicationAnswerRequired,
RegistrationUsernameRequired,
EmailAlreadyExists,
UsernameAlreadyExists,
EmailAlreadyTaken,
UsernameAlreadyTaken,
PersonIsBannedFromCommunity,
NoIdGiven,
IncorrectLogin,
@ -85,32 +80,12 @@ pub enum LemmyErrorType {
InvalidBodyField,
BioLengthOverflow,
AltTextLengthOverflow,
CouldntParseTotpSecret,
CouldntGenerateTotp,
MissingTotpToken,
MissingTotpSecret,
IncorrectTotpToken,
CouldntParseTotpSecret,
CouldntGenerateTotp,
TotpAlreadyEnabled,
CouldntLikeComment,
CouldntSaveComment,
CouldntCreateReport,
CouldntResolveReport,
CommunityModeratorAlreadyExists,
CommunityUserAlreadyBanned,
CommunityBlockAlreadyExists,
CommunityFollowerAlreadyExists,
PersonBlockAlreadyExists,
CouldntLikePost,
CouldntSavePost,
CouldntMarkPostAsRead,
CouldntUpdateReadComments,
CouldntHidePost,
CouldntUpdateCommunity,
CouldntCreateNotification,
CouldntUpdateNotification,
CouldntCreatePost,
CouldntCreatePrivateMessage,
CouldntUpdatePrivateMessage,
BlockedUrl,
InvalidUrl,
EmailSendFailed,
@ -129,8 +104,6 @@ pub enum LemmyErrorType {
InvalidUrlScheme,
CouldntSendWebmention,
ContradictingFilters,
InstanceBlockCommunitiesAlreadyExists,
InstanceBlockPersonsAlreadyExists,
/// Thrown when an API call is submitted with more than 1000 array elements, see
/// [[MAX_API_PARAM_ELEMENTS]]
TooManyItems,
@ -144,8 +117,6 @@ pub enum LemmyErrorType {
OauthAuthorizationInvalid,
OauthLoginFailed,
OauthRegistrationClosed,
CouldntCreateOauthProvider,
CouldntUpdateOauthProvider,
NotFound,
CommunityHasNoFollowers,
PostScheduleTimeMustBeInFuture,
@ -158,33 +129,6 @@ pub enum LemmyErrorType {
CouldntParsePaginationToken,
PluginError(String),
InvalidFetchLimit,
CouldntCreateEmoji,
CouldntUpdateEmoji,
CouldntCreatePerson,
CouldntUpdatePerson,
CouldntCreateModlog,
CouldntUpdateModlog,
CouldntCreateSite,
CouldntUpdateSite,
CouldntCreateRegistrationApplication,
CouldntUpdateRegistrationApplication,
CouldntCreateTag,
CouldntUpdateTag,
CouldntCreatePostTag,
CouldntCreateTagline,
CouldntUpdateTagline,
CouldntCreateImage,
CouldntAllowInstance,
CouldntBlockInstance,
CouldntInsertActivity,
CouldntCreateRateLimit,
CouldntCreateCaptchaAnswer,
CouldntUpdateFederationQueueState,
CouldntCreateOauthAccount,
CouldntCreatePasswordResetRequest,
CouldntCreateLoginToken,
CouldntUpdateLocalSiteUrlBlocklist,
CouldntCreateEmailVerification,
EmailNotificationsDisabled,
MultiCommunityUpdateWrongUser,
CannotCombineCommunityIdAndMultiCommunityId,
@ -206,8 +150,6 @@ pub enum FederationError {
PersonIsBannedFromSite(String),
InvalidVoteValue,
PageDoesNotSpecifyCreator,
CouldntGetComments,
CouldntGetPosts,
FederationDisabled,
DomainBlocked(String),
DomainNotInAllowList(String),

View file

@ -61,13 +61,13 @@ mod tests {
#[actix_web::test]
async fn test_lemmy_errors_are_not_modified() {
async fn lemmy_error_service() -> actix_web::Result<String, LemmyError> {
Err(LemmyError::from(LemmyErrorType::EmailAlreadyExists))
Err(LemmyError::from(LemmyErrorType::AlreadyExists))
}
check_for_jsonification(
lemmy_error_service,
StatusCode::BAD_REQUEST,
"{\"error\":\"email_already_exists\"}",
"{\"error\":\"already_exists\"}",
)
.await;
}