举报时手动选择是否隐藏

This commit is contained in:
2022-07-21 14:05:47 +08:00
parent 58794a479d
commit 273073ba11
2 changed files with 6 additions and 3 deletions

View File

@@ -95,6 +95,7 @@ pub struct ReportInput {
pid: i32, pid: i32,
#[field(validate = len(0..1000))] #[field(validate = len(0..1000))]
reason: String, reason: String,
should_hide: Option<u8>,
} }
#[post("/report", data = "<ri>")] #[post("/report", data = "<ri>")]
@@ -113,8 +114,10 @@ pub async fn report(ri: Form<ReportInput>, user: CurrentUser, db: Db, rconn: Rds
(!ri.reason.is_empty()).then(|| ()).ok_or(NoReason)?; (!ri.reason.is_empty()).then(|| ()).ok_or(NoReason)?;
let mut p = Post::get(&db, &rconn, ri.pid).await?; let mut p = Post::get(&db, &rconn, ri.pid).await?;
if ri.should_hide.is_some() {
update!(p, posts, &db, { is_reported, to true }); update!(p, posts, &db, { is_reported, to true });
p.refresh_cache(&rconn, false).await; p.refresh_cache(&rconn, false).await;
}
Systemlog { Systemlog {
user_hash: user.namehash.to_string(), user_hash: user.namehash.to_string(),

View File

@@ -1,6 +1,6 @@
use crate::api::comment::{c2output, CommentOutput}; use crate::api::comment::{c2output, CommentOutput};
use crate::api::vote::get_poll_dict; 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::cache::*;
use crate::db_conn::Db; use crate::db_conn::Db;
use crate::libs::diesel_logger::LoggingConnection; use crate::libs::diesel_logger::LoggingConnection;