diff --git a/api_tests/src/post.spec.ts b/api_tests/src/post.spec.ts index cb7df832f..e125e241a 100644 --- a/api_tests/src/post.spec.ts +++ b/api_tests/src/post.spec.ts @@ -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"), ); }); diff --git a/crates/api/api/src/reports/private_message_report/create.rs b/crates/api/api/src/reports/private_message_report/create.rs index 2abc94dec..f940d5f59 100644 --- a/crates/api/api/src/reports/private_message_report/create.rs +++ b/crates/api/api/src/reports/private_message_report/create.rs @@ -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 { diff --git a/crates/api/api_crud/src/comment/create.rs b/crates/api/api_crud/src/comment/create.rs index ccc39d24f..6b9c9e4d6 100644 --- a/crates/api/api_crud/src/comment/create.rs +++ b/crates/api/api_crud/src/comment/create.rs @@ -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)?; } diff --git a/crates/api/api_crud/src/comment/delete.rs b/crates/api/api_crud/src/comment/delete.rs index 28b3f0a6b..ecabd7321 100644 --- a/crates/api/api_crud/src/comment/delete.rs +++ b/crates/api/api_crud/src/comment/delete.rs @@ -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( diff --git a/crates/api/api_crud/src/comment/remove.rs b/crates/api/api_crud/src/comment/remove.rs index 2b840b072..68b10fc26 100644 --- a/crates/api/api_crud/src/comment/remove.rs +++ b/crates/api/api_crud/src/comment/remove.rs @@ -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 diff --git a/crates/api/api_crud/src/community/create.rs b/crates/api/api_crud/src/community/create.rs index 3e743eb1c..451afb3ba 100644 --- a/crates/api/api_crud/src/community/create.rs +++ b/crates/api/api_crud/src/community/create.rs @@ -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()?; diff --git a/crates/api/api_crud/src/post/delete.rs b/crates/api/api_crud/src/post/delete.rs index 5de1c1e92..265b18d38 100644 --- a/crates/api/api_crud/src/post/delete.rs +++ b/crates/api/api_crud/src/post/delete.rs @@ -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?; diff --git a/crates/api/api_crud/src/site/create.rs b/crates/api/api_crud/src/site/create.rs index 1950664a8..67565af26 100644 --- a/crates/api/api_crud/src/site/create.rs +++ b/crates/api/api_crud/src/site/create.rs @@ -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, diff --git a/crates/api/api_crud/src/user/create.rs b/crates/api/api_crud/src/user/create.rs index ec18e3d15..5a1015417 100644 --- a/crates/api/api_crud/src/user/create.rs +++ b/crates/api/api_crud/src/user/create.rs @@ -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 diff --git a/crates/api/api_utils/src/utils.rs b/crates/api/api_utils/src/utils.rs index 27cb1ce75..bd12edf83 100644 --- a/crates/api/api_utils/src/utils.rs +++ b/crates/api/api_utils/src/utils.rs @@ -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?; diff --git a/crates/db_schema/src/impls/activity.rs b/crates/db_schema/src/impls/activity.rs index 2382a34b6..c7580d032 100644 --- a/crates/db_schema/src/impls/activity.rs +++ b/crates/db_schema/src/impls/activity.rs @@ -16,7 +16,7 @@ impl SentActivity { .values(form) .get_result::(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 { @@ -53,7 +53,7 @@ impl ReceivedActivity { // new activity inserted successfully Ok(()) } else { - Err(LemmyErrorType::CouldntInsertActivity.into()) + Err(LemmyErrorType::CouldntCreate.into()) } } } diff --git a/crates/db_schema/src/impls/actor_language.rs b/crates/db_schema/src/impls/actor_language.rs index 589863b83..640402693 100644 --- a/crates/db_schema/src/impls/actor_language.rs +++ b/crates/db_schema/src/impls/actor_language.rs @@ -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() }) diff --git a/crates/db_schema/src/impls/captcha_answer.rs b/crates/db_schema/src/impls/captcha_answer.rs index f9a899945..420ed4f5f 100644 --- a/crates/db_schema/src/impls/captcha_answer.rs +++ b/crates/db_schema/src/impls/captcha_answer.rs @@ -15,7 +15,7 @@ impl CaptchaAnswer { .values(captcha) .get_result::(conn) .await - .with_lemmy_type(LemmyErrorType::CouldntCreateCaptchaAnswer) + .with_lemmy_type(LemmyErrorType::CouldntCreate) } pub async fn check_captcha( diff --git a/crates/db_schema/src/impls/comment.rs b/crates/db_schema/src/impls/comment.rs index 3dbb67783..a130f30e5 100644 --- a/crates/db_schema/src/impls/comment.rs +++ b/crates/db_schema/src/impls/comment.rs @@ -52,7 +52,7 @@ impl Comment { )) .get_results::(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::(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::(conn) .await - .with_lemmy_type(LemmyErrorType::CouldntCreateComment) } else { insert_into(comment::table) .values(comment_form) .get_result::(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::(conn) .await - .with_lemmy_type(LemmyErrorType::CouldntUpdateComment) + .with_lemmy_type(LemmyErrorType::CouldntUpdate) } pub fn local_url(&self, settings: &Settings) -> LemmyResult { let domain = settings.get_protocol_and_hostname(); @@ -260,7 +259,7 @@ impl Crud for Comment { .set(comment_form) .get_result::(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 { 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::(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::(conn) .await - .with_lemmy_type(LemmyErrorType::CouldntSaveComment) + .with_lemmy_type(LemmyErrorType::CouldntCreate) } async fn unsave(pool: &mut DbPool<'_>, form: &Self::Form) -> LemmyResult { 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) } } diff --git a/crates/db_schema/src/impls/comment_report.rs b/crates/db_schema/src/impls/comment_report.rs index 92edfa2e9..3c434a3f8 100644 --- a/crates/db_schema/src/impls/comment_report.rs +++ b/crates/db_schema/src/impls/comment_report.rs @@ -29,7 +29,7 @@ impl Reportable for CommentReport { .values(form) .get_result::(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) } } diff --git a/crates/db_schema/src/impls/community.rs b/crates/db_schema/src/impls/community.rs index 3d45dc8d8..f5ee3ceb0 100644 --- a/crates/db_schema/src/impls/community.rs +++ b/crates/db_schema/src/impls/community.rs @@ -78,7 +78,7 @@ impl Crud for Community { .set(form) .get_result::(conn) .await - .with_lemmy_type(LemmyErrorType::CouldntUpdateCommunity) + .with_lemmy_type(LemmyErrorType::CouldntUpdate) } } @@ -96,7 +96,7 @@ impl CommunityActions { .returning(Self::as_select()) .get_result::(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::(conn) .await - .with_lemmy_type(LemmyErrorType::CommunityUserAlreadyBanned) + .with_lemmy_type(LemmyErrorType::CouldntUpdate) } async fn unban(pool: &mut DbPool<'_>, form: &Self::Form) -> LemmyResult { @@ -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::(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::(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::(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( diff --git a/crates/db_schema/src/impls/community_report.rs b/crates/db_schema/src/impls/community_report.rs index c8b67bd8d..b813f6b41 100644 --- a/crates/db_schema/src/impls/community_report.rs +++ b/crates/db_schema/src/impls/community_report.rs @@ -29,7 +29,7 @@ impl Reportable for CommunityReport { .values(form) .get_result::(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) } } diff --git a/crates/db_schema/src/impls/custom_emoji.rs b/crates/db_schema/src/impls/custom_emoji.rs index 4d1dd8b32..d082ad469 100644 --- a/crates/db_schema/src/impls/custom_emoji.rs +++ b/crates/db_schema/src/impls/custom_emoji.rs @@ -26,7 +26,7 @@ impl Crud for CustomEmoji { .values(form) .get_result::(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::(conn) .await - .with_lemmy_type(LemmyErrorType::CouldntUpdateEmoji) + .with_lemmy_type(LemmyErrorType::CouldntUpdate) } } @@ -53,7 +53,7 @@ impl CustomEmojiKeyword { .values(form) .get_results::(conn) .await - .with_lemmy_type(LemmyErrorType::CouldntCreateEmoji) + .with_lemmy_type(LemmyErrorType::CouldntCreate) } pub async fn delete(pool: &mut DbPool<'_>, emoji_id: CustomEmojiId) -> LemmyResult { let conn = &mut get_conn(pool).await?; diff --git a/crates/db_schema/src/impls/email_verification.rs b/crates/db_schema/src/impls/email_verification.rs index 3ce5f1531..4710f8eba 100644 --- a/crates/db_schema/src/impls/email_verification.rs +++ b/crates/db_schema/src/impls/email_verification.rs @@ -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 { diff --git a/crates/db_schema/src/impls/federation_allowlist.rs b/crates/db_schema/src/impls/federation_allowlist.rs index 226cffa6b..1add78edc 100644 --- a/crates/db_schema/src/impls/federation_allowlist.rs +++ b/crates/db_schema/src/impls/federation_allowlist.rs @@ -15,7 +15,7 @@ impl FederationAllowList { .values(form) .get_result::(conn) .await - .with_lemmy_type(LemmyErrorType::CouldntAllowInstance) + .with_lemmy_type(LemmyErrorType::CouldntCreate) } pub async fn unallow(pool: &mut DbPool<'_>, instance_id_: InstanceId) -> LemmyResult { let conn = &mut get_conn(pool).await?; diff --git a/crates/db_schema/src/impls/federation_blocklist.rs b/crates/db_schema/src/impls/federation_blocklist.rs index ae51423c4..9f14b16e7 100644 --- a/crates/db_schema/src/impls/federation_blocklist.rs +++ b/crates/db_schema/src/impls/federation_blocklist.rs @@ -15,7 +15,7 @@ impl FederationBlockList { .values(form) .get_result::(conn) .await - .with_lemmy_type(LemmyErrorType::CouldntBlockInstance) + .with_lemmy_type(LemmyErrorType::CouldntCreate) } pub async fn unblock(pool: &mut DbPool<'_>, instance_id_: InstanceId) -> LemmyResult { let conn = &mut get_conn(pool).await?; diff --git a/crates/db_schema/src/impls/federation_queue_state.rs b/crates/db_schema/src/impls/federation_queue_state.rs index 8f3bae422..7fc4c60fb 100644 --- a/crates/db_schema/src/impls/federation_queue_state.rs +++ b/crates/db_schema/src/impls/federation_queue_state.rs @@ -38,6 +38,6 @@ impl FederationQueueState { .set(state) .execute(conn) .await - .with_lemmy_type(LemmyErrorType::CouldntUpdateFederationQueueState) + .with_lemmy_type(LemmyErrorType::CouldntUpdate) } } diff --git a/crates/db_schema/src/impls/images.rs b/crates/db_schema/src/impls/images.rs index 18c3922d4..6f6a9befe 100644 --- a/crates/db_schema/src/impls/images.rs +++ b/crates/db_schema/src/impls/images.rs @@ -30,7 +30,7 @@ impl LocalImage { .values(form) .get_result::(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) } } diff --git a/crates/db_schema/src/impls/instance.rs b/crates/db_schema/src/impls/instance.rs index fdf1580de..372496807 100644 --- a/crates/db_schema/src/impls/instance.rs +++ b/crates/db_schema/src/impls/instance.rs @@ -74,7 +74,7 @@ impl Instance { .set(&form) .get_result::(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 { @@ -227,7 +227,7 @@ impl InstanceActions { .returning(Self::as_select()) .get_result::(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::(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. diff --git a/crates/db_schema/src/impls/keyword_block.rs b/crates/db_schema/src/impls/keyword_block.rs index 78aef314d..08c9cb442 100644 --- a/crates/db_schema/src/impls/keyword_block.rs +++ b/crates/db_schema/src/impls/keyword_block.rs @@ -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() }) diff --git a/crates/db_schema/src/impls/local_site.rs b/crates/db_schema/src/impls/local_site.rs index 34c024e38..0fdb22b68 100644 --- a/crates/db_schema/src/impls/local_site.rs +++ b/crates/db_schema/src/impls/local_site.rs @@ -14,7 +14,7 @@ impl LocalSite { .values(form) .get_result::(conn) .await - .with_lemmy_type(LemmyErrorType::CouldntCreateSite) + .with_lemmy_type(LemmyErrorType::CouldntCreate) } pub async fn update(pool: &mut DbPool<'_>, form: &LocalSiteUpdateForm) -> LemmyResult { @@ -23,7 +23,7 @@ impl LocalSite { .set(form) .get_result::(conn) .await - .with_lemmy_type(LemmyErrorType::CouldntUpdateSite) + .with_lemmy_type(LemmyErrorType::CouldntUpdate) } pub async fn delete(pool: &mut DbPool<'_>) -> LemmyResult { diff --git a/crates/db_schema/src/impls/local_site_rate_limit.rs b/crates/db_schema/src/impls/local_site_rate_limit.rs index 323f43835..ccf8c22cc 100644 --- a/crates/db_schema/src/impls/local_site_rate_limit.rs +++ b/crates/db_schema/src/impls/local_site_rate_limit.rs @@ -31,7 +31,7 @@ impl LocalSiteRateLimit { .values(form) .get_result::(conn) .await - .with_lemmy_type(LemmyErrorType::CouldntCreateRateLimit) + .with_lemmy_type(LemmyErrorType::CouldntCreate) } pub async fn update( pool: &mut DbPool<'_>, diff --git a/crates/db_schema/src/impls/local_site_url_blocklist.rs b/crates/db_schema/src/impls/local_site_url_blocklist.rs index b5de6b0a4..a2bca810b 100644 --- a/crates/db_schema/src/impls/local_site_url_blocklist.rs +++ b/crates/db_schema/src/impls/local_site_url_blocklist.rs @@ -28,7 +28,7 @@ impl LocalSiteUrlBlocklist { .values(forms) .execute(conn) .await - .with_lemmy_type(LemmyErrorType::CouldntUpdateLocalSiteUrlBlocklist) + .with_lemmy_type(LemmyErrorType::CouldntUpdate) } .scope_boxed() }) diff --git a/crates/db_schema/src/impls/local_user.rs b/crates/db_schema/src/impls/local_user.rs index 1a24bf1dd..60c877782 100644 --- a/crates/db_schema/src/impls/local_user.rs +++ b/crates/db_schema/src/impls/local_user.rs @@ -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 { @@ -90,7 +90,7 @@ impl LocalUser { .set((local_user::password_encrypted.eq(password_hash),)) .get_result::(conn) .await - .with_lemmy_type(LemmyErrorType::CouldntUpdateUser) + .with_lemmy_type(LemmyErrorType::CouldntUpdate) } pub async fn set_all_users_email_verified(pool: &mut DbPool<'_>) -> LemmyResult> { @@ -99,7 +99,7 @@ impl LocalUser { .set(local_user::email_verified.eq(true)) .get_results::(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::(conn) .await - .with_lemmy_type(LemmyErrorType::CouldntUpdateUser) + .with_lemmy_type(LemmyErrorType::CouldntUpdate) } pub async fn delete_old_denied_local_users(pool: &mut DbPool<'_>) -> LemmyResult { @@ -150,7 +150,7 @@ impl LocalUser { .get_result::(conn) .await? .then_some(()) - .ok_or(LemmyErrorType::EmailAlreadyExists.into()) + .ok_or(LemmyErrorType::EmailAlreadyTaken.into()) } // TODO: maybe move this and pass in LocalUserView diff --git a/crates/db_schema/src/impls/login_token.rs b/crates/db_schema/src/impls/login_token.rs index 95a6b860e..ccaf07313 100644 --- a/crates/db_schema/src/impls/login_token.rs +++ b/crates/db_schema/src/impls/login_token.rs @@ -16,7 +16,7 @@ impl LoginToken { .values(form) .get_result::(conn) .await - .with_lemmy_type(LemmyErrorType::CouldntCreateLoginToken) + .with_lemmy_type(LemmyErrorType::CouldntCreate) } /// Check if the given token is valid for user. diff --git a/crates/db_schema/src/impls/mod_log/admin.rs b/crates/db_schema/src/impls/mod_log/admin.rs index 4a23fb7fe..1111404f5 100644 --- a/crates/db_schema/src/impls/mod_log/admin.rs +++ b/crates/db_schema/src/impls/mod_log/admin.rs @@ -59,7 +59,7 @@ impl Crud for AdminPurgePerson { .values(form) .get_result::(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::(conn) .await - .with_lemmy_type(LemmyErrorType::CouldntUpdateModlog) + .with_lemmy_type(LemmyErrorType::CouldntUpdate) } } @@ -87,7 +87,7 @@ impl Crud for AdminPurgeCommunity { .values(form) .get_result::(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::(conn) .await - .with_lemmy_type(LemmyErrorType::CouldntUpdateModlog) + .with_lemmy_type(LemmyErrorType::CouldntUpdate) } } @@ -115,7 +115,7 @@ impl Crud for AdminPurgePost { .values(form) .get_result::(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::(conn) .await - .with_lemmy_type(LemmyErrorType::CouldntUpdateModlog) + .with_lemmy_type(LemmyErrorType::CouldntUpdate) } } @@ -143,7 +143,7 @@ impl Crud for AdminPurgeComment { .values(form) .get_result::(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::(conn) .await - .with_lemmy_type(LemmyErrorType::CouldntUpdateModlog) + .with_lemmy_type(LemmyErrorType::CouldntUpdate) } } @@ -171,7 +171,7 @@ impl Crud for AdminAllowInstance { .values(form) .get_result::(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::(conn) .await - .with_lemmy_type(LemmyErrorType::CouldntUpdateModlog) + .with_lemmy_type(LemmyErrorType::CouldntUpdate) } } @@ -199,7 +199,7 @@ impl Crud for AdminBlockInstance { .values(form) .get_result::(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::(conn) .await - .with_lemmy_type(LemmyErrorType::CouldntUpdateModlog) + .with_lemmy_type(LemmyErrorType::CouldntUpdate) } } @@ -227,7 +227,7 @@ impl Crud for AdminRemoveCommunity { .values(form) .get_result::(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::(conn) .await - .with_lemmy_type(LemmyErrorType::CouldntUpdateModlog) + .with_lemmy_type(LemmyErrorType::CouldntUpdate) } } @@ -255,7 +255,7 @@ impl Crud for AdminBan { .values(form) .get_result::(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::(conn) .await - .with_lemmy_type(LemmyErrorType::CouldntUpdateModlog) + .with_lemmy_type(LemmyErrorType::CouldntUpdate) } } @@ -283,7 +283,7 @@ impl Crud for AdminAdd { .values(form) .get_result::(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::(conn) .await - .with_lemmy_type(LemmyErrorType::CouldntUpdateModlog) + .with_lemmy_type(LemmyErrorType::CouldntUpdate) } } diff --git a/crates/db_schema/src/impls/mod_log/moderator.rs b/crates/db_schema/src/impls/mod_log/moderator.rs index 8b50cf51b..a7a822437 100644 --- a/crates/db_schema/src/impls/mod_log/moderator.rs +++ b/crates/db_schema/src/impls/mod_log/moderator.rs @@ -55,7 +55,7 @@ impl Crud for ModRemovePost { .values(form) .get_result::(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::(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::(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::(conn) .await - .with_lemmy_type(LemmyErrorType::CouldntUpdateModlog) + .with_lemmy_type(LemmyErrorType::CouldntUpdate) } } @@ -125,7 +125,7 @@ impl Crud for ModFeaturePost { .values(form) .get_result::(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::(conn) .await - .with_lemmy_type(LemmyErrorType::CouldntUpdateModlog) + .with_lemmy_type(LemmyErrorType::CouldntUpdate) } } @@ -153,7 +153,7 @@ impl Crud for ModRemoveComment { .values(form) .get_result::(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::(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::(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::(conn) .await - .with_lemmy_type(LemmyErrorType::CouldntUpdateModlog) + .with_lemmy_type(LemmyErrorType::CouldntUpdate) } } @@ -223,7 +223,7 @@ impl Crud for ModChangeCommunityVisibility { .values(form) .get_result::(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::(conn) .await - .with_lemmy_type(LemmyErrorType::CouldntUpdateModlog) + .with_lemmy_type(LemmyErrorType::CouldntUpdate) } } @@ -251,7 +251,7 @@ impl Crud for ModAddToCommunity { .values(form) .get_result::(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::(conn) .await - .with_lemmy_type(LemmyErrorType::CouldntUpdateModlog) + .with_lemmy_type(LemmyErrorType::CouldntUpdate) } } @@ -279,7 +279,7 @@ impl Crud for ModTransferCommunity { .values(form) .get_result::(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::(conn) .await - .with_lemmy_type(LemmyErrorType::CouldntUpdateModlog) + .with_lemmy_type(LemmyErrorType::CouldntUpdate) } } diff --git a/crates/db_schema/src/impls/notification.rs b/crates/db_schema/src/impls/notification.rs index 236a27541..a1661c4ae 100644 --- a/crates/db_schema/src/impls/notification.rs +++ b/crates/db_schema/src/impls/notification.rs @@ -20,7 +20,7 @@ impl Notification { .on_conflict_do_nothing() .get_result::(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( diff --git a/crates/db_schema/src/impls/oauth_account.rs b/crates/db_schema/src/impls/oauth_account.rs index a1f4a9218..14bf20f9a 100644 --- a/crates/db_schema/src/impls/oauth_account.rs +++ b/crates/db_schema/src/impls/oauth_account.rs @@ -15,7 +15,7 @@ impl OAuthAccount { .values(form) .get_result::(conn) .await - .with_lemmy_type(LemmyErrorType::CouldntCreateOauthAccount) + .with_lemmy_type(LemmyErrorType::CouldntCreate) } pub async fn delete_user_accounts( diff --git a/crates/db_schema/src/impls/oauth_provider.rs b/crates/db_schema/src/impls/oauth_provider.rs index 3a28ea7af..b5788a245 100644 --- a/crates/db_schema/src/impls/oauth_provider.rs +++ b/crates/db_schema/src/impls/oauth_provider.rs @@ -25,7 +25,7 @@ impl Crud for OAuthProvider { .values(form) .get_result::(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::(conn) .await - .with_lemmy_type(LemmyErrorType::CouldntUpdateOauthProvider) + .with_lemmy_type(LemmyErrorType::CouldntUpdate) } } diff --git a/crates/db_schema/src/impls/password_reset_request.rs b/crates/db_schema/src/impls/password_reset_request.rs index 7a06e26c1..78050d911 100644 --- a/crates/db_schema/src/impls/password_reset_request.rs +++ b/crates/db_schema/src/impls/password_reset_request.rs @@ -29,7 +29,7 @@ impl PasswordResetRequest { .values(form) .get_result::(conn) .await - .with_lemmy_type(LemmyErrorType::CouldntCreatePasswordResetRequest) + .with_lemmy_type(LemmyErrorType::CouldntCreate) } pub async fn read_and_delete(pool: &mut DbPool<'_>, token_: &str) -> LemmyResult { diff --git a/crates/db_schema/src/impls/person.rs b/crates/db_schema/src/impls/person.rs index 89ecd9a27..8235ee5f6 100644 --- a/crates/db_schema/src/impls/person.rs +++ b/crates/db_schema/src/impls/person.rs @@ -58,7 +58,7 @@ impl Crud for Person { .values(form) .get_result::(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::(conn) .await - .with_lemmy_type(LemmyErrorType::CouldntUpdatePerson) + .with_lemmy_type(LemmyErrorType::CouldntUpdate) } } @@ -88,7 +88,7 @@ impl Person { .set(form) .get_result::(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::(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::(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::(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::(conn) .await - .with_lemmy_type(LemmyErrorType::PersonBlockAlreadyExists) + .with_lemmy_type(LemmyErrorType::AlreadyExists) } async fn unblock(pool: &mut DbPool<'_>, form: &Self::Form) -> LemmyResult { @@ -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( diff --git a/crates/db_schema/src/impls/post.rs b/crates/db_schema/src/impls/post.rs index e96d90b2e..26d9a9979 100644 --- a/crates/db_schema/src/impls/post.rs +++ b/crates/db_schema/src/impls/post.rs @@ -59,7 +59,7 @@ impl Crud for Post { .values(form) .get_result::(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::(conn) .await - .with_lemmy_type(LemmyErrorType::CouldntUpdatePost) + .with_lemmy_type(LemmyErrorType::CouldntUpdate) } } @@ -100,7 +100,7 @@ impl Post { .set(form) .get_result::(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::(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::(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::(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::(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::(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::(conn) .await - .with_lemmy_type(LemmyErrorType::CouldntUpdatePost) + .with_lemmy_type(LemmyErrorType::CouldntUpdate) } pub fn local_url(&self, settings: &Settings) -> LemmyResult { 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 { 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::(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::(conn) .await - .with_lemmy_type(LemmyErrorType::CouldntSavePost) + .with_lemmy_type(LemmyErrorType::CouldntUpdate) } async fn unsave(pool: &mut DbPool<'_>, form: &Self::Form) -> LemmyResult { 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::(conn) .await - .with_lemmy_type(LemmyErrorType::CouldntHidePost) + .with_lemmy_type(LemmyErrorType::CouldntUpdate) } pub async fn unhide(pool: &mut DbPool<'_>, form: &PostHideForm) -> LemmyResult { @@ -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::(conn) .await - .with_lemmy_type(LemmyErrorType::CouldntUpdateReadComments) + .with_lemmy_type(LemmyErrorType::CouldntUpdate) } } diff --git a/crates/db_schema/src/impls/post_report.rs b/crates/db_schema/src/impls/post_report.rs index 73d8e0593..9efdf2bc3 100644 --- a/crates/db_schema/src/impls/post_report.rs +++ b/crates/db_schema/src/impls/post_report.rs @@ -26,7 +26,7 @@ impl Reportable for PostReport { .values(form) .get_result::(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) } } diff --git a/crates/db_schema/src/impls/private_message.rs b/crates/db_schema/src/impls/private_message.rs index 221b819ef..9160101ad 100644 --- a/crates/db_schema/src/impls/private_message.rs +++ b/crates/db_schema/src/impls/private_message.rs @@ -26,7 +26,7 @@ impl Crud for PrivateMessage { .values(form) .get_result::(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::(conn) .await - .with_lemmy_type(LemmyErrorType::CouldntUpdatePrivateMessage) + .with_lemmy_type(LemmyErrorType::CouldntUpdate) } } @@ -60,7 +60,7 @@ impl PrivateMessage { .set(form) .get_result::(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::(conn) .await - .with_lemmy_type(LemmyErrorType::CouldntUpdatePrivateMessage) + .with_lemmy_type(LemmyErrorType::CouldntUpdate) } } diff --git a/crates/db_schema/src/impls/private_message_report.rs b/crates/db_schema/src/impls/private_message_report.rs index 9316a4920..1041fa037 100644 --- a/crates/db_schema/src/impls/private_message_report.rs +++ b/crates/db_schema/src/impls/private_message_report.rs @@ -25,7 +25,7 @@ impl Reportable for PrivateMessageReport { .values(form) .get_result::(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<'_>, diff --git a/crates/db_schema/src/impls/registration_application.rs b/crates/db_schema/src/impls/registration_application.rs index f64b67c41..3ca160cee 100644 --- a/crates/db_schema/src/impls/registration_application.rs +++ b/crates/db_schema/src/impls/registration_application.rs @@ -24,7 +24,7 @@ impl Crud for RegistrationApplication { .values(form) .get_result::(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::(conn) .await - .with_lemmy_type(LemmyErrorType::CouldntUpdateRegistrationApplication) + .with_lemmy_type(LemmyErrorType::CouldntUpdate) } } diff --git a/crates/db_schema/src/impls/site.rs b/crates/db_schema/src/impls/site.rs index f99cdc33f..1f0800907 100644 --- a/crates/db_schema/src/impls/site.rs +++ b/crates/db_schema/src/impls/site.rs @@ -57,7 +57,7 @@ impl Crud for Site { .set(new_site) .get_result::(conn) .await - .with_lemmy_type(LemmyErrorType::CouldntUpdateSite) + .with_lemmy_type(LemmyErrorType::CouldntUpdate) } } diff --git a/crates/db_schema/src/impls/tag.rs b/crates/db_schema/src/impls/tag.rs index 04244ffc0..5a2df3efa 100644 --- a/crates/db_schema/src/impls/tag.rs +++ b/crates/db_schema/src/impls/tag.rs @@ -35,7 +35,7 @@ impl Crud for Tag { .values(form) .get_result::(conn) .await - .with_lemmy_type(LemmyErrorType::CouldntCreateTag) + .with_lemmy_type(LemmyErrorType::CouldntCreate) } async fn update(pool: &mut DbPool<'_>, pid: TagId, form: &Self::UpdateForm) -> LemmyResult { @@ -44,7 +44,7 @@ impl Crud for Tag { .set(form) .get_result::(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() }) diff --git a/crates/db_schema/src/impls/tagline.rs b/crates/db_schema/src/impls/tagline.rs index 1b89142d0..647b49e1b 100644 --- a/crates/db_schema/src/impls/tagline.rs +++ b/crates/db_schema/src/impls/tagline.rs @@ -21,7 +21,7 @@ impl Crud for Tagline { .values(form) .get_result::(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::(conn) .await - .with_lemmy_type(LemmyErrorType::CouldntUpdateTagline) + .with_lemmy_type(LemmyErrorType::CouldntUpdate) } } diff --git a/crates/utils/src/error.rs b/crates/utils/src/error.rs index d8a790cfa..3a941dc7c 100644 --- a/crates/utils/src/error.rs +++ b/crates/utils/src/error.rs @@ -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), diff --git a/crates/utils/src/response.rs b/crates/utils/src/response.rs index 51ea7198d..bf710bf4e 100644 --- a/crates/utils/src/response.rs +++ b/crates/utils/src/response.rs @@ -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 { - 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; }