diff --git a/crates/api_crud/src/comment/create.rs b/crates/api_crud/src/comment/create.rs index 7f7a0441a..713292314 100644 --- a/crates/api_crud/src/comment/create.rs +++ b/crates/api_crud/src/comment/create.rs @@ -16,7 +16,7 @@ use lemmy_api_common::{ }, }; use lemmy_db_schema::{ - impls::actor_language::default_post_language, + impls::actor_language::validate_post_language, source::{ comment::{Comment, CommentInsertForm, CommentLike, CommentLikeForm}, comment_reply::{CommentReply, CommentReplyUpdateForm}, @@ -87,7 +87,7 @@ pub async fn create_comment( check_comment_depth(parent)?; } - let language_id = default_post_language( + let language_id = validate_post_language( &mut context.pool(), data.language_id, community_id, diff --git a/crates/api_crud/src/comment/update.rs b/crates/api_crud/src/comment/update.rs index 6e320b2db..0afe3390d 100644 --- a/crates/api_crud/src/comment/update.rs +++ b/crates/api_crud/src/comment/update.rs @@ -13,7 +13,7 @@ use lemmy_api_common::{ }, }; use lemmy_db_schema::{ - impls::actor_language::default_post_language, + impls::actor_language::validate_post_language, source::{ comment::{Comment, CommentUpdateForm}, local_site::LocalSite, @@ -55,7 +55,7 @@ pub async fn update_comment( Err(LemmyErrorType::NoCommentEditAllowed)? } - let language_id = default_post_language( + let language_id = validate_post_language( &mut context.pool(), data.language_id, orig_comment.community.id, diff --git a/crates/api_crud/src/post/create.rs b/crates/api_crud/src/post/create.rs index f8fdc592e..1ca6508be 100644 --- a/crates/api_crud/src/post/create.rs +++ b/crates/api_crud/src/post/create.rs @@ -17,7 +17,7 @@ use lemmy_api_common::{ }, }; use lemmy_db_schema::{ - impls::actor_language::default_post_language, + impls::actor_language::validate_post_language, source::{ community::Community, local_site::LocalSite, @@ -103,7 +103,7 @@ pub async fn create_post( .await?; } - let language_id = default_post_language( + let language_id = validate_post_language( &mut context.pool(), data.language_id, community_id, diff --git a/crates/api_crud/src/post/update.rs b/crates/api_crud/src/post/update.rs index e04712664..645774b53 100644 --- a/crates/api_crud/src/post/update.rs +++ b/crates/api_crud/src/post/update.rs @@ -15,7 +15,7 @@ use lemmy_api_common::{ }, }; use lemmy_db_schema::{ - impls::actor_language::default_post_language, + impls::actor_language::validate_post_language, source::{ community::Community, local_site::LocalSite, @@ -101,7 +101,7 @@ pub async fn update_post( Err(LemmyErrorType::NoPostEditAllowed)? } - let language_id = default_post_language( + let language_id = validate_post_language( &mut context.pool(), data.language_id, orig_post.community_id, diff --git a/crates/db_schema/src/impls/actor_language.rs b/crates/db_schema/src/impls/actor_language.rs index 47a62c027..b4575d432 100644 --- a/crates/db_schema/src/impls/actor_language.rs +++ b/crates/db_schema/src/impls/actor_language.rs @@ -319,7 +319,7 @@ impl CommunityLanguage { } } -pub async fn default_post_language( +pub async fn validate_post_language( pool: &mut DbPool<'_>, language_id: Option, community_id: CommunityId, @@ -622,7 +622,7 @@ mod tests { LocalUserLanguage::update(pool, test_langs2, local_user.id).await?; // no overlap in user/community languages, so defaults to undetermined - let def1 = default_post_language(pool, None, community.id, local_user.id).await; + let def1 = validate_post_language(pool, None, community.id, local_user.id).await; assert_eq!( Some(LemmyErrorType::LanguageNotAllowed), def1.err().map(|e| e.error_type) @@ -638,7 +638,7 @@ mod tests { LocalUserLanguage::update(pool, test_langs3, local_user.id).await?; // this time, both have ru as common lang - let def2 = default_post_language(pool, None, community.id, local_user.id).await?; + let def2 = validate_post_language(pool, None, community.id, local_user.id).await?; assert_eq!(ru, def2); Person::delete(pool, person.id).await?;