Skip to content

Commit

Permalink
Support channel_id_changed events
Browse files Browse the repository at this point in the history
  • Loading branch information
stephyeung committed Mar 18, 2021
1 parent 0b8d7ec commit f07da23
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
11 changes: 11 additions & 0 deletions slackevents/inner_events.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,14 @@ type AppUninstalledEvent struct {
Type string `json:"type"`
}

// ChannelIDChangedEvent A channel ID has changed after being shared externally.
type ChannelIDChangedEvent struct {
Type string `json:"type"`
OldChannelID string `json:"old_channel_id"`
NewChannelID string `json:"new_channel_id"`
EventTimeStamp json.Number `json:"event_ts"`
}

// GridMigrationFinishedEvent An enterprise grid migration has finished on this workspace.
type GridMigrationFinishedEvent struct {
Type string `json:"type"`
Expand Down Expand Up @@ -310,6 +318,8 @@ const (
AppHomeOpened = "app_home_opened"
// AppUninstalled Your Slack app was uninstalled.
AppUninstalled = "app_uninstalled"
// ChannelIDChangedEvent A channel ID has changed after being shared externally.
ChannelIDChanged = "channel_id_changed"
// GridMigrationFinished An enterprise grid migration has finished on this workspace.
GridMigrationFinished = "grid_migration_finished"
// GridMigrationStarted An enterprise grid migration has started on this workspace.
Expand Down Expand Up @@ -343,6 +353,7 @@ var EventsAPIInnerEventMapping = map[string]interface{}{
AppMention: AppMentionEvent{},
AppHomeOpened: AppHomeOpenedEvent{},
AppUninstalled: AppUninstalledEvent{},
ChannelIDChanged: ChannelIDChangedEvent{},
GridMigrationFinished: GridMigrationFinishedEvent{},
GridMigrationStarted: GridMigrationStartedEvent{},
LinkShared: LinkSharedEvent{},
Expand Down
15 changes: 15 additions & 0 deletions slackevents/inner_events_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,21 @@ func TestAppUninstalled(t *testing.T) {
}
}

func TestChannelIDChanged(t *testing.T) {
rawE := []byte(`
{
"type": "channel_id_changed",
"old_channel_id": "G012Y48650T",
"new_channel_id": "C012Y48650T",
"event_ts": "1612206778.000000"
}
`)
err := json.Unmarshal(rawE, &ChannelIDChangedEvent{})
if err != nil {
t.Error(err)
}
}

func TestGridMigrationFinishedEvent(t *testing.T) {
rawE := []byte(`
{
Expand Down

0 comments on commit f07da23

Please sign in to comment.