feat: initial ideas for content reporting
This commit is contained in:
@@ -10,6 +10,7 @@ mod invites;
|
|||||||
mod onboard;
|
mod onboard;
|
||||||
mod push;
|
mod push;
|
||||||
mod root;
|
mod root;
|
||||||
|
mod safety;
|
||||||
mod servers;
|
mod servers;
|
||||||
mod sync;
|
mod sync;
|
||||||
mod users;
|
mod users;
|
||||||
@@ -27,6 +28,7 @@ pub fn mount(mut rocket: Rocket<Build>) -> Rocket<Build> {
|
|||||||
"/servers" => servers::routes(),
|
"/servers" => servers::routes(),
|
||||||
"/invites" => invites::routes(),
|
"/invites" => invites::routes(),
|
||||||
"/custom" => customisation::routes(),
|
"/custom" => customisation::routes(),
|
||||||
|
"/safety" => safety::routes(),
|
||||||
"/auth/account" => rocket_rauth::routes::account::routes(),
|
"/auth/account" => rocket_rauth::routes::account::routes(),
|
||||||
"/auth/session" => rocket_rauth::routes::session::routes(),
|
"/auth/session" => rocket_rauth::routes::session::routes(),
|
||||||
"/auth/mfa" => rocket_rauth::routes::mfa::routes(),
|
"/auth/mfa" => rocket_rauth::routes::mfa::routes(),
|
||||||
@@ -105,6 +107,12 @@ fn custom_openapi_spec() -> OpenApi {
|
|||||||
"Emojis"
|
"Emojis"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "Platform Moderation",
|
||||||
|
"tags": [
|
||||||
|
"User Safety"
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "Authentication",
|
"name": "Authentication",
|
||||||
"tags": [
|
"tags": [
|
||||||
|
|||||||
11
crates/delta/src/routes/safety/mod.rs
Normal file
11
crates/delta/src/routes/safety/mod.rs
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
use rocket::Route;
|
||||||
|
use rocket_okapi::okapi::openapi3::OpenApi;
|
||||||
|
|
||||||
|
mod report_content;
|
||||||
|
|
||||||
|
pub fn routes() -> (Vec<Route>, OpenApi) {
|
||||||
|
openapi_get_routes_spec![
|
||||||
|
// Reports
|
||||||
|
report_content::report_content
|
||||||
|
]
|
||||||
|
}
|
||||||
52
crates/delta/src/routes/safety/report_content.rs
Normal file
52
crates/delta/src/routes/safety/report_content.rs
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
use revolt_quark::models::User;
|
||||||
|
use revolt_quark::{Db, Error, Result};
|
||||||
|
use serde::Deserialize;
|
||||||
|
use validator::Validate;
|
||||||
|
|
||||||
|
use rocket::serde::json::Json;
|
||||||
|
|
||||||
|
#[derive(Deserialize, JsonSchema)]
|
||||||
|
enum UserReportReason {
|
||||||
|
NoneSpecified,
|
||||||
|
InappropriateProfile,
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: move me into models
|
||||||
|
#[derive(Deserialize, JsonSchema)]
|
||||||
|
pub enum ReportedContent {
|
||||||
|
User {
|
||||||
|
id: String,
|
||||||
|
report_reason: UserReportReason,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
/// # Report Data
|
||||||
|
#[derive(Validate, Deserialize, JsonSchema)]
|
||||||
|
pub struct DataReportContent {
|
||||||
|
/// Content being reported
|
||||||
|
content: ReportedContent,
|
||||||
|
/// Additional report description
|
||||||
|
#[validate(length(min = 0, max = 1000))]
|
||||||
|
#[serde(default)]
|
||||||
|
additional_context: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// # Report Content
|
||||||
|
///
|
||||||
|
/// Report a piece of content to the moderation team.
|
||||||
|
#[openapi(tag = "User Safety")]
|
||||||
|
#[post("/report", data = "<data>")]
|
||||||
|
pub async fn report_content(db: &Db, user: User, data: Json<DataReportContent>) -> Result<()> {
|
||||||
|
let data = data.into_inner();
|
||||||
|
data.validate()
|
||||||
|
.map_err(|error| Error::FailedValidation { error })?;
|
||||||
|
|
||||||
|
// Bots cannot create reports
|
||||||
|
if user.bot.is_some() {
|
||||||
|
return Err(Error::IsBot);
|
||||||
|
}
|
||||||
|
|
||||||
|
// find the content and create the report here
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
@@ -126,6 +126,8 @@ fn resolve_bucket<'r>(request: &'r rocket::Request<'_>) -> (&'r str, Option<&'r
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
("swagger", _) => ("swagger", None),
|
("swagger", _) => ("swagger", None),
|
||||||
|
("safety", Some("report")) => ("safety_report", Some("report")),
|
||||||
|
("safety", _) => ("safety", None),
|
||||||
_ => ("any", None),
|
_ => ("any", None),
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -145,6 +147,8 @@ fn resolve_bucket_limit(bucket: &str) -> u8 {
|
|||||||
"auth_delete" => 255,
|
"auth_delete" => 255,
|
||||||
"default_avatar" => 255,
|
"default_avatar" => 255,
|
||||||
"swagger" => 100,
|
"swagger" => 100,
|
||||||
|
"safety" => 15,
|
||||||
|
"safety_report" => 3,
|
||||||
_ => 20,
|
_ => 20,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user