Skip to content

Commit

Permalink
Update version for few handlers to correct values
Browse files Browse the repository at this point in the history
  • Loading branch information
dnsge committed Mar 15, 2024
1 parent a9a83ed commit 7d25238
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 14 deletions.
3 changes: 3 additions & 0 deletions bindings/conditions.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ type ConditionChannelUpdate struct {
type ConditionChannelFollow struct {
// The broadcaster user ID for the channel you want to get follow notifications for.
BroadcasterUserID string `json:"broadcaster_user_id"`
// The ID of the moderator of the channel you want to get follow notifications for. If you have authorization from
// the broadcaster rather than a moderator, specify the broadcaster’s user ID here.
ModeratorUserID string `json:"moderator_user_id"`
}

type ConditionChannelUnban struct {
Expand Down
5 changes: 3 additions & 2 deletions bindings/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,9 @@ type EventChannelUpdate struct {
CategoryID string `json:"category_id"`
// The category name.
CategoryName string `json:"category_name"`
// A boolean identifying whether the channel is flagged as mature. Valid values are true and false.
IsMature bool `json:"is_mature"`
// Array of content classification label IDs currently applied on the Channel. To retrieve a list of all possible
// IDs, use the Get Content Classification Labels API endpoint.
ContentClassificationLabels []string `json:"content_classification_labels"`
}

type EventChannelUnban struct {
Expand Down
8 changes: 4 additions & 4 deletions handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ type SubHandler struct {
// EventSub notification as duplicate.
OnDuplicateNotification func(ctx context.Context, h *bindings.NotificationHeaders)

HandleChannelUpdate EventHandler[bindings.EventChannelUpdate] `eventsub-type:"channel.update" eventsub-version:"1"`
HandleChannelFollow EventHandler[bindings.EventChannelFollow] `eventsub-type:"channel.follow" eventsub-version:"1"`
HandleChannelUpdate EventHandler[bindings.EventChannelUpdate] `eventsub-type:"channel.update" eventsub-version:"2"`
HandleChannelFollow EventHandler[bindings.EventChannelFollow] `eventsub-type:"channel.follow" eventsub-version:"2"`
HandleChannelSubscribe EventHandler[bindings.EventChannelSubscribe] `eventsub-type:"channel.subscribe" eventsub-version:"1"`
HandleChannelSubscriptionEnd EventHandler[bindings.EventChannelSubscriptionEnd] `eventsub-type:"channel.subscription.end" eventsub-version:"1"`
HandleChannelSubscriptionGift EventHandler[bindings.EventChannelSubscriptionGift] `eventsub-type:"channel.subscription.gift" eventsub-version:"1"`
Expand All @@ -52,8 +52,8 @@ type SubHandler struct {
HandleChannelRaid EventHandler[bindings.EventChannelRaid] `eventsub-type:"channel.raid" eventsub-version:"1"`
HandleChannelBan EventHandler[bindings.EventChannelBan] `eventsub-type:"channel.ban" eventsub-version:"1"`
HandleChannelUnban EventHandler[bindings.EventChannelUnban] `eventsub-type:"channel.unban" eventsub-version:"1"`
HandleChannelUnbanRequestCreate EventHandler[bindings.EventChannelUnbanRequestCreate] `eventsub-type:"channel.unban_request.create" eventsub-version:"1"`
HandleChannelUnbanRequestResolve EventHandler[bindings.EventChannelUnbanRequestResolve] `eventsub-type:"channel.unban_request.resolve" eventsub-version:"1"`
HandleChannelUnbanRequestCreate EventHandler[bindings.EventChannelUnbanRequestCreate] `eventsub-type:"channel.unban_request.create" eventsub-version:"beta"`
HandleChannelUnbanRequestResolve EventHandler[bindings.EventChannelUnbanRequestResolve] `eventsub-type:"channel.unban_request.resolve" eventsub-version:"beta"`
HandleChannelModeratorAdd EventHandler[bindings.EventChannelModeratorAdd] `eventsub-type:"channel.moderator.add" eventsub-version:"1"`
HandleChannelModeratorRemove EventHandler[bindings.EventChannelModeratorRemove] `eventsub-type:"channel.moderator.remove" eventsub-version:"1"`
HandleChannelPointsRewardAdd EventHandler[bindings.EventChannelPointsRewardAdd] `eventsub-type:"channel.channel_points_custom_reward.add" eventsub-version:"1"`
Expand Down
7 changes: 3 additions & 4 deletions handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,26 +153,25 @@ func newVerificationRequestWithType(typ string) func() *http.Request {
}

func newNotificationRequest() *http.Request {
bodyData := []byte(`{"subscription":{"id":"ef7e8fba-6c32-4ead-965d-61f21660d095","status":"enabled","type":"channel.update","version":"1","condition":{"broadcaster_user_id":"132532813"},"transport":{"method":"webhook","callback":"https://testing.proxy.b.dnsge.org/webhooks"},"created_at":"2023-03-09T04:44:48.057734342Z","cost":0},"event":{"broadcaster_user_id":"132532813","broadcaster_user_login":"icelys","broadcaster_user_name":"icelys","title":"hello there!","language":"en","category_id":"509658","category_name":"Just Chatting","is_mature":false}}`)
bodyData := []byte(`{"subscription":{"id":"ef7e8fba-6c32-4ead-965d-61f21660d095","status":"enabled","type":"channel.update","version":"2","condition":{"broadcaster_user_id":"132532813","moderator_user_id":"132532813"},"transport":{"method":"webhook","callback":"https://testing.proxy.b.dnsge.org/webhooks"},"created_at":"2023-03-09T04:44:48.057734342Z","cost":0},"event":{"broadcaster_user_id":"132532813","broadcaster_user_login":"icelys","broadcaster_user_name":"icelys","title":"hello there!","language":"en","category_id":"509658","category_name":"Just Chatting","content_classification_labels":[]}}`)

req := httptest.NewRequest("POST", "/", bytes.NewReader(bodyData))
req.Header = http.Header{
"Content-Type": {"application/json"},
"Twitch-Eventsub-Message-Id": {"eTOJ71BBQNXGNW8qPUNMRGIHH5yv4bBrvwl02DWgF0o="},
"Twitch-Eventsub-Message-Retry": {"0"},
"Twitch-Eventsub-Message-Signature": {"sha256=e6e0d4bc8eb792d9081be6c4fa64416b9a756c5fa4675867f38487f94751f9a6"},
"Twitch-Eventsub-Message-Timestamp": {"2023-03-09T04:45:36.836089549Z"},
"Twitch-Eventsub-Message-Type": {"notification"},
"Twitch-Eventsub-Subscription-Is-Batching-Enabled": {"false"},
"Twitch-Eventsub-Subscription-Type": {"channel.update"},
"Twitch-Eventsub-Subscription-Version": {"1"},
"Twitch-Eventsub-Subscription-Version": {"2"},
}

return req
}

func newNotificationRequestBadVersion() *http.Request {
bodyData := []byte(`{"subscription":{"id":"ef7e8fba-6c32-4ead-965d-61f21660d095","status":"enabled","type":"channel.update","version":"unknown","condition":{"broadcaster_user_id":"132532813"},"transport":{"method":"webhook","callback":"https://testing.proxy.b.dnsge.org/webhooks"},"created_at":"2023-03-09T04:44:48.057734342Z","cost":0},"event":{"broadcaster_user_id":"132532813","broadcaster_user_login":"icelys","broadcaster_user_name":"icelys","title":"hello there!","language":"en","category_id":"509658","category_name":"Just Chatting","is_mature":false}}`)
bodyData := []byte(`{"subscription":{"id":"ef7e8fba-6c32-4ead-965d-61f21660d095","status":"enabled","type":"channel.update","version":"unknown","condition":{"broadcaster_user_id":"132532813","moderator_user_id":"132532813"},"transport":{"method":"webhook","callback":"https://testing.proxy.b.dnsge.org/webhooks"},"created_at":"2023-03-09T04:44:48.057734342Z","cost":0},"event":{"broadcaster_user_id":"132532813","broadcaster_user_login":"icelys","broadcaster_user_name":"icelys","title":"hello there!","language":"en","category_id":"509658","category_name":"Just Chatting","content_classification_labels":[]}}`)

req := httptest.NewRequest("POST", "/", bytes.NewReader(bodyData))
req.Header = http.Header{
Expand Down
8 changes: 4 additions & 4 deletions notification_handler.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 7d25238

Please sign in to comment.