This commit is contained in:
Felix Ableitner 2024-11-12 10:58:37 +01:00
parent 0337816803
commit 163bc3ffc4
5 changed files with 11 additions and 11 deletions

View file

@ -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,

View file

@ -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,

View file

@ -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,

View file

@ -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,

View file

@ -319,7 +319,7 @@ impl CommunityLanguage {
}
}
pub async fn default_post_language(
pub async fn validate_post_language(
pool: &mut DbPool<'_>,
language_id: Option<LanguageId>,
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?;