Skip to content

Commit

Permalink
fix: slack-notify cli
Browse files Browse the repository at this point in the history
- This partially addresses #43
- `channels.list` seems to become `conversations.list` now.
- Responses of `conversations.list` are limited conversation objects
  that do not have `members` attribute.
- No need to trime channel names anymore?
  • Loading branch information
pm5 committed Jun 6, 2023
1 parent 1dbc151 commit f4b80c4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
9 changes: 4 additions & 5 deletions src/lib/slacko.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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."
Expand Down
2 changes: 1 addition & 1 deletion src/lib/slacko.mli
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit f4b80c4

Please sign in to comment.