diff options
author | Vincent Ambo <tazjin@gmail.com> | 2018-04-15T10·38+0200 |
---|---|---|
committer | Vincent Ambo <tazjin@gmail.com> | 2018-04-15T10·38+0200 |
commit | 9cee48f2dac7400fc0df78b8790ff1e1600a632e (patch) | |
tree | cd21cdad21f6dc8c046be7819564ba8d80005f00 /src/handlers.rs | |
parent | 02a466a28be4c6fdcd88075d6345841759ff630c (diff) |
feat(handlers): Determine whether current user can edit a post
Diffstat (limited to 'src/handlers.rs')
-rw-r--r-- | src/handlers.rs | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/handlers.rs b/src/handlers.rs index ccb01eb3c803..f4346f26c6c3 100644 --- a/src/handlers.rs +++ b/src/handlers.rs @@ -60,11 +60,18 @@ pub fn forum_index(state: State<AppState>) -> ConverseResponse { } /// This handler retrieves and displays a single forum thread. -pub fn forum_thread(state: State<AppState>, thread_id: Path<i32>) -> ConverseResponse { +pub fn forum_thread(state: State<AppState>, + mut req: HttpRequest<AppState>, + thread_id: Path<i32>) -> ConverseResponse { let id = thread_id.into_inner(); + let user = req.session().get(AUTHOR) + .unwrap_or_else(|_| None) + .map(|a: Author| a.email); + state.db.send(GetThread(id)) .flatten() .and_then(move |res| state.renderer.send(ThreadPage { + current_user: user, thread: res.0, posts: res.1, }).from_err()) |