Skip to content

Commit 6ea0678

Browse files
committed
feat(websocket): support user_*_changed events
Closes #1541.
1 parent 8497ee8 commit 6ea0678

File tree

4 files changed

+40
-4
lines changed

4 files changed

+40
-4
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99

1010
### Added
1111

12+
- **RTM support for `user_status_changed`, `user_huddle_changed`, `user_profile_changed`
13+
events** — these events are now mapped in `EventMapping` with dedicated structs
14+
(`UserStatusChangedEvent`, `UserHuddleChangedEvent`, `UserProfileChangedEvent`).
15+
Previously they triggered `UnmarshallingErrorEvent`. ([#1541])
16+
- **`CacheTS` and `EventTS` fields on `UserChangeEvent`** — these fields were sent by Slack
17+
but silently dropped during unmarshalling.
1218
- **`workflows.featured` API support** — add, list, remove, and set featured workflows on
1319
channels via `WorkflowsFeaturedAdd`, `WorkflowsFeaturedList`, `WorkflowsFeaturedRemove`,
1420
and `WorkflowsFeaturedSet`
@@ -326,6 +332,7 @@ for details.
326332
[#1533]: https://github.com/slack-go/slack/pull/1533
327333
[#1534]: https://github.com/slack-go/slack/pull/1534
328334
[#1536]: https://github.com/slack-go/slack/pull/1536
335+
[#1541]: https://github.com/slack-go/slack/issues/1541
329336
330337
[Unreleased]: https://github.com/slack-go/slack/compare/v0.20.0...HEAD
331338
[0.20.0]: https://github.com/slack-go/slack/compare/v0.19.0...v0.20.0

websocket_managed_conn.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -582,7 +582,10 @@ var EventMapping = map[string]interface{}{
582582

583583
"manual_presence_change": ManualPresenceChangeEvent{},
584584

585-
"user_change": UserChangeEvent{},
585+
"user_change": UserChangeEvent{},
586+
"user_status_changed": UserStatusChangedEvent{},
587+
"user_huddle_changed": UserHuddleChangedEvent{},
588+
"user_profile_changed": UserProfileChangedEvent{},
586589

587590
"emoji_changed": EmojiChangedEvent{},
588591

websocket_managed_conn_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ func TestRTMSingleConnect(t *testing.T) {
317317
}
318318

319319
func TestRTMUnmappedError(t *testing.T) {
320-
const unmappedEventName = "user_status_changed"
320+
const unmappedEventName = "some_unknown_event"
321321
// Set up the test server.
322322
testServer := slacktest.NewTestServer()
323323
go testServer.Start()

websocket_misc.go

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,34 @@ type ManualPresenceChangeEvent struct {
7171

7272
// UserChangeEvent represents the user change event
7373
type UserChangeEvent struct {
74-
Type string `json:"type"`
75-
User User `json:"user"`
74+
Type string `json:"type"`
75+
User User `json:"user"`
76+
CacheTS int64 `json:"cache_ts"`
77+
EventTS string `json:"event_ts"`
78+
}
79+
80+
// UserStatusChangedEvent represents the user status changed event
81+
type UserStatusChangedEvent struct {
82+
Type string `json:"type"`
83+
User User `json:"user"`
84+
CacheTS int64 `json:"cache_ts"`
85+
EventTS string `json:"event_ts"`
86+
}
87+
88+
// UserHuddleChangedEvent represents the user huddle changed event
89+
type UserHuddleChangedEvent struct {
90+
Type string `json:"type"`
91+
User User `json:"user"`
92+
CacheTS int64 `json:"cache_ts"`
93+
EventTS string `json:"event_ts"`
94+
}
95+
96+
// UserProfileChangedEvent represents the user profile changed event
97+
type UserProfileChangedEvent struct {
98+
Type string `json:"type"`
99+
User User `json:"user"`
100+
CacheTS int64 `json:"cache_ts"`
101+
EventTS string `json:"event_ts"`
76102
}
77103

78104
// EmojiChangedEvent represents the emoji changed event

0 commit comments

Comments
 (0)