Skip to content
This repository was archived by the owner on Dec 20, 2017. It is now read-only.

Commit 0ff5041

Browse files
committed
ensure authenticators call "disconnected()" when bot shuts down
1 parent 69b58b8 commit 0ff5041

File tree

4 files changed

+6
-4
lines changed

4 files changed

+6
-4
lines changed

Sources/Bot/Bot.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ public class SlackBot {
9696
default: return false
9797
}
9898
}
99+
100+
self.authenticator.disconnected()
99101
}
100102
}
101103

Sources/Bot/SlackAuthenticator+OAuth.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ public final class OAuthAuthentication: SlackAuthenticator {
7373

7474
print("Ready to authenticate: Please visit /login")
7575
}
76-
public func disconnected() throws {
77-
try self.clearAuthentication()
76+
public func disconnected() {
77+
try! self.clearAuthentication()
7878
}
7979

8080
//MARK: - State

Sources/Bot/SlackAuthenticator+Token.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,5 @@ public struct TokenAuthentication: SlackAuthenticator {
3131
public func authenticate(success: @escaping (SlackAuthentication) -> Void, failure: @escaping (Error) -> Void) {
3232
success(self.authentication)
3333
}
34-
public func disconnected() throws { }
34+
public func disconnected() { }
3535
}

Sources/Bot/SlackAuthenticator.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,5 @@ public protocol SlackAuthenticator {
1717
/**
1818
The `SlackBot` was disconnected, this allows any cleanup to be performed
1919
*/
20-
func disconnected() throws
20+
func disconnected()
2121
}

0 commit comments

Comments
 (0)