diff options
author | Clombrong <cromblong@egregore.fun> | 2025-06-26 17:09:20 +0200 |
---|---|---|
committer | Clombrong <cromblong@egregore.fun> | 2025-06-26 21:40:53 +0200 |
commit | 38b332a6c3940c3156b27b88e15e9735bebce718 (patch) | |
tree | b8c3cacfe0f81d879328dafefb442e446a8fae73 /test/hello.ml | |
parent | fada25b1563d3d1da08da3ce8c47fa5b820cfbd8 (diff) |
refactor(sasl): handle stream features outside of authenticate
Diffstat (limited to 'test/hello.ml')
-rw-r--r-- | test/hello.ml | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/test/hello.ml b/test/hello.ml index 5bc38ad..392c3a1 100644 --- a/test/hello.ml +++ b/test/hello.ml @@ -2,8 +2,8 @@ open! Lwt.Syntax open! Lwt.Infix open! Flesh -let program (stream, push) config = - let+ _auth = Sasl.authenticate (stream, push) config +let program (stream, push) config (features : Stream.features) = + let+ _auth = Sasl.authenticate (stream, push) config features.mechanisms in begin match _auth with | Error (NotAuthorized, Some (_, text)) -> print_endline ("Not authorized: " ^ text) | Error (MalformedRequest, Some (_, text)) -> print_endline ("Malformed request: " ^ text) @@ -21,8 +21,9 @@ let main = in let domain = (List.nth (String.split_on_char '@' config.jid) 1) in let* stream, push = Portal.connect domain in let* _id = Portal.header domain (stream, push) in + let* features = Xml.get stream >|= Stream.parse_features in Lwt.catch - (fun () -> program (stream, push) config >|= (fun () -> push None)) + (fun () -> program (stream, push) config features >|= (fun () -> push None)) (fun exn -> push None; (* I suspect JavaScript's [wrap_callback] swallows the Exceptions thrown by |