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

@@ -247,19 +247,52 @@ pub async fn auth_callback(
}
if let Some(username) = username {
User {
let new_user = User {
id: user_id,
github_id: Some(user.id as i64),
username,
username: username.clone(),
name: user.name,
email: user.email,
avatar_url: Some(user.avatar_url),
bio: user.bio,
created: OffsetDateTime::now_utc(),
role: Role::Developer.to_string(),
}
.insert(&mut transaction)
};
crate::util::report::censor_check(
&*username,
None,
None,
Some(user_id),
"New user's username is inappropriate".to_string(),
&mut transaction,
)
.await?;
if let Some(name) = &new_user.name {
crate::util::report::censor_check(
&*name,
None,
None,
Some(user_id),
"New user's name is inappropriate".to_string(),
&mut transaction,
)
.await?;
}
if let Some(bio) = &new_user.bio {
crate::util::report::censor_check(
&*bio,
None,
None,
Some(user_id),
"New user's bio is inappropriate".to_string(),
&mut transaction,
)
.await?;
}
new_user.insert(&mut transaction).await?;
}
}
}