accept new threads without image
This commit is contained in:
parent
a40682139a
commit
bf495bfe7d
1 changed files with 17 additions and 15 deletions
|
|
@ -179,15 +179,17 @@ let newthread_post ~board request =
|
||||||
| None, _ -> render_unsafe "Invalide coordinate" request
|
| None, _ -> render_unsafe "Invalide coordinate" request
|
||||||
| _, None -> render_unsafe "Invalide coordinate" request
|
| _, None -> render_unsafe "Invalide coordinate" request
|
||||||
| Some lat, Some lng -> (
|
| Some lat, Some lng -> (
|
||||||
|
let res =
|
||||||
match file with
|
match file with
|
||||||
| [] -> render_unsafe "No image" request
|
| [] ->
|
||||||
| _ :: _ :: _ -> render_unsafe "More than one image" request
|
Babillard.make_op ~comment ~lat ~lng ~subject ~tags ~board nick
|
||||||
| [ (image_name, image_content) ] -> (
|
| _ :: _ :: _ -> Error "More than one image"
|
||||||
|
| [ (image_name, image_content) ] ->
|
||||||
let image = (image_name, image_content, alt) in
|
let image = (image_name, image_content, alt) in
|
||||||
match
|
|
||||||
Babillard.make_op ~comment ~image ~lat ~lng ~subject ~tags ~board
|
Babillard.make_op ~comment ~image ~lat ~lng ~subject ~tags ~board
|
||||||
nick
|
nick
|
||||||
with
|
in
|
||||||
|
match res with
|
||||||
| Ok thread_id ->
|
| Ok thread_id ->
|
||||||
let adress =
|
let adress =
|
||||||
Format.asprintf "/%a/%s" Babillard.pp_board board thread_id
|
Format.asprintf "/%a/%s" Babillard.pp_board board thread_id
|
||||||
|
|
@ -195,7 +197,7 @@ let newthread_post ~board request =
|
||||||
Dream.respond ~status:`See_Other
|
Dream.respond ~status:`See_Other
|
||||||
~headers:[ ("Location", adress) ]
|
~headers:[ ("Location", adress) ]
|
||||||
"Your thread was posted!"
|
"Your thread was posted!"
|
||||||
| Error e -> render_unsafe e 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