Skip to content

Commit bf396e7

Browse files
author
Martin Jambon
committed
Create proper return value for Slack account_inactive response and
clear user credentials when it happens.
1 parent 158544f commit bf396e7

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

slack_ws_conn.ml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
Maintain websocket connections to Slack.
33
*)
44

5+
open Printf
56
open Lwt
67
open Log
78

@@ -232,6 +233,12 @@ type connection_result =
232233
| Giveup
233234
| Connected of connection
234235

236+
let string_of_connection_result = function
237+
| Retry -> "Retry"
238+
| Giveup -> "Giveup"
239+
| Connected x ->
240+
sprintf "Connected %s" (Slack_api_teamid.to_string x.conn_id)
241+
235242
let create_connection uid slack_teamid input_handler handle_permanent_failure =
236243
logf `Debug "Create websocket connection for Slack team %s"
237244
(Slack_api_teamid.to_string slack_teamid);
@@ -243,9 +250,10 @@ let create_connection uid slack_teamid input_handler handle_permanent_failure =
243250
| Some access_token ->
244251
Slack_api.rtm_start access_token >>= fun resp ->
245252
match Slack_util.extract_result resp with
246-
| None ->
247-
return Retry
248-
| Some x ->
253+
| `Account_inactive ->
254+
Slack_user.clear_posting_param uid >>= fun () ->
255+
return Giveup
256+
| `OK x ->
249257
let ws_url = x.Slack_api_t.url in
250258
let waiting_for_pong = ref None in
251259
create_websocket_connection ws_url

0 commit comments

Comments
 (0)