feat(handlers): Add reply_thread handler for posts
This commit is contained in:
parent
148dfc39c8
commit
cf636077e6
2 changed files with 18 additions and 2 deletions
|
|
@ -83,9 +83,24 @@ pub fn submit_thread(state: State<AppState>, input: Form<NewThread>) -> Converse
|
|||
.and_then(move |res| {
|
||||
let thread = res?;
|
||||
info!("Created new thread \"{}\" with ID {}", thread.title, thread.id);
|
||||
Ok(HttpResponse::TemporaryRedirect()
|
||||
Ok(HttpResponse::SeeOther()
|
||||
.header("Location", format!("/thread/{}", thread.id))
|
||||
.finish())
|
||||
})
|
||||
.responder()
|
||||
}
|
||||
|
||||
/// This handler receives a "Reply"-form and redirects the user to the
|
||||
/// new post after creation.
|
||||
pub fn reply_thread(state: State<AppState>, input: Form<NewPost>) -> ConverseResponse {
|
||||
state.db.send(CreatePost(input.0))
|
||||
.from_err()
|
||||
.and_then(move |res| {
|
||||
let post = res?;
|
||||
info!("Posted reply {} to thread {}", post.id, post.thread_id);
|
||||
Ok(HttpResponse::SeeOther()
|
||||
.header("Location", format!("/thread/{}#post{}", post.thread_id, post.id))
|
||||
.finish())
|
||||
})
|
||||
.responder()
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue