accept new threads without image

This commit is contained in:
Swrup 2022-01-29 10:21:53 +01:00
parent a40682139a
commit bf495bfe7d

View file

@ -179,23 +179,25 @@ 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 -> (
match file with let res =
| [] -> render_unsafe "No image" request match file with
| _ :: _ :: _ -> render_unsafe "More than one image" request | [] ->
| [ (image_name, image_content) ] -> ( Babillard.make_op ~comment ~lat ~lng ~subject ~tags ~board nick
let image = (image_name, image_content, alt) in | _ :: _ :: _ -> Error "More than one image"
match | [ (image_name, image_content) ] ->
let image = (image_name, image_content, alt) in
Babillard.make_op ~comment ~image ~lat ~lng ~subject ~tags ~board Babillard.make_op ~comment ~image ~lat ~lng ~subject ~tags ~board
nick nick
with in
| Ok thread_id -> match res with
let adress = | Ok thread_id ->
Format.asprintf "/%a/%s" Babillard.pp_board board thread_id let adress =
in Format.asprintf "/%a/%s" Babillard.pp_board board thread_id
Dream.respond ~status:`See_Other in
~headers:[ ("Location", adress) ] Dream.respond ~status:`See_Other
"Your thread was posted!" ~headers:[ ("Location", adress) ]
| Error e -> render_unsafe e request ) ) ) "Your thread was posted!"
| Error e -> render_unsafe e request ) )
| `Ok _ -> Dream.empty `Bad_Request | `Ok _ -> Dream.empty `Bad_Request
| `Expired _ | `Expired _
| `Many_tokens _ | `Many_tokens _