From 273073ba115f55db034bc425af566df4f2b5a695 Mon Sep 17 00:00:00 2001 From: hole-thu Date: Thu, 21 Jul 2022 14:05:47 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=BE=E6=8A=A5=E6=97=B6=E6=89=8B=E5=8A=A8?= =?UTF-8?q?=E9=80=89=E6=8B=A9=E6=98=AF=E5=90=A6=E9=9A=90=E8=97=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/operation.rs | 7 +++++-- src/api/post.rs | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) 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;