Skip to content

Commit 50cd227

Browse files
committed
use validator for scopes
1 parent 668a413 commit 50cd227

File tree

149 files changed

+348
-215
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

149 files changed

+348
-215
lines changed

CHANGELOG.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
- All (most) types are now living in their own crate `twitch_types`
1818
- Features for clients are now named after the client, e.g feature `reqwest_client` is now simply `reqwest`
1919
- Fixed wrong type on `UserAuthorizationGrantV1::client_id`
20-
- Deprecate `bits_voting_enabled`, `bits_per_vote` and `bits_votes` on `Create Poll` and `Poll` and made the fields optional
2120
- `Get Clips` takes and returns `ClipId` instead of a string
2221
- Made `GetCustomRewardRedemptionRequest::reward_id` optional
2322
- `typed-builder` is now optional and not enabled by default, enable feature `typed-builder` to use the `::builder()` methods
@@ -27,9 +26,12 @@
2726
- `TeamInformation::thumbnail_url` is now optional (`Option<String>`).
2827
- Made many structs & enums non exhaustive
2928
- Renamed `GetBlockedTerms` -> `GetBlockedTermsRequest`
29+
- Changed `SCOPES` on `helix::Request`, `pubsub::Topic` and `eventsub::EventSubscription` to be `twitch_oauth2::Validator`
30+
- Updated `twitch_oauth2` dependency
3031

3132
### Changes
3233

34+
- Deprecate `bits_voting_enabled`, `bits_per_vote` and `bits_votes` on `Create Poll` and `Poll` and made the fields optional
3335
- Deprecate `Get User` `view_count`
3436
- Deprecate `Check AutoMod status` `user_id`
3537
- Removed deprecated `limit` on `GetEventSubSubscriptionsRequest` response
@@ -40,10 +42,10 @@
4042
- Deprecated `channel.follow` v1 eventsub event
4143
- Deprecated `Get User Follows` and associated follower related extension methods
4244
- Deprecated Twitch-defined tags: `Get All Stream Tags`, `Get Stream Tags`, `Replace Stream Tags` and `TwitchTag`
43-
- Added `beta` feature to specifically enable beta endpoints
4445

4546
### Added
4647

48+
- Added `beta` feature to specifically enable beta endpoints
4749
- Added `Ban User` and `Unban User`
4850
- Added `Get Chat Settings` endpoint
4951
- Added `type` and `user_id` query params to `GetEventSubSubscriptionsRequest`

Cargo.lock

Lines changed: 43 additions & 34 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ exclude = ["twitch_types", "twitch_oauth2"]
2828

2929
[workspace.dependencies]
3030
twitch_api = { version = "0.7.0-rc.6", path = "." }
31-
twitch_oauth2 = { version = "0.12.1", path = "twitch_oauth2/" }
31+
twitch_oauth2 = { version = "0.12.2", path = "twitch_oauth2/" }
3232
twitch_types = { version = "0.4.1", features = [
3333
"serde",
3434
], path = "./twitch_types" }

src/eventsub/channel/ban.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ impl EventSubscription for ChannelBanV1 {
2727

2828
const EVENT_TYPE: EventType = EventType::ChannelBan;
2929
#[cfg(feature = "twitch_oauth2")]
30-
const SCOPE: &'static [twitch_oauth2::Scope] = &[twitch_oauth2::Scope::ChannelModerate];
30+
const SCOPE: twitch_oauth2::Validator =
31+
twitch_oauth2::validator![twitch_oauth2::Scope::ChannelModerate];
3132
const VERSION: &'static str = "1";
3233
}
3334

src/eventsub/channel/channel_points_custom_reward/add.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,10 @@ impl EventSubscription for ChannelPointsCustomRewardAddV1 {
2727

2828
const EVENT_TYPE: EventType = EventType::ChannelPointsCustomRewardAdd;
2929
#[cfg(feature = "twitch_oauth2")]
30-
const SCOPE: &'static [twitch_oauth2::Scope] = &[twitch_oauth2::Scope::ChannelReadRedemptions];
30+
const SCOPE: twitch_oauth2::Validator = twitch_oauth2::validator![any(
31+
twitch_oauth2::Scope::ChannelReadRedemptions,
32+
twitch_oauth2::Scope::ChannelManageRedemptions
33+
)];
3134
const VERSION: &'static str = "1";
3235
}
3336

src/eventsub/channel/channel_points_custom_reward/remove.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,10 @@ impl EventSubscription for ChannelPointsCustomRewardRemoveV1 {
3737

3838
const EVENT_TYPE: EventType = EventType::ChannelPointsCustomRewardRemove;
3939
#[cfg(feature = "twitch_oauth2")]
40-
const SCOPE: &'static [twitch_oauth2::Scope] = &[twitch_oauth2::Scope::ChannelReadRedemptions];
40+
const SCOPE: twitch_oauth2::Validator = twitch_oauth2::validator![any(
41+
twitch_oauth2::Scope::ChannelReadRedemptions,
42+
twitch_oauth2::Scope::ChannelManageRedemptions
43+
)];
4144
const VERSION: &'static str = "1";
4245
}
4346

src/eventsub/channel/channel_points_custom_reward/update.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,10 @@ impl EventSubscription for ChannelPointsCustomRewardUpdateV1 {
3737

3838
const EVENT_TYPE: EventType = EventType::ChannelPointsCustomRewardUpdate;
3939
#[cfg(feature = "twitch_oauth2")]
40-
const SCOPE: &'static [twitch_oauth2::Scope] = &[twitch_oauth2::Scope::ChannelReadRedemptions];
40+
const SCOPE: twitch_oauth2::Validator = twitch_oauth2::validator![any(
41+
twitch_oauth2::Scope::ChannelReadRedemptions,
42+
twitch_oauth2::Scope::ChannelManageRedemptions
43+
)];
4144
const VERSION: &'static str = "1";
4245
}
4346

src/eventsub/channel/channel_points_custom_reward_redemption/add.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,10 @@ impl EventSubscription for ChannelPointsCustomRewardRedemptionAddV1 {
3737

3838
const EVENT_TYPE: EventType = EventType::ChannelPointsCustomRewardRedemptionAdd;
3939
#[cfg(feature = "twitch_oauth2")]
40-
const SCOPE: &'static [twitch_oauth2::Scope] = &[twitch_oauth2::Scope::ChannelReadRedemptions];
40+
const SCOPE: twitch_oauth2::Validator = twitch_oauth2::validator![any(
41+
twitch_oauth2::Scope::ChannelReadRedemptions,
42+
twitch_oauth2::Scope::ChannelManageRedemptions
43+
)];
4144
const VERSION: &'static str = "1";
4245
}
4346

src/eventsub/channel/channel_points_custom_reward_redemption/update.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,10 @@ impl EventSubscription for ChannelPointsCustomRewardRedemptionUpdateV1 {
3737

3838
const EVENT_TYPE: EventType = EventType::ChannelPointsCustomRewardRedemptionUpdate;
3939
#[cfg(feature = "twitch_oauth2")]
40-
const SCOPE: &'static [twitch_oauth2::Scope] = &[twitch_oauth2::Scope::ChannelReadRedemptions];
40+
const SCOPE: twitch_oauth2::Validator = twitch_oauth2::validator![any(
41+
twitch_oauth2::Scope::ChannelReadRedemptions,
42+
twitch_oauth2::Scope::ChannelManageRedemptions
43+
)];
4144
const VERSION: &'static str = "1";
4245
}
4346

src/eventsub/channel/charity_campaign/donate.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ impl EventSubscription for ChannelCharityCampaignDonateV1 {
2626

2727
const EVENT_TYPE: EventType = EventType::ChannelCharityCampaignDonate;
2828
#[cfg(feature = "twitch_oauth2")]
29-
const SCOPE: &'static [twitch_oauth2::Scope] = &[twitch_oauth2::Scope::ChannelReadCharity];
29+
const SCOPE: twitch_oauth2::Validator =
30+
twitch_oauth2::validator![twitch_oauth2::Scope::ChannelReadCharity];
3031
const VERSION: &'static str = "1";
3132
}
3233

src/eventsub/channel/charity_campaign/progress.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ impl EventSubscription for ChannelCharityCampaignProgressV1 {
2626

2727
const EVENT_TYPE: EventType = EventType::ChannelCharityCampaignProgress;
2828
#[cfg(feature = "twitch_oauth2")]
29-
const SCOPE: &'static [twitch_oauth2::Scope] = &[twitch_oauth2::Scope::ChannelReadCharity];
29+
const SCOPE: twitch_oauth2::Validator =
30+
twitch_oauth2::validator![twitch_oauth2::Scope::ChannelReadCharity];
3031
const VERSION: &'static str = "1";
3132
}
3233

src/eventsub/channel/charity_campaign/start.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ impl EventSubscription for ChannelCharityCampaignStartV1 {
2626

2727
const EVENT_TYPE: EventType = EventType::ChannelCharityCampaignStart;
2828
#[cfg(feature = "twitch_oauth2")]
29-
const SCOPE: &'static [twitch_oauth2::Scope] = &[twitch_oauth2::Scope::ChannelReadCharity];
29+
const SCOPE: twitch_oauth2::Validator =
30+
twitch_oauth2::validator![twitch_oauth2::Scope::ChannelReadCharity];
3031
const VERSION: &'static str = "1";
3132
}
3233

src/eventsub/channel/charity_campaign/stop.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ impl EventSubscription for ChannelCharityCampaignStopV1 {
2626

2727
const EVENT_TYPE: EventType = EventType::ChannelCharityCampaignStop;
2828
#[cfg(feature = "twitch_oauth2")]
29-
const SCOPE: &'static [twitch_oauth2::Scope] = &[twitch_oauth2::Scope::ChannelReadCharity];
29+
const SCOPE: twitch_oauth2::Validator =
30+
twitch_oauth2::validator![twitch_oauth2::Scope::ChannelReadCharity];
3031
const VERSION: &'static str = "1";
3132
}
3233

src/eventsub/channel/cheer.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ impl EventSubscription for ChannelCheerV1 {
2727

2828
const EVENT_TYPE: EventType = EventType::ChannelCheer;
2929
#[cfg(feature = "twitch_oauth2")]
30-
const SCOPE: &'static [twitch_oauth2::Scope] = &[twitch_oauth2::Scope::BitsRead];
30+
const SCOPE: twitch_oauth2::Validator =
31+
twitch_oauth2::validator![twitch_oauth2::Scope::BitsRead];
3132
const VERSION: &'static str = "1";
3233
}
3334

0 commit comments

Comments
 (0)