diff --git a/src/lib/slacko.ml b/src/lib/slacko.ml index 6261b26..9d39dce 100644 --- a/src/lib/slacko.ml +++ b/src/lib/slacko.ml @@ -248,8 +248,8 @@ type channel_obj = { creator: user; is_archived: bool; is_general: bool; + name_normalized: string; is_member: bool; - members: user list; topic: topic_obj; purpose: topic_obj; last_read: Timestamp.t option [@default None]; @@ -721,7 +721,7 @@ let maybe fn = function (* nonpublic types for conversion in list types *) type channels_list_obj = { channels: channel_obj list -} [@@deriving of_yojson] +} [@@deriving of_yojson { strict = false }] type users_list_obj = { members: user_obj list @@ -736,7 +736,7 @@ type im_list_obj = { } [@@deriving of_yojson] let channels_list ?exclude_archived session = - api_request "channels.list" + api_request "conversations.list" |> optionally_add "exclude_archived" @@ maybe string_of_bool @@ exclude_archived |> query session >|= function @@ -782,8 +782,7 @@ let lookupk session (listfn : 'a listfn) filterfn k = let id_of_channel session = function | ChannelId id -> Lwt.return @@ `Found id | ChannelName name -> - let base = String.sub name 1 @@ String.length name - 1 in - lookupk session channels_list (fun (x:channel_obj) -> x.name = base) @@ function + lookupk session channels_list (fun (x:channel_obj) -> x.name = name || x.name_normalized = name) @@ function | [] -> `Channel_not_found | [{id = ChannelId s; _}] -> `Found s | [_] -> failwith "Bad result from channel id lookup." diff --git a/src/lib/slacko.mli b/src/lib/slacko.mli index 901b321..e2a2641 100644 --- a/src/lib/slacko.mli +++ b/src/lib/slacko.mli @@ -357,8 +357,8 @@ type channel_obj = { creator: user; is_archived: bool; is_general: bool; + name_normalized: string; is_member: bool; - members: user list; topic: topic_obj; purpose: topic_obj; last_read: timestamp option;