Better logging in new_comment route
This commit is contained in:
parent
fb42380f9c
commit
70c8ff28a1
1 changed files with 15 additions and 3 deletions
|
@ -42,7 +42,6 @@ pub async fn new_comment(
|
||||||
}
|
}
|
||||||
|
|
||||||
let claims = user_claims.unwrap();
|
let claims = user_claims.unwrap();
|
||||||
info!("User {:?} created a new comment", &claims.sub);
|
|
||||||
|
|
||||||
let content = data.content.clone();
|
let content = data.content.clone();
|
||||||
let username = claims.sub.clone();
|
let username = claims.sub.clone();
|
||||||
|
@ -54,6 +53,13 @@ pub async fn new_comment(
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.id;
|
.id;
|
||||||
|
|
||||||
|
info!(
|
||||||
|
"User {:?}, with id {:?} is creating a new comment",
|
||||||
|
&claims.sub, userid
|
||||||
|
);
|
||||||
|
|
||||||
|
info!("Creating a new comment {:?}", &data);
|
||||||
|
|
||||||
let success = db_new_comment(
|
let success = db_new_comment(
|
||||||
&state.pool,
|
&state.pool,
|
||||||
data.parent_post_id,
|
data.parent_post_id,
|
||||||
|
@ -64,7 +70,13 @@ pub async fn new_comment(
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
match success {
|
match success {
|
||||||
true => Ok(HttpResponse::Ok().json("Success")),
|
true => {
|
||||||
false => Ok(HttpResponse::BadRequest().json("Error")),
|
info!("User {:?} created a new comment", &claims.sub);
|
||||||
|
Ok(HttpResponse::Ok().json("Successfully created comment"))
|
||||||
|
}
|
||||||
|
false => {
|
||||||
|
info!("User {:?} failed to create a new comment", &claims.sub);
|
||||||
|
Ok(HttpResponse::BadRequest().json("Failed to create comment"))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue