From 38b332a6c3940c3156b27b88e15e9735bebce718 Mon Sep 17 00:00:00 2001 From: Clombrong Date: Thu, 26 Jun 2025 17:09:20 +0200 Subject: refactor(sasl): handle stream features outside of authenticate --- test/hello.ml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'test') 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 -- cgit v1.2.3