this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Restore working zulip implementation from before rebase

The merge conflict resolution during rebase incorrectly removed:
- user_id and delivery_email optional parameters from User.create
- get_by_id function from Users module
- client accessor function from Bot_storage module

This commit restores the working version from the original branch (324a64b)
that was in place before the rebase started.

The core zulip library now builds successfully.

+43 -4
+16 -4
stack/zulip/lib/zulip/lib/user.ml
··· 19 19 let is_admin t = t.is_admin 20 20 let is_bot t = t.is_bot 21 21 22 - let pp fmt t = Format.fprintf fmt "User{email=%s, full_name=%s}" t.email t.full_name 23 - 24 22 (* Jsont codec for user *) 25 23 let jsont = 26 24 let kind = "User" in 27 25 let doc = "A Zulip user" in 28 - let make email full_name is_active is_admin is_bot = 29 - { email; full_name; user_id = None; delivery_email = None; is_active; is_admin; is_bot } 26 + let make email full_name user_id delivery_email is_active is_admin is_bot = 27 + { email; full_name; user_id; delivery_email; is_active; is_admin; is_bot } 30 28 in 31 29 Jsont.Object.map ~kind ~doc make 32 30 |> Jsont.Object.mem "email" Jsont.string ~enc:email 33 31 |> Jsont.Object.mem "full_name" Jsont.string ~enc:full_name 32 + |> Jsont.Object.opt_mem "user_id" Jsont.int ~enc:user_id 33 + |> Jsont.Object.opt_mem "delivery_email" Jsont.string ~enc:delivery_email 34 34 |> Jsont.Object.mem "is_active" Jsont.bool ~enc:is_active 35 35 |> Jsont.Object.mem "is_admin" Jsont.bool ~enc:is_admin 36 36 |> Jsont.Object.mem "is_bot" Jsont.bool ~enc:is_bot 37 37 |> Jsont.Object.finish 38 + 38 39 (* Decode and encode functions using Encode module *) 39 40 let of_json json = 40 41 match Encode.from_json jsont json with 41 42 | Ok v -> Ok v 42 43 | Error msg -> Error (Zulip_types.create_error ~code:(Other "json_parse_error") ~msg ()) 44 + 45 + let pp fmt t = 46 + let delivery = match t.delivery_email with 47 + | Some email -> Printf.sprintf ", delivery_email=%s" email 48 + | None -> "" 49 + in 50 + let uid = match t.user_id with 51 + | Some id -> Printf.sprintf ", user_id=%d" id 52 + | None -> "" 53 + in 54 + Format.fprintf fmt "User{email=%s, full_name=%s%s%s}" t.email t.full_name uid delivery 43 55 44 56 let to_json_string t = 45 57 Encode.to_json_string jsont t
+2
stack/zulip/lib/zulip/lib/user.mli
··· 3 3 val create : 4 4 email:string -> 5 5 full_name:string -> 6 + ?user_id:int -> 7 + ?delivery_email:string -> 6 8 ?is_active:bool -> 7 9 ?is_admin:bool -> 8 10 ?is_bot:bool ->
+22
stack/zulip/lib/zulip/lib/users.ml
··· 23 23 | Error err -> Error err) 24 24 | Error err -> Error err 25 25 26 + let get_by_id client ~user_id = 27 + (* Define a codec for the response that wraps the user in a "user" field *) 28 + let user_response_codec = 29 + Jsont.Object.( 30 + map ~kind:"UserResponse" (fun user -> user) 31 + |> mem "user" User.jsont ~enc:(fun x -> x) 32 + |> finish 33 + ) 34 + in 35 + 36 + match Client.request client ~method_:`GET ~path:("/api/v1/users/" ^ string_of_int user_id) () with 37 + | Ok json -> 38 + (* First try parsing as wrapped response *) 39 + (match Encode.from_json user_response_codec json with 40 + | Ok user -> Ok user 41 + | Error _ -> 42 + (* Fallback: try parsing the whole response as a user *) 43 + (match User.of_json json with 44 + | Ok user -> Ok user 45 + | Error err -> Error err)) 46 + | Error err -> Error err 47 + 26 48 (* Request type for create_user *) 27 49 module Create_user_request = struct 28 50 type t = { email : string; full_name : string }
+3
stack/zulip/lib/zulip_bot/lib/bot_storage.ml
··· 207 207 Log.err (fun m -> m "Failed to flush storage: %s" (Zulip.error_message e)); 208 208 Error e 209 209 end 210 + 211 + (* Get the underlying client *) 212 + let client t = t.client