5
0
mirror of https://github.com/cwinfo/matterbridge.git synced 2024-12-27 10:05:39 +00:00
matterbridge/vendor/github.com/slack-go/slack/websocket_managed_conn.go

588 lines
19 KiB
Go
Raw Normal View History

2016-09-05 14:34:37 +00:00
package slack
import (
"encoding/json"
"fmt"
"io"
2018-08-09 22:38:19 +00:00
"net/http"
2018-12-01 18:55:35 +00:00
stdurl "net/url"
2016-09-05 14:34:37 +00:00
"reflect"
"time"
2021-02-01 20:29:04 +00:00
"github.com/slack-go/slack/internal/backoff"
"github.com/slack-go/slack/internal/misc"
2018-08-09 22:38:19 +00:00
"github.com/gorilla/websocket"
"github.com/slack-go/slack/internal/errorsx"
"github.com/slack-go/slack/internal/timex"
2016-09-05 14:34:37 +00:00
)
// ManageConnection can be called on a Slack RTM instance returned by the
// NewRTM method. It will connect to the slack RTM API and handle all incoming
// and outgoing events. If a connection fails then it will attempt to reconnect
// and will notify any listeners through an error event on the IncomingEvents
// channel.
//
// If the connection ends and the disconnect was unintentional then this will
// attempt to reconnect.
//
// This should only be called once per slack API! Otherwise expect undefined
// behavior.
//
// The defined error events are located in websocket_internals.go.
func (rtm *RTM) ManageConnection() {
2018-08-09 22:38:19 +00:00
var (
err error
info *Info
conn *websocket.Conn
)
for connectionCount := 0; ; connectionCount++ {
2016-09-05 14:34:37 +00:00
// start trying to connect
// the returned err is already passed onto the IncomingEvents channel
2018-08-09 22:38:19 +00:00
if info, conn, err = rtm.connect(connectionCount, rtm.useRTMStart); err != nil {
// when the connection is unsuccessful its fatal, and we need to bail out.
rtm.Debugf("Failed to connect with RTM on try %d: %s", connectionCount, err)
2019-09-07 20:46:58 +00:00
rtm.disconnect()
2016-09-05 14:34:37 +00:00
return
}
2018-08-09 22:38:19 +00:00
// lock to prevent data races with Disconnect particularly around isConnected
// and conn.
rtm.mu.Lock()
rtm.conn = conn
2016-09-05 14:34:37 +00:00
rtm.info = info
2018-08-09 22:38:19 +00:00
rtm.mu.Unlock()
2016-09-05 14:34:37 +00:00
rtm.IncomingEvents <- RTMEvent{"connected", &ConnectedEvent{
ConnectionCount: connectionCount,
Info: info,
}}
2018-08-09 22:38:19 +00:00
rtm.Debugf("RTM connection succeeded on try %d", connectionCount)
2016-09-05 14:34:37 +00:00
2019-12-07 21:54:36 +00:00
rawEvents := make(chan json.RawMessage)
2019-09-07 20:46:58 +00:00
// we're now connected so we can set up listeners
2019-12-07 21:54:36 +00:00
go rtm.handleIncomingEvents(rawEvents)
2016-09-05 14:34:37 +00:00
// this should be a blocking call until the connection has ended
2019-12-07 21:54:36 +00:00
rtm.handleEvents(rawEvents)
2016-09-05 14:34:37 +00:00
2019-09-07 20:46:58 +00:00
select {
case <-rtm.disconnected:
// after handle events returns we need to check if we're disconnected
2019-12-07 21:54:36 +00:00
// when this happens we need to cleanup the newly created connection.
if err = conn.Close(); err != nil {
rtm.Debugln("failed to close conn on disconnected RTM", err)
}
2016-09-05 14:34:37 +00:00
return
2019-09-07 20:46:58 +00:00
default:
// otherwise continue and run the loop again to reconnect
2016-09-05 14:34:37 +00:00
}
}
}
// connect attempts to connect to the slack websocket API. It handles any
// errors that occur while connecting and will return once a connection
// has been successfully opened.
2017-07-16 12:29:46 +00:00
// If useRTMStart is false then it uses rtm.connect to create the connection,
// otherwise it uses rtm.start.
func (rtm *RTM) connect(connectionCount int, useRTMStart bool) (*Info, *websocket.Conn, error) {
2018-08-09 22:38:19 +00:00
const (
errInvalidAuth = "invalid_auth"
errInactiveAccount = "account_inactive"
errMissingAuthToken = "not_authed"
2021-03-20 21:40:23 +00:00
errTokenRevoked = "token_revoked"
2018-08-09 22:38:19 +00:00
)
2016-09-05 14:34:37 +00:00
// used to provide exponential backoff wait time with jitter before trying
// to connect to slack again
2021-02-01 20:29:04 +00:00
boff := &backoff.Backoff{
2019-09-07 20:46:58 +00:00
Max: 5 * time.Minute,
2016-09-05 14:34:37 +00:00
}
for {
2019-09-07 20:46:58 +00:00
var (
backoff time.Duration
)
2016-09-05 14:34:37 +00:00
// send connecting event
rtm.IncomingEvents <- RTMEvent{"connecting", &ConnectingEvent{
2021-02-01 20:29:04 +00:00
Attempt: boff.Attempts() + 1,
2016-09-05 14:34:37 +00:00
ConnectionCount: connectionCount,
}}
2019-09-07 20:46:58 +00:00
2016-09-05 14:34:37 +00:00
// attempt to start the connection
2017-07-16 12:29:46 +00:00
info, conn, err := rtm.startRTMAndDial(useRTMStart)
2016-09-05 14:34:37 +00:00
if err == nil {
return info, conn, nil
}
2018-08-09 22:38:19 +00:00
// check for fatal errors
switch err.Error() {
2021-03-20 21:40:23 +00:00
case errInvalidAuth, errInactiveAccount, errMissingAuthToken, errTokenRevoked:
2019-09-07 20:46:58 +00:00
rtm.Debugf("invalid auth when connecting with RTM: %s", err)
2016-09-05 14:34:37 +00:00
rtm.IncomingEvents <- RTMEvent{"invalid_auth", &InvalidAuthEvent{}}
2018-08-09 22:38:19 +00:00
return nil, nil, err
default:
2016-09-05 14:34:37 +00:00
}
2016-11-05 23:07:24 +00:00
2019-09-07 20:46:58 +00:00
switch actual := err.(type) {
2021-02-01 20:29:04 +00:00
case misc.StatusCodeError:
2019-09-07 20:46:58 +00:00
if actual.Code == http.StatusNotFound {
rtm.Debugf("invalid auth when connecting with RTM: %s", err)
rtm.IncomingEvents <- RTMEvent{"invalid_auth", &InvalidAuthEvent{}}
return nil, nil, err
}
case *RateLimitedError:
backoff = actual.RetryAfter
default:
}
backoff = timex.Max(backoff, boff.Duration())
2016-09-05 14:34:37 +00:00
// any other errors are treated as recoverable and we try again after
// sending the event along the IncomingEvents channel
rtm.IncomingEvents <- RTMEvent{"connection_error", &ConnectionErrorEvent{
2021-02-01 20:29:04 +00:00
Attempt: boff.Attempts(),
2019-09-07 20:46:58 +00:00
Backoff: backoff,
2016-09-05 14:34:37 +00:00
ErrorObj: err,
}}
2018-01-08 21:41:38 +00:00
2019-09-07 20:46:58 +00:00
// get time we should wait before attempting to connect again
2021-02-01 20:29:04 +00:00
rtm.Debugf("reconnection %d failed: %s reconnecting in %v\n", boff.Attempts(), err, backoff)
2019-09-07 20:46:58 +00:00
// wait for one of the following to occur,
// backoff duration has elapsed, killChannel is signalled, or
// the rtm finishes disconnecting.
2018-01-08 21:41:38 +00:00
select {
2019-09-07 20:46:58 +00:00
case <-time.After(backoff): // retry after the backoff.
case intentional := <-rtm.killChannel:
if intentional {
rtm.killConnection(intentional, ErrRTMDisconnected)
return nil, nil, ErrRTMDisconnected
}
2018-08-09 22:38:19 +00:00
case <-rtm.disconnected:
2019-09-07 20:46:58 +00:00
return nil, nil, ErrRTMDisconnected
2018-01-08 21:41:38 +00:00
}
2016-09-05 14:34:37 +00:00
}
}
2017-07-16 12:29:46 +00:00
// startRTMAndDial attempts to connect to the slack websocket. If useRTMStart is true,
// then it returns the full information returned by the "rtm.start" method on the
// slack API. Else it uses the "rtm.connect" method to connect
2018-08-09 22:38:19 +00:00
func (rtm *RTM) startRTMAndDial(useRTMStart bool) (info *Info, _ *websocket.Conn, err error) {
var (
url string
)
2017-07-16 12:29:46 +00:00
if useRTMStart {
2018-08-09 22:38:19 +00:00
rtm.Debugf("Starting RTM")
2017-07-16 12:29:46 +00:00
info, url, err = rtm.StartRTM()
} else {
2018-08-09 22:38:19 +00:00
rtm.Debugf("Connecting to RTM")
2017-07-16 12:29:46 +00:00
info, url, err = rtm.ConnectRTM()
}
2016-09-05 14:34:37 +00:00
if err != nil {
2018-08-09 22:38:19 +00:00
rtm.Debugf("Failed to start or connect to RTM: %s", err)
2016-09-05 14:34:37 +00:00
return nil, nil, err
}
2018-12-01 18:55:35 +00:00
// install connection parameters
u, err := stdurl.Parse(url)
if err != nil {
return nil, nil, err
}
u.RawQuery = rtm.connParams.Encode()
url = u.String()
2018-08-09 22:38:19 +00:00
rtm.Debugf("Dialing to websocket on url %s", url)
2018-01-08 21:41:38 +00:00
// Only use HTTPS for connections to prevent MITM attacks on the connection.
2018-08-09 22:38:19 +00:00
upgradeHeader := http.Header{}
upgradeHeader.Add("Origin", "https://api.slack.com")
dialer := websocket.DefaultDialer
if rtm.dialer != nil {
dialer = rtm.dialer
}
conn, _, err := dialer.Dial(url, upgradeHeader)
2016-09-05 14:34:37 +00:00
if err != nil {
2018-08-09 22:38:19 +00:00
rtm.Debugf("Failed to dial to the websocket: %s", err)
2016-09-05 14:34:37 +00:00
return nil, nil, err
}
return info, conn, err
}
// killConnection stops the websocket connection and signals to all goroutines
// that they should cease listening to the connection for events.
//
// This should not be called directly! Instead a boolean value (true for
// intentional, false otherwise) should be sent to the killChannel on the RTM.
2019-09-07 20:46:58 +00:00
func (rtm *RTM) killConnection(intentional bool, cause error) (err error) {
2019-12-07 21:54:36 +00:00
rtm.Debugln("killing connection", cause)
2019-09-07 20:46:58 +00:00
if rtm.conn != nil {
err = rtm.conn.Close()
}
rtm.IncomingEvents <- RTMEvent{"disconnected", &DisconnectedEvent{Intentional: intentional, Cause: cause}}
if intentional {
rtm.disconnect()
2016-09-05 14:34:37 +00:00
}
2019-09-07 20:46:58 +00:00
2016-09-05 14:34:37 +00:00
return err
}
// handleEvents is a blocking function that handles all events. This sends
// pings when asked to (on rtm.forcePing) and upon every given elapsed
// interval. This also sends outgoing messages that are received from the RTM's
// outgoingMessages channel. This also handles incoming raw events from the RTM
// rawEvents channel.
2019-12-07 21:54:36 +00:00
func (rtm *RTM) handleEvents(events chan json.RawMessage) {
2018-08-09 22:38:19 +00:00
ticker := time.NewTicker(rtm.pingInterval)
2016-09-05 14:34:37 +00:00
defer ticker.Stop()
for {
select {
// catch "stop" signal on channel close
case intentional := <-rtm.killChannel:
2019-09-07 20:46:58 +00:00
_ = rtm.killConnection(intentional, errorsx.String("signaled"))
2016-09-05 14:34:37 +00:00
return
2018-08-09 22:38:19 +00:00
// detect when the connection is dead.
case <-rtm.pingDeadman.C:
2019-12-07 21:54:36 +00:00
_ = rtm.killConnection(false, ErrRTMDeadman)
2019-09-07 20:46:58 +00:00
return
2018-08-09 22:38:19 +00:00
// send pings on ticker interval
2016-09-05 14:34:37 +00:00
case <-ticker.C:
2019-09-07 20:46:58 +00:00
if err := rtm.ping(); err != nil {
_ = rtm.killConnection(false, err)
2016-09-05 14:34:37 +00:00
return
}
case <-rtm.forcePing:
2019-09-07 20:46:58 +00:00
if err := rtm.ping(); err != nil {
_ = rtm.killConnection(false, err)
2016-09-05 14:34:37 +00:00
return
}
// listen for messages that need to be sent
case msg := <-rtm.outgoingMessages:
rtm.sendOutgoingMessage(msg)
2019-12-07 21:54:36 +00:00
// listen for incoming messages that need to be parsed
case rawEvent := <-events:
2018-08-09 22:38:19 +00:00
switch rtm.handleRawEvent(rawEvent) {
case rtmEventTypeGoodbye:
2019-12-07 21:54:36 +00:00
// kill the connection, but DO NOT RETURN, a follow up kill signal will
// be sent that still needs to be processed. this duplication is because
// the event reader restarts once it emits the goodbye event.
// unlike the other cases in this function a final read will be triggered
// against the connection which will emit a kill signal. if we return early
// this kill signal will be processed by the next connection.
_ = rtm.killConnection(false, ErrRTMGoodbye)
2018-08-09 22:38:19 +00:00
default:
}
2016-09-05 14:34:37 +00:00
}
}
}
// handleIncomingEvents monitors the RTM's opened websocket for any incoming
2019-12-07 21:54:36 +00:00
// events. It pushes the raw events into the channel.
2016-09-05 14:34:37 +00:00
//
2019-12-07 21:54:36 +00:00
// This will stop executing once the RTM's when a fatal error is detected, or
// a disconnect occurs.
func (rtm *RTM) handleIncomingEvents(events chan json.RawMessage) {
2016-09-05 14:34:37 +00:00
for {
2019-12-07 21:54:36 +00:00
if err := rtm.receiveIncomingEvent(events); err != nil {
select {
case rtm.killChannel <- false:
case <-rtm.disconnected:
}
2016-09-05 14:34:37 +00:00
return
}
}
}
2016-11-05 23:07:24 +00:00
func (rtm *RTM) sendWithDeadline(msg interface{}) error {
// set a write deadline on the connection
if err := rtm.conn.SetWriteDeadline(time.Now().Add(10 * time.Second)); err != nil {
return err
}
2018-08-09 22:38:19 +00:00
if err := rtm.conn.WriteJSON(msg); err != nil {
2016-11-05 23:07:24 +00:00
return err
}
// remove write deadline
return rtm.conn.SetWriteDeadline(time.Time{})
}
2016-09-05 14:34:37 +00:00
// sendOutgoingMessage sends the given OutgoingMessage to the slack websocket.
//
// It does not currently detect if a outgoing message fails due to a disconnect
// and instead lets a future failed 'PING' detect the failed connection.
func (rtm *RTM) sendOutgoingMessage(msg OutgoingMessage) {
rtm.Debugln("Sending message:", msg)
2018-12-01 18:55:35 +00:00
if len([]rune(msg.Text)) > MaxMessageTextLength {
2016-09-05 14:34:37 +00:00
rtm.IncomingEvents <- RTMEvent{"outgoing_error", &MessageTooLongEvent{
Message: msg,
MaxLength: MaxMessageTextLength,
}}
return
}
2016-11-05 23:07:24 +00:00
if err := rtm.sendWithDeadline(msg); err != nil {
2016-09-05 14:34:37 +00:00
rtm.IncomingEvents <- RTMEvent{"outgoing_error", &OutgoingErrorEvent{
Message: msg,
ErrorObj: err,
}}
}
}
// ping sends a 'PING' message to the RTM's websocket. If the 'PING' message
// fails to send then this returns an error signifying that the connection
// should be considered disconnected.
//
// This does not handle incoming 'PONG' responses but does store the time of
// each successful 'PING' send so latency can be detected upon a 'PONG'
// response.
func (rtm *RTM) ping() error {
id := rtm.idGen.Next()
rtm.Debugln("Sending PING ", id)
2018-08-09 22:38:19 +00:00
msg := &Ping{ID: id, Type: "ping", Timestamp: time.Now().Unix()}
2016-11-05 23:07:24 +00:00
if err := rtm.sendWithDeadline(msg); err != nil {
2016-09-05 14:34:37 +00:00
rtm.Debugf("RTM Error sending 'PING %d': %s", id, err.Error())
return err
}
return nil
}
// receiveIncomingEvent attempts to receive an event from the RTM's websocket.
// This will block until a frame is available from the websocket.
2018-08-09 22:38:19 +00:00
// If the read from the websocket results in a fatal error, this function will return non-nil.
2019-12-07 21:54:36 +00:00
func (rtm *RTM) receiveIncomingEvent(events chan json.RawMessage) error {
2016-09-05 14:34:37 +00:00
event := json.RawMessage{}
2018-08-09 22:38:19 +00:00
err := rtm.conn.ReadJSON(&event)
2019-12-07 21:54:36 +00:00
// check if the connection was closed.
if websocket.IsUnexpectedCloseError(err) {
return err
}
2018-08-09 22:38:19 +00:00
switch {
case err == io.ErrUnexpectedEOF:
2016-09-05 14:34:37 +00:00
// EOF's don't seem to signify a failed connection so instead we ignore
// them here and detect a failed connection upon attempting to send a
// 'PING' message
2018-08-09 22:38:19 +00:00
// trigger a 'PING' to detect potential websocket disconnect
2019-09-07 20:46:58 +00:00
select {
case rtm.forcePing <- true:
case <-rtm.disconnected:
}
2018-08-09 22:38:19 +00:00
case err != nil:
// All other errors from ReadJSON come from NextReader, and should
// kill the read loop and force a reconnect.
2016-09-05 14:34:37 +00:00
rtm.IncomingEvents <- RTMEvent{"incoming_error", &IncomingEventError{
ErrorObj: err,
}}
2019-09-07 20:46:58 +00:00
2018-08-09 22:38:19 +00:00
return err
case len(event) == 0:
2016-09-05 14:34:37 +00:00
rtm.Debugln("Received empty event")
2018-08-09 22:38:19 +00:00
default:
2019-09-07 20:46:58 +00:00
rtm.Debugln("Incoming Event:", string(event))
select {
2019-12-07 21:54:36 +00:00
case events <- event:
2019-09-07 20:46:58 +00:00
case <-rtm.disconnected:
rtm.Debugln("disonnected while attempting to send raw event")
}
2016-09-05 14:34:37 +00:00
}
2019-12-07 21:54:36 +00:00
2018-08-09 22:38:19 +00:00
return nil
2016-09-05 14:34:37 +00:00
}
// handleRawEvent takes a raw JSON message received from the slack websocket
// and handles the encoded event.
2018-08-09 22:38:19 +00:00
// returns the event type of the message.
func (rtm *RTM) handleRawEvent(rawEvent json.RawMessage) string {
2016-09-05 14:34:37 +00:00
event := &Event{}
err := json.Unmarshal(rawEvent, event)
if err != nil {
rtm.IncomingEvents <- RTMEvent{"unmarshalling_error", &UnmarshallingErrorEvent{err}}
2018-08-09 22:38:19 +00:00
return ""
2016-09-05 14:34:37 +00:00
}
2018-08-09 22:38:19 +00:00
2016-09-05 14:34:37 +00:00
switch event.Type {
2018-08-09 22:38:19 +00:00
case rtmEventTypeAck:
2016-09-05 14:34:37 +00:00
rtm.handleAck(rawEvent)
2018-08-09 22:38:19 +00:00
case rtmEventTypeHello:
2016-09-05 14:34:37 +00:00
rtm.IncomingEvents <- RTMEvent{"hello", &HelloEvent{}}
2018-08-09 22:38:19 +00:00
case rtmEventTypePong:
2016-09-05 14:34:37 +00:00
rtm.handlePong(rawEvent)
2018-08-09 22:38:19 +00:00
case rtmEventTypeGoodbye:
// just return the event type up for goodbye, will be handled by caller.
2016-09-05 14:34:37 +00:00
default:
rtm.handleEvent(event.Type, rawEvent)
}
2018-08-09 22:38:19 +00:00
return event.Type
2016-09-05 14:34:37 +00:00
}
// handleAck handles an incoming 'ACK' message.
func (rtm *RTM) handleAck(event json.RawMessage) {
ack := &AckMessage{}
if err := json.Unmarshal(event, ack); err != nil {
rtm.Debugln("RTM Error unmarshalling 'ack' event:", err)
rtm.Debugln(" -> Erroneous 'ack' event:", string(event))
return
}
2018-01-08 21:41:38 +00:00
2016-09-05 14:34:37 +00:00
if ack.Ok {
rtm.IncomingEvents <- RTMEvent{"ack", ack}
2018-01-08 21:41:38 +00:00
} else if ack.RTMResponse.Error != nil {
2018-08-09 22:38:19 +00:00
// As there is no documentation for RTM error-codes, this
// identification of a rate-limit warning is very brittle.
if ack.RTMResponse.Error.Code == -1 && ack.RTMResponse.Error.Msg == "slow down, too many messages..." {
rtm.IncomingEvents <- RTMEvent{"ack_error", &RateLimitEvent{}}
} else {
2021-03-20 21:40:23 +00:00
rtm.IncomingEvents <- RTMEvent{"ack_error", &AckErrorEvent{ack.Error, ack.ReplyTo}}
2018-08-09 22:38:19 +00:00
}
2018-01-08 21:41:38 +00:00
} else {
2021-03-20 21:40:23 +00:00
rtm.IncomingEvents <- RTMEvent{"ack_error", &AckErrorEvent{ErrorObj: fmt.Errorf("ack decode failure")}}
2016-09-05 14:34:37 +00:00
}
}
// handlePong handles an incoming 'PONG' message which should be in response to
// a previously sent 'PING' message. This is then used to compute the
// connection's latency.
func (rtm *RTM) handlePong(event json.RawMessage) {
2018-08-09 22:38:19 +00:00
var (
p Pong
)
rtm.resetDeadman()
if err := json.Unmarshal(event, &p); err != nil {
2018-12-01 18:55:35 +00:00
rtm.Client.log.Println("RTM Error unmarshalling 'pong' event:", err)
2016-09-05 14:34:37 +00:00
return
}
2018-08-09 22:38:19 +00:00
latency := time.Since(time.Unix(p.Timestamp, 0))
rtm.IncomingEvents <- RTMEvent{"latency_report", &LatencyReport{Value: latency}}
2016-09-05 14:34:37 +00:00
}
// handleEvent is the "default" response to an event that does not have a
// special case. It matches the command's name to a mapping of defined events
// and then sends the corresponding event struct to the IncomingEvents channel.
// If the event type is not found or the event cannot be unmarshalled into the
// correct struct then this sends an UnmarshallingErrorEvent to the
// IncomingEvents channel.
func (rtm *RTM) handleEvent(typeStr string, event json.RawMessage) {
2018-08-09 22:38:19 +00:00
v, exists := EventMapping[typeStr]
2016-09-05 14:34:37 +00:00
if !exists {
2018-12-01 18:55:35 +00:00
rtm.Debugf("RTM Error - received unmapped event %q: %s\n", typeStr, string(event))
err := fmt.Errorf("RTM Error: Received unmapped event %q: %s", typeStr, string(event))
2016-09-05 14:34:37 +00:00
rtm.IncomingEvents <- RTMEvent{"unmarshalling_error", &UnmarshallingErrorEvent{err}}
return
}
t := reflect.TypeOf(v)
recvEvent := reflect.New(t).Interface()
err := json.Unmarshal(event, recvEvent)
if err != nil {
rtm.Debugf("RTM Error, could not unmarshall event %q: %s\n", typeStr, string(event))
2018-12-01 18:55:35 +00:00
err := fmt.Errorf("RTM Error: Could not unmarshall event %q: %s", typeStr, string(event))
2016-09-05 14:34:37 +00:00
rtm.IncomingEvents <- RTMEvent{"unmarshalling_error", &UnmarshallingErrorEvent{err}}
return
}
rtm.IncomingEvents <- RTMEvent{typeStr, recvEvent}
}
2018-08-09 22:38:19 +00:00
// EventMapping holds a mapping of event names to their corresponding struct
2016-09-05 14:34:37 +00:00
// implementations. The structs should be instances of the unmarshalling
// target for the matching event type.
2018-08-09 22:38:19 +00:00
var EventMapping = map[string]interface{}{
2016-09-05 14:34:37 +00:00
"message": MessageEvent{},
"presence_change": PresenceChangeEvent{},
"user_typing": UserTypingEvent{},
"channel_marked": ChannelMarkedEvent{},
"channel_created": ChannelCreatedEvent{},
"channel_joined": ChannelJoinedEvent{},
"channel_left": ChannelLeftEvent{},
"channel_deleted": ChannelDeletedEvent{},
"channel_rename": ChannelRenameEvent{},
"channel_archive": ChannelArchiveEvent{},
"channel_unarchive": ChannelUnarchiveEvent{},
"channel_history_changed": ChannelHistoryChangedEvent{},
"dnd_updated": DNDUpdatedEvent{},
"dnd_updated_user": DNDUpdatedEvent{},
"im_created": IMCreatedEvent{},
"im_open": IMOpenEvent{},
"im_close": IMCloseEvent{},
"im_marked": IMMarkedEvent{},
"im_history_changed": IMHistoryChangedEvent{},
"group_marked": GroupMarkedEvent{},
"group_open": GroupOpenEvent{},
"group_joined": GroupJoinedEvent{},
"group_left": GroupLeftEvent{},
"group_close": GroupCloseEvent{},
"group_rename": GroupRenameEvent{},
"group_archive": GroupArchiveEvent{},
"group_unarchive": GroupUnarchiveEvent{},
"group_history_changed": GroupHistoryChangedEvent{},
"file_created": FileCreatedEvent{},
"file_shared": FileSharedEvent{},
"file_unshared": FileUnsharedEvent{},
"file_public": FilePublicEvent{},
"file_private": FilePrivateEvent{},
"file_change": FileChangeEvent{},
"file_deleted": FileDeletedEvent{},
"file_comment_added": FileCommentAddedEvent{},
"file_comment_edited": FileCommentEditedEvent{},
"file_comment_deleted": FileCommentDeletedEvent{},
"pin_added": PinAddedEvent{},
"pin_removed": PinRemovedEvent{},
"star_added": StarAddedEvent{},
"star_removed": StarRemovedEvent{},
"reaction_added": ReactionAddedEvent{},
"reaction_removed": ReactionRemovedEvent{},
"pref_change": PrefChangeEvent{},
"team_join": TeamJoinEvent{},
"team_rename": TeamRenameEvent{},
"team_pref_change": TeamPrefChangeEvent{},
"team_domain_change": TeamDomainChangeEvent{},
"team_migration_started": TeamMigrationStartedEvent{},
"manual_presence_change": ManualPresenceChangeEvent{},
"user_change": UserChangeEvent{},
"emoji_changed": EmojiChangedEvent{},
"commands_changed": CommandsChangedEvent{},
"email_domain_changed": EmailDomainChangedEvent{},
"bot_added": BotAddedEvent{},
"bot_changed": BotChangedEvent{},
"accounts_changed": AccountsChangedEvent{},
"reconnect_url": ReconnectUrlEvent{},
2018-08-09 22:38:19 +00:00
"member_joined_channel": MemberJoinedChannelEvent{},
"member_left_channel": MemberLeftChannelEvent{},
2020-05-23 22:06:21 +00:00
"subteam_created": SubteamCreatedEvent{},
"subteam_members_changed": SubteamMembersChangedEvent{},
"subteam_self_added": SubteamSelfAddedEvent{},
"subteam_self_removed": SubteamSelfRemovedEvent{},
"subteam_updated": SubteamUpdatedEvent{},
2019-12-07 21:54:36 +00:00
2020-03-28 22:50:47 +00:00
"desktop_notification": DesktopNotificationEvent{},
"mobile_in_app_notification": MobileInAppNotificationEvent{},
2016-09-05 14:34:37 +00:00
}