举报时手动选择是否隐藏
This commit is contained in:
@@ -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(),
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
Reference in New Issue
Block a user