You've already forked AstralRinth
forked from didirus/AstralRinth
Add auto-reporting inappropriate text content (#387)
* Add initial support for blocking inappropriate text content To make something clear, **nothing** is automatically censored or deleted as a result of this pull request. This pull request is meant to add two things: - Regenerate new IDs (project, version, user, etc.) with profanity - Send reports to the moderators for new inappropriate content * Make it build * Fix logic issue Co-authored-by: Geometrically <18202329+Geometrically@users.noreply.github.com>
This commit is contained in:
@@ -204,6 +204,18 @@ pub async fn user_edit(
|
||||
)
|
||||
.execute(&mut *transaction)
|
||||
.await?;
|
||||
|
||||
crate::util::report::censor_check(
|
||||
&*username,
|
||||
None,
|
||||
None,
|
||||
Some(crate::database::models::ids::UserId::from(
|
||||
user_id,
|
||||
)),
|
||||
"User edited with inappropriate username".to_string(),
|
||||
&mut transaction,
|
||||
)
|
||||
.await?;
|
||||
} else {
|
||||
return Err(ApiError::InvalidInput(format!(
|
||||
"Username {} is taken!",
|
||||
@@ -224,6 +236,20 @@ pub async fn user_edit(
|
||||
)
|
||||
.execute(&mut *transaction)
|
||||
.await?;
|
||||
|
||||
if let Some(name) = name {
|
||||
crate::util::report::censor_check(
|
||||
&*name,
|
||||
None,
|
||||
None,
|
||||
Some(crate::database::models::ids::UserId::from(
|
||||
user_id,
|
||||
)),
|
||||
"User edited with inappropriate name".to_string(),
|
||||
&mut transaction,
|
||||
)
|
||||
.await?;
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(bio) = &new_user.bio {
|
||||
@@ -238,6 +264,20 @@ pub async fn user_edit(
|
||||
)
|
||||
.execute(&mut *transaction)
|
||||
.await?;
|
||||
|
||||
if let Some(bio) = bio {
|
||||
crate::util::report::censor_check(
|
||||
&*bio,
|
||||
None,
|
||||
None,
|
||||
Some(crate::database::models::ids::UserId::from(
|
||||
user_id,
|
||||
)),
|
||||
"User edited with inappropriate bio".to_string(),
|
||||
&mut transaction,
|
||||
)
|
||||
.await?;
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(email) = &new_user.email {
|
||||
|
||||
Reference in New Issue
Block a user