clean code, fix html escape in discuss

This commit is contained in:
zapashcanon 2022-04-06 16:15:13 +02:00
parent e890b93ba6
commit 190d086206
No known key found for this signature in database
GPG key ID: 8981C3C62D1D28F1

View file

@ -44,7 +44,6 @@ let () =
(** let's find who the user is talking to so we can know if they're dangerous *)
let find_comrades user_id =
let open Syntax in
let^ comrades = Db.collect_list Q.find_comrades (user_id, user_id) in
let comrades =
List.map (fun (l, r) -> if l = user_id then r else l) comrades
@ -53,7 +52,6 @@ let find_comrades user_id =
(** find all messages between two товарищи *)
let find_messages k1 k2 =
let open Syntax in
let^ comrades = Db.collect_list Q.find_messages ((k1, k2), (k2, k1)) in
Ok comrades
@ -90,7 +88,7 @@ let pp_discussion (request, user_id, comrade_id) =
let pp_one_msg fmt (from_id, msg) =
Format.fprintf fmt "<li>%s | %s</li>"
(if from_id = user_id then user_nick else comrade_nick)
msg
(Dream.html_escape msg)
in
let pp_all_msg fmt msg =
Format.fprintf fmt "<ul>%a</ul>"
@ -116,7 +114,6 @@ let renderone request =
pp_discussion (request, user_id, comrade_id) )
let insert_msg from_id to_id msg =
let open Syntax in
let^ () = Db.exec Q.insert_msg (from_id, to_id, msg) in
Ok ()