use postgresql
This commit is contained in:
@@ -18,11 +18,12 @@ pub async fn delete(di: Form<DeleteInput>, user: CurrentUser, db: Db) -> API<Val
|
||||
"cid" => {
|
||||
let c = Comment::get(&db, di.id).await.m()?;
|
||||
c.soft_delete(&user, &db).await?;
|
||||
let p = Post::get(&db, c.post_id).await.m()?;
|
||||
p.change_n_comments(&db, -1).await.m()?;
|
||||
}
|
||||
"pid" => {
|
||||
let p = Post::get(&db, di.id).await.m()?;
|
||||
p.soft_delete(&user, &db).await?;
|
||||
p.change_n_comments(&db, -1).await.m()?;
|
||||
}
|
||||
_ => return Err(APIError::PcError(NotAllowed)),
|
||||
}
|
||||
|
||||
@@ -140,7 +140,7 @@ pub async fn get_list(
|
||||
|
||||
#[post("/dopost", data = "<poi>")]
|
||||
pub async fn publish_post(poi: Form<PostInput>, user: CurrentUser, db: Db) -> JsonAPI {
|
||||
let r = Post::create(
|
||||
let p = Post::create(
|
||||
&db,
|
||||
NewPost {
|
||||
content: poi.text.to_string(),
|
||||
@@ -156,7 +156,6 @@ pub async fn publish_post(poi: Form<PostInput>, user: CurrentUser, db: Db) -> Js
|
||||
.m()?;
|
||||
// TODO: attention
|
||||
Ok(json!({
|
||||
"data": r,
|
||||
"code": 0
|
||||
}))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user