diff --git a/slackevents/parsers.go b/slackevents/parsers.go index 4daac8b16..9e8c22b7f 100644 --- a/slackevents/parsers.go +++ b/slackevents/parsers.go @@ -212,6 +212,32 @@ func ParseEvent(rawEvent json.RawMessage, opts ...Option) (EventsAPIEvent, error } return innerEvent, nil } + + if e.Type == AppRateLimited { + appRateLimitedEvent := &EventsAPIAppRateLimited{} + err = json.Unmarshal(rawEvent, appRateLimitedEvent) + if err != nil { + return EventsAPIEvent{ + "", + "", + "unmarshalling_error", + "", + "", + &slack.UnmarshallingErrorEvent{ErrorObj: err}, + EventsAPIInnerEvent{}, + }, err + } + return EventsAPIEvent{ + e.Token, + e.TeamID, + e.Type, + e.APIAppID, + e.EnterpriseID, + appRateLimitedEvent, + EventsAPIInnerEvent{}, + }, nil + } + urlVerificationEvent := &EventsAPIURLVerificationEvent{} err = json.Unmarshal(rawEvent, urlVerificationEvent) if err != nil { diff --git a/slackevents/parsers_test.go b/slackevents/parsers_test.go index 821d50f70..2e2b63401 100644 --- a/slackevents/parsers_test.go +++ b/slackevents/parsers_test.go @@ -73,6 +73,33 @@ func TestParseURLVerificationEvent(t *testing.T) { } } +func TestParseAppRateLimitedEvent(t *testing.T) { + event := ` + { + "token": "fake-token", + "team_id": "T123ABC456", + "minute_rate_limited": 1518467820, + "api_app_id": "A123ABC456", + "type": "app_rate_limited" + } + ` + msg, e := ParseEvent(json.RawMessage(event), OptionVerifyToken(&TokenComparator{"fake-token"})) + if e != nil { + fmt.Println(e) + t.Fail() + } + switch ev := msg.Data.(type) { + case *EventsAPIAppRateLimited: + { + } + default: + { + fmt.Println(ev) + t.Fail() + } + } +} + func TestThatOuterCallbackEventHasInnerEvent(t *testing.T) { eventsAPIRawCallbackEvent := ` {