diff --git a/CHANGELOG.md b/CHANGELOG.md index 1f10ae2ed..9d4761bc1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added +- **RTM support for `user_status_changed`, `user_huddle_changed`, `user_profile_changed` + events** — these events are now mapped in `EventMapping` with dedicated structs + (`UserStatusChangedEvent`, `UserHuddleChangedEvent`, `UserProfileChangedEvent`). + Previously they triggered `UnmarshallingErrorEvent`. ([#1541]) +- **`CacheTS` and `EventTS` fields on `UserChangeEvent`** — these fields were sent by Slack + but silently dropped during unmarshalling. - **`workflows.featured` API support** — add, list, remove, and set featured workflows on channels via `WorkflowsFeaturedAdd`, `WorkflowsFeaturedList`, `WorkflowsFeaturedRemove`, and `WorkflowsFeaturedSet` @@ -326,6 +332,7 @@ for details. [#1533]: https://github.com/slack-go/slack/pull/1533 [#1534]: https://github.com/slack-go/slack/pull/1534 [#1536]: https://github.com/slack-go/slack/pull/1536 +[#1541]: https://github.com/slack-go/slack/issues/1541 [Unreleased]: https://github.com/slack-go/slack/compare/v0.20.0...HEAD [0.20.0]: https://github.com/slack-go/slack/compare/v0.19.0...v0.20.0 diff --git a/websocket_managed_conn.go b/websocket_managed_conn.go index f107b2a47..55c35d1a8 100644 --- a/websocket_managed_conn.go +++ b/websocket_managed_conn.go @@ -582,7 +582,10 @@ var EventMapping = map[string]interface{}{ "manual_presence_change": ManualPresenceChangeEvent{}, - "user_change": UserChangeEvent{}, + "user_change": UserChangeEvent{}, + "user_status_changed": UserStatusChangedEvent{}, + "user_huddle_changed": UserHuddleChangedEvent{}, + "user_profile_changed": UserProfileChangedEvent{}, "emoji_changed": EmojiChangedEvent{}, diff --git a/websocket_managed_conn_test.go b/websocket_managed_conn_test.go index c7a8b7034..efbbe97ec 100644 --- a/websocket_managed_conn_test.go +++ b/websocket_managed_conn_test.go @@ -317,7 +317,7 @@ func TestRTMSingleConnect(t *testing.T) { } func TestRTMUnmappedError(t *testing.T) { - const unmappedEventName = "user_status_changed" + const unmappedEventName = "some_unknown_event" // Set up the test server. testServer := slacktest.NewTestServer() go testServer.Start() diff --git a/websocket_misc.go b/websocket_misc.go index 65a8bb65d..69e63ef15 100644 --- a/websocket_misc.go +++ b/websocket_misc.go @@ -71,8 +71,34 @@ type ManualPresenceChangeEvent struct { // UserChangeEvent represents the user change event type UserChangeEvent struct { - Type string `json:"type"` - User User `json:"user"` + Type string `json:"type"` + User User `json:"user"` + CacheTS int64 `json:"cache_ts"` + EventTS string `json:"event_ts"` +} + +// UserStatusChangedEvent represents the user status changed event +type UserStatusChangedEvent struct { + Type string `json:"type"` + User User `json:"user"` + CacheTS int64 `json:"cache_ts"` + EventTS string `json:"event_ts"` +} + +// UserHuddleChangedEvent represents the user huddle changed event +type UserHuddleChangedEvent struct { + Type string `json:"type"` + User User `json:"user"` + CacheTS int64 `json:"cache_ts"` + EventTS string `json:"event_ts"` +} + +// UserProfileChangedEvent represents the user profile changed event +type UserProfileChangedEvent struct { + Type string `json:"type"` + User User `json:"user"` + CacheTS int64 `json:"cache_ts"` + EventTS string `json:"event_ts"` } // EmojiChangedEvent represents the emoji changed event