Revert "Add auto-reporting inappropriate text content" (#397)

* Revert "Add auto-reporting inappropriate text content (#387)"

This reverts commit 68f7dc9512.

* Maybe don't revert the whole thing
This commit is contained in:
Emma Cypress ⚘
2022-07-10 17:02:41 +00:00
committed by GitHub
parent 02c3894fc9
commit 6614b56298
7 changed files with 4 additions and 199 deletions

View File

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

View File

@@ -387,16 +387,6 @@ pub async fn project_edit(
)
.execute(&mut *transaction)
.await?;
crate::util::report::censor_check(
&*title,
Some(project_item.inner.id),
None,
None,
"Project edited with inappropriate title".to_string(),
&mut transaction,
)
.await?;
}
if let Some(description) = &new_project.description {
@@ -418,16 +408,6 @@ pub async fn project_edit(
)
.execute(&mut *transaction)
.await?;
crate::util::report::censor_check(
&*description,
Some(project_item.inner.id),
None,
None,
"Project edited with inappropriate description".to_string(),
&mut transaction,
)
.await?;
}
if let Some(status) = &new_project.status {
@@ -699,16 +679,6 @@ pub async fn project_edit(
));
}
}
crate::util::report::censor_check(
&*slug,
Some(project_item.inner.id),
None,
None,
"Project edited with inappropriate slug".to_string(),
&mut transaction,
)
.await?;
}
sqlx::query!(
@@ -921,16 +891,6 @@ pub async fn project_edit(
)
.execute(&mut *transaction)
.await?;
crate::util::report::censor_check(
&*body,
Some(project_item.inner.id),
None,
None,
"Project edited with inappropriate body".to_string(),
&mut transaction,
)
.await?;
}
transaction.commit().await?;

View File

@@ -204,18 +204,6 @@ 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!",
@@ -236,20 +224,6 @@ 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 {
@@ -264,20 +238,6 @@ 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 {

View File

@@ -393,28 +393,6 @@ async fn version_create_inner(
.insert_many(users, &mut *transaction)
.await?;
if let Some(version_body) = version_data.version_body {
crate::util::report::censor_check(
&*version_body,
None,
Some(models::ids::VersionId::from(version_id)),
None,
"Version created with inappropriate changelog".to_string(),
&mut *transaction,
)
.await?;
}
crate::util::report::censor_check(
&*version_data.version_title,
None,
Some(models::ids::VersionId::from(version_id)),
None,
"Version created with inappropriate name".to_string(),
&mut *transaction,
)
.await?;
let response = Version {
id: builder.version_id.into(),
project_id: builder.project_id.into(),

View File

@@ -1,6 +1,5 @@
use super::ApiError;
use crate::database;
use crate::database::models::VersionId;
use crate::models;
use crate::models::projects::{Dependency, Version};
use crate::models::teams::Permissions;
@@ -248,16 +247,6 @@ pub async fn version_edit(
)
.execute(&mut *transaction)
.await?;
crate::util::report::censor_check(
&*name,
None,
Some(VersionId::from(version_id)),
None,
"Version edited with inappropriate name".to_string(),
&mut transaction,
)
.await?;
}
if let Some(number) = &new_version.version_number {
@@ -474,16 +463,6 @@ pub async fn version_edit(
)
.execute(&mut *transaction)
.await?;
crate::util::report::censor_check(
&*body,
None,
Some(VersionId::from(version_id)),
None,
"Version edited with inappropriate changelog".to_string(),
&mut transaction,
)
.await?;
}
if let Some(downloads) = &new_version.downloads {

View File

@@ -2,7 +2,6 @@ pub mod auth;
pub mod env;
pub mod ext;
pub mod guards;
pub mod report;
pub mod routes;
pub mod time_ser;
pub mod validate;

View File

@@ -1,38 +0,0 @@
use crate::database::models::categories::ReportType;
use crate::database::models::report_item::Report;
use crate::database::models::{
generate_report_id, DatabaseError, ProjectId, UserId, VersionId,
};
use crate::models::users::DELETED_USER;
use censor::Censor;
use time::OffsetDateTime;
pub async fn censor_check(
text: &str,
project: Option<ProjectId>,
version: Option<VersionId>,
user: Option<UserId>,
report_text: String,
mut transaction: &mut sqlx::Transaction<'_, sqlx::Postgres>,
) -> Result<(), DatabaseError> {
let censor = Censor::Standard + Censor::Sex;
if censor.check(text) {
let report_type =
ReportType::get_id("inappropriate", &mut *transaction)
.await?
.expect("No database entry for 'inappropriate' report type");
Report {
id: generate_report_id(&mut transaction).await?,
report_type_id: report_type,
project_id: project,
version_id: version,
user_id: user,
body: report_text,
reporter: UserId::from(DELETED_USER),
created: OffsetDateTime::now_utc(),
}
.insert(&mut transaction)
.await?;
}
Ok(())
}