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:
Emma Cypress ⚘
2022-07-10 01:51:55 +00:00
committed by GitHub
parent 18d1bc56fd
commit 68f7dc9512
10 changed files with 216 additions and 6 deletions

View File

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