feat(errors): Introduce error variant for thread closing

(other minor change: log the user ID when invalid post editing
requests were constructed)
This commit is contained in:
Vincent Ambo 2018-05-26 10:53:31 +02:00 committed by Vincent Ambo
parent c2a551146d
commit a14ece6af3
2 changed files with 20 additions and 6 deletions

View file

@ -207,7 +207,10 @@ pub fn edit_form(state: State<AppState>,
return Ok(post);
}
Err(ConverseError::PostEditForbidden { id: post.id })
Err(ConverseError::PostEditForbidden {
user: user_id,
id: post.id,
})
})
.and_then(move |post| {
let edit_msg = EditPostPage {
@ -236,7 +239,10 @@ pub fn edit_post(state: State<AppState>,
if user_id != 1 && post.user_id == user_id {
Ok(())
} else {
Err(ConverseError::PostEditForbidden { id: post.id })
Err(ConverseError::PostEditForbidden {
user: user_id,
id: post.id,
})
}
})
.and_then(move |_| state.db.send(update.0).from_err())