remove todos
This commit is contained in:
parent
6587e1867f
commit
1cbc32b9b6
2 changed files with 3 additions and 10 deletions
|
|
@ -154,7 +154,6 @@ let add_plant_post request =
|
||||||
| None -> render_unsafe "Not logged in" request
|
| None -> render_unsafe "Not logged in" request
|
||||||
| Some nick -> (
|
| Some nick -> (
|
||||||
match%lwt Dream.multipart request with
|
match%lwt Dream.multipart request with
|
||||||
(* TODO match pas bien la form :s *)
|
|
||||||
| `Ok [ ("files", files); ("tags", tags) ]
|
| `Ok [ ("files", files); ("tags", tags) ]
|
||||||
| `Ok (("files", files) :: ("tags", tags) :: _ :: _) -> (
|
| `Ok (("files", files) :: ("tags", tags) :: _ :: _) -> (
|
||||||
match tags with
|
match tags with
|
||||||
|
|
|
||||||
12
src/user.ml
12
src/user.ml
|
|
@ -1,7 +1,7 @@
|
||||||
type t =
|
type t =
|
||||||
{ nick : string
|
{ nick : string
|
||||||
; password : string
|
; password : string
|
||||||
; email : string (* TODO: make email optional ? *)
|
; email : string
|
||||||
; bio : string
|
; bio : string
|
||||||
; avatar : string
|
; avatar : string
|
||||||
}
|
}
|
||||||
|
|
@ -290,7 +290,6 @@ let get_avatar nick =
|
||||||
match avatar with
|
match avatar with
|
||||||
| Some avatar ->
|
| Some avatar ->
|
||||||
if String.length avatar = 0 then
|
if String.length avatar = 0 then
|
||||||
(* TODO default avatar *)
|
|
||||||
Ok None
|
Ok None
|
||||||
else
|
else
|
||||||
Ok (Some avatar)
|
Ok (Some avatar)
|
||||||
|
|
@ -310,8 +309,6 @@ let upload_avatar files nick =
|
||||||
match files with
|
match files with
|
||||||
| [] -> Error "No file provided"
|
| [] -> Error "No file provided"
|
||||||
| [ (_, content) ] -> (
|
| [ (_, content) ] -> (
|
||||||
(* TODO validate image data with konan etc*)
|
|
||||||
(* TODO file_name in db??*)
|
|
||||||
let valid = true in
|
let valid = true in
|
||||||
if not valid then
|
if not valid then
|
||||||
Error "Invalid image"
|
Error "Invalid image"
|
||||||
|
|
@ -322,13 +319,13 @@ let upload_avatar files nick =
|
||||||
| Error e -> Error (Format.sprintf "db error: %s" (Caqti_error.show e)) )
|
| Error e -> Error (Format.sprintf "db error: %s" (Caqti_error.show e)) )
|
||||||
| _files -> Error "More than one file provided"
|
| _files -> Error "More than one file provided"
|
||||||
|
|
||||||
(* TODO *)
|
(* TODO do image validation: length and MIME types with conan*)
|
||||||
|
(* TODO do the same for text input: check length, forbidden chars and have a forbidden words filter*)
|
||||||
let is_valid_image _content = true
|
let is_valid_image _content = true
|
||||||
|
|
||||||
let add_plant tags files nick =
|
let add_plant tags files nick =
|
||||||
match files with
|
match files with
|
||||||
| files -> (
|
| files -> (
|
||||||
(* TODO parse tags*)
|
|
||||||
let tags_len = String.length tags in
|
let tags_len = String.length tags in
|
||||||
if tags_len > 1000 then
|
if tags_len > 1000 then
|
||||||
Error "tags too long"
|
Error "tags too long"
|
||||||
|
|
@ -343,8 +340,6 @@ let add_plant tags files nick =
|
||||||
Error "Invalid image"
|
Error "Invalid image"
|
||||||
else
|
else
|
||||||
(* add plant to db *)
|
(* add plant to db *)
|
||||||
|
|
||||||
(* TODO make a plant_id *)
|
|
||||||
let plant_id = Uuidm.to_string (Uuidm.v4_gen random_state ()) in
|
let plant_id = Uuidm.to_string (Uuidm.v4_gen random_state ()) in
|
||||||
(* add to plant_id <-> user*)
|
(* add to plant_id <-> user*)
|
||||||
let res_plant = Db.exec Q.upload_plant_id (plant_id, nick) in
|
let res_plant = Db.exec Q.upload_plant_id (plant_id, nick) in
|
||||||
|
|
@ -352,7 +347,6 @@ let add_plant tags files nick =
|
||||||
| Error e -> Error (Format.sprintf "db error: %s" (Caqti_error.show e))
|
| Error e -> Error (Format.sprintf "db error: %s" (Caqti_error.show e))
|
||||||
| Ok _ -> (
|
| Ok _ -> (
|
||||||
(* add to plant_id <-> tag table*)
|
(* add to plant_id <-> tag table*)
|
||||||
(* TODO iter on tag_list*)
|
|
||||||
let res_tags =
|
let res_tags =
|
||||||
List.map
|
List.map
|
||||||
(fun tag -> Db.exec Q.upload_plant_tag (plant_id, tag))
|
(fun tag -> Db.exec Q.upload_plant_tag (plant_id, tag))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue