From 52cc186949f0bf94336a7f81dec4f7dee13782ab Mon Sep 17 00:00:00 2001 From: Clombrong Date: Tue, 3 Jun 2025 02:19:13 +0200 Subject: fix(open_stanza): use Markup.ml to construct the default open stanza --- portal/lib/ws/portal.ml | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/portal/lib/ws/portal.ml b/portal/lib/ws/portal.ml index f5491ca..e0c76b4 100644 --- a/portal/lib/ws/portal.ml +++ b/portal/lib/ws/portal.ml @@ -14,13 +14,20 @@ let stanza_open ?from domain = If [from] is specified, the stanza has the from parameter. *) - Printf.sprintf - {||} - domain - (Option.fold ~none:"" ~some:(fun jid -> {|from="|} ^ jid ^ {|"|}) from) + let open Markup in + let stanza = + let attributes = + let open Option in + [(("", "xmlns"), "urn:ietf:params:xml:ns:xmpp-framing"); + (("", "to"), domain)] + @ (map (fun jid -> (("", "from"), jid)) from |> to_list) + @ [(("", "version"), "1.0")] + in + [`Start_element + (("urn:ietf:params:xml:ns:xmpp-framing", "open"), + attributes); + `End_element] + in stanza |> of_list |> write_xml |> to_string let stanza_close = {||} -- cgit v1.2.3