diff --git a/src/api/operation.rs b/src/api/operation.rs index dcfd252..374dfac 100644 --- a/src/api/operation.rs +++ b/src/api/operation.rs @@ -95,6 +95,7 @@ pub struct ReportInput { pid: i32, #[field(validate = len(0..1000))] reason: String, + should_hide: Option, } #[post("/report", data = "")] @@ -113,8 +114,10 @@ pub async fn report(ri: Form, user: CurrentUser, db: Db, rconn: Rds (!ri.reason.is_empty()).then(|| ()).ok_or(NoReason)?; let mut p = Post::get(&db, &rconn, ri.pid).await?; - update!(p, posts, &db, { is_reported, to true }); - p.refresh_cache(&rconn, false).await; + if ri.should_hide.is_some() { + update!(p, posts, &db, { is_reported, to true }); + p.refresh_cache(&rconn, false).await; + } Systemlog { user_hash: user.namehash.to_string(), diff --git a/src/api/post.rs b/src/api/post.rs index 6a8615a..c6298b8 100644 --- a/src/api/post.rs +++ b/src/api/post.rs @@ -1,6 +1,6 @@ use crate::api::comment::{c2output, CommentOutput}; use crate::api::vote::get_poll_dict; -use crate::api::{CurrentUser, JsonApi, PolicyError::*, Api, Ugc}; +use crate::api::{Api, CurrentUser, JsonApi, PolicyError::*, Ugc}; use crate::cache::*; use crate::db_conn::Db; use crate::libs::diesel_logger::LoggingConnection;