Skip to content

Commit

Permalink
Merge pull request #3 from range-labs/stephyeung/channel-id-changed
Browse files Browse the repository at this point in the history
Support channel_id_changed events
  • Loading branch information
stephyeung committed Mar 19, 2021
2 parents 0b8d7ec + f07da23 commit d078cbb
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
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
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 d078cbb

Please sign in to comment.