redirect after successful posting
This commit is contained in:
parent
ad5b0f2034
commit
94cdecd7a4
1 changed files with 17 additions and 20 deletions
|
|
@ -250,15 +250,15 @@ let newthread_post request =
|
||||||
match file with
|
match file with
|
||||||
| [] -> render_unsafe "No image" request
|
| [] -> render_unsafe "No image" request
|
||||||
| _ :: _ :: _ -> render_unsafe "More than one image" request
|
| _ :: _ :: _ -> render_unsafe "More than one image" request
|
||||||
| [ file ] ->
|
| [ file ] -> (
|
||||||
let res =
|
match
|
||||||
match
|
Babillard.make_thread comment file (lat, lng) subject tags nick
|
||||||
Babillard.make_thread comment file (lat, lng) subject tags nick
|
with
|
||||||
with
|
| Ok thread_id ->
|
||||||
| Ok _post_id -> "Your thread was posted on the babillard!"
|
let adress = Format.sprintf "/babillard/%s" thread_id in
|
||||||
| Error e -> e
|
Dream.respond ~status:`See_Other ~headers:[ ("Location", adress) ]
|
||||||
in
|
"Your thread was posted on the babillard!"
|
||||||
render_unsafe res request ) )
|
| Error e -> render_unsafe e request ) ) )
|
||||||
| `Ok _ -> Dream.empty `Bad_Request
|
| `Ok _ -> Dream.empty `Bad_Request
|
||||||
| `Expired _
|
| `Expired _
|
||||||
| `Many_tokens _
|
| `Many_tokens _
|
||||||
|
|
@ -282,10 +282,7 @@ let thread_view request =
|
||||||
let thread_view = Babillard.view_thread thread_id in
|
let thread_view = Babillard.view_thread thread_id in
|
||||||
match thread_view with
|
match thread_view with
|
||||||
| Error e -> render_unsafe e request
|
| Error e -> render_unsafe e request
|
||||||
| Ok thread_view ->
|
| Ok thread_view -> Dream.html (Thread_page.f thread_view thread_id request)
|
||||||
Dream.respond
|
|
||||||
~headers:[ ("Content-Type", "html") ]
|
|
||||||
(Thread_page.f thread_view thread_id request)
|
|
||||||
|
|
||||||
(*form to reply to a thread *)
|
(*form to reply to a thread *)
|
||||||
let thread_post request =
|
let thread_post request =
|
||||||
|
|
@ -301,7 +298,7 @@ let thread_post request =
|
||||||
| `Ok
|
| `Ok
|
||||||
(("file", file)
|
(("file", file)
|
||||||
:: ("tags", [ (_, tags) ])
|
:: ("tags", [ (_, tags) ])
|
||||||
:: ("replyComment", [ (_, comment) ]) :: _ :: _ ) ->
|
:: ("replyComment", [ (_, comment) ]) :: _ :: _ ) -> (
|
||||||
let parent_id = Dream.param "thread_id" request in
|
let parent_id = Dream.param "thread_id" request in
|
||||||
let res =
|
let res =
|
||||||
match file with
|
match file with
|
||||||
|
|
@ -309,12 +306,12 @@ let thread_post request =
|
||||||
| [ file ] -> Babillard.make_post ~comment ~file ~tags ~parent_id nick
|
| [ file ] -> Babillard.make_post ~comment ~file ~tags ~parent_id nick
|
||||||
| _ :: _ :: _ -> Error "More than one image"
|
| _ :: _ :: _ -> Error "More than one image"
|
||||||
in
|
in
|
||||||
let msg =
|
match res with
|
||||||
match res with
|
| Ok post_id ->
|
||||||
| Ok _post_id -> "Your reply was posted"
|
let adress = Format.sprintf "/babillard/%s#%s" parent_id post_id in
|
||||||
| Error e -> e
|
Dream.respond ~status:`See_Other ~headers:[ ("Location", adress) ]
|
||||||
in
|
"Your thread was posted on the babillard!"
|
||||||
render_unsafe msg request
|
| Error e -> render_unsafe e request )
|
||||||
| `Ok _ -> Dream.empty `Bad_Request
|
| `Ok _ -> Dream.empty `Bad_Request
|
||||||
| `Expired _
|
| `Expired _
|
||||||
| `Many_tokens _
|
| `Many_tokens _
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue