Skip to content

Commit c711d47

Browse files
committed
feat: add channel_unshared event
1 parent abcbf2b commit c711d47

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

slackevents/inner_events.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,15 @@ type ChannelRenameInfo struct {
147147
Created int `json:"created"`
148148
}
149149

150+
// ChannelUnsharedEvent represents a channel has been unshared with an external workspace event
151+
type ChannelUnsharedEvent struct {
152+
Type string `json:"type"`
153+
PreviouslyConnectedTeamID string `json:"previously_connected_team_id"`
154+
Channel string `json:"channel"`
155+
IsExtShared bool `json:"is_ext_shared"`
156+
EventTimestamp string `json:"event_ts"`
157+
}
158+
150159
// GroupDeletedEvent represents the Group deleted event
151160
type GroupDeletedEvent struct {
152161
Type string `json:"type"`
@@ -1170,6 +1179,8 @@ const (
11701179
ChannelArchive = EventsAPIType("channel_archive")
11711180
// ChannelUnarchive is sent when a channel is unarchived.
11721181
ChannelUnarchive = EventsAPIType("channel_unarchive")
1182+
// ChannelUnshared is sent when a channel is unshared.
1183+
ChannelUnshared = EventsAPIType("channel_unshared")
11731184
// ChannelLeft is sent when a channel is left.
11741185
ChannelLeft = EventsAPIType("channel_left")
11751186
// ChannelRename is sent when a channel is rename.
@@ -1327,6 +1338,7 @@ var EventsAPIInnerEventMapping = map[EventsAPIType]interface{}{
13271338
ChannelDeleted: ChannelDeletedEvent{},
13281339
ChannelArchive: ChannelArchiveEvent{},
13291340
ChannelUnarchive: ChannelUnarchiveEvent{},
1341+
ChannelUnshared: ChannelUnsharedEvent{},
13301342
ChannelLeft: ChannelLeftEvent{},
13311343
ChannelRename: ChannelRenameEvent{},
13321344
ChannelIDChanged: ChannelIDChangedEvent{},

slackevents/inner_events_test.go

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2502,6 +2502,37 @@ func TestChannelSharedEvent(t *testing.T) {
25022502
}
25032503
}
25042504

2505+
func TestChannelUnsharedEvent(t *testing.T) {
2506+
jsonStr := `{
2507+
"type": "channel_unshared",
2508+
"previously_connected_team_id": "E163Q94DX",
2509+
"channel": "C123ABC456",
2510+
"is_ext_shared": false,
2511+
"event_ts": "1561064063.001100"
2512+
}`
2513+
2514+
var event ChannelUnsharedEvent
2515+
if err := json.Unmarshal([]byte(jsonStr), &event); err != nil {
2516+
t.Errorf("Failed to unmarshal ChannelUnsharedEvent: %v", err)
2517+
}
2518+
2519+
if event.Type != "channel_unshared" {
2520+
t.Errorf("Expected type to be 'channel_unshared', got %s", event.Type)
2521+
}
2522+
2523+
if event.PreviouslyConnectedTeamID != "E163Q94DX" {
2524+
t.Errorf("Expected previously_connected_team_id to be 'E163Q94DX', got %s", event.PreviouslyConnectedTeamID)
2525+
}
2526+
2527+
if event.IsExtShared {
2528+
t.Errorf("Expected is_ext_shared to be false, got %t", event.IsExtShared)
2529+
}
2530+
2531+
if event.Channel != "C123ABC456" {
2532+
t.Fail()
2533+
}
2534+
}
2535+
25052536
func TestFileCreatedEvent(t *testing.T) {
25062537
jsonStr := `{
25072538
"type": "file_created",

0 commit comments

Comments
 (0)