@@ -5,7 +5,8 @@ module Filename = Stdlib.Filename
5
5
module Sys = Stdlib. Sys
6
6
7
7
let cwd = Sys. getcwd ()
8
- let cache_dir = Filename. concat cwd " github-api-cache"
8
+ let github_cache_dir = Filename. concat cwd " github-api-cache"
9
+ let slack_cache_dir = Filename. concat cwd " slack-api-cache"
9
10
10
11
(* * return the file with a function f applied unless the file is empty;
11
12
empty file:this is needed to simulate 404 returns from github *)
@@ -29,7 +30,7 @@ and its Github_j.<kind>_of_string function.
29
30
NB: please save the cache file in the same format *)
30
31
let get_repo_member_cache ~(repo : Github_t.repository ) ~kind ~ref_ ~of_string =
31
32
let file = clean_forward_slashes (sprintf " %s_%s_%s" repo.full_name kind ref_) in
32
- let url = Filename. concat cache_dir file in
33
+ let url = Filename. concat github_cache_dir file in
33
34
with_cache_file url of_string
34
35
35
36
module Github : Api .Github = struct
56
57
(* * The base implementation for local check payload debugging and mocking tests *)
57
58
module Slack_base : Api .Slack = struct
58
59
let lookup_user ?cache :_ ~ctx:_ ~cfg:_ ~email:_ () = Lwt. return @@ Error " undefined for local setup"
60
+ let list_users ?cursor :_ ?limit:_ ~ctx:_ () = Lwt. return @@ Error " undefined for local setup"
59
61
let send_notification ~ctx :_ ~msg :_ = Lwt. return @@ Error " undefined for local setup"
60
62
let send_chat_unfurl ~ctx :_ ~channel :_ ~ts :_ ~unfurls :_ () = Lwt. return @@ Error " undefined for local setup"
61
63
let send_auth_test ~ctx :_ () = Lwt. return @@ Error " undefined for local setup"
@@ -72,11 +74,16 @@ module Slack : Api.Slack = struct
72
74
Slack_t. id = sprintf " id[%s]" email;
73
75
name = sprintf " name[%s]" email;
74
76
real_name = sprintf " real_name[%s]" email;
77
+ profile = { email = Some email };
75
78
}
76
79
in
77
80
let mock_response = { Slack_t. user = mock_user } in
78
81
Lwt. return @@ Ok mock_response
79
82
83
+ let list_users ?cursor :_ ?limit:_ ~ctx:_ () =
84
+ let url = Filename. concat slack_cache_dir " users-list" in
85
+ with_cache_file url Slack_j. list_users_res_of_string
86
+
80
87
let send_notification ~ctx :_ ~msg =
81
88
let json = msg |> Slack_j. string_of_post_message_req |> Yojson.Basic. from_string |> Yojson.Basic. pretty_to_string in
82
89
Printf. printf " will notify #%s\n " msg.channel;
0 commit comments