Skip to content

use validator for scopes #368

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
- `TeamInformation::thumbnail_url` is now optional (`Option<String>`).
- Made many structs & enums non exhaustive
- Renamed `GetBlockedTerms` -> `GetBlockedTermsRequest`
- Changed `SCOPES` on `helix::Request`, `pubsub::Topic` and `eventsub::EventSubscription` to be `twitch_oauth2::Validator`
- Updated `twitch_oauth2` dependency

### Changes

Expand All @@ -40,10 +42,10 @@
- Deprecated `channel.follow` v1 eventsub event
- Deprecated `Get User Follows` and associated follower related extension methods
- Deprecated Twitch-defined tags: `Get All Stream Tags`, `Get Stream Tags`, `Replace Stream Tags` and `TwitchTag`
- Added `beta` feature to specifically enable beta endpoints

### Added

- Added `beta` feature to specifically enable beta endpoints
- Added `Ban User` and `Unban User`
- Added `Get Chat Settings` endpoint
- Added `type` and `user_id` query params to `GetEventSubSubscriptionsRequest`
Expand Down
77 changes: 43 additions & 34 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ exclude = ["twitch_types", "twitch_oauth2"]

[workspace.dependencies]
twitch_api = { version = "0.7.0-rc.6", path = "." }
twitch_oauth2 = { version = "0.12.1", path = "twitch_oauth2/" }
twitch_oauth2 = { version = "0.12.2", path = "twitch_oauth2/" }
twitch_types = { version = "0.4.1", features = [
"serde",
], path = "./twitch_types" }
Expand Down
3 changes: 2 additions & 1 deletion src/eventsub/channel/ban.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ impl EventSubscription for ChannelBanV1 {

const EVENT_TYPE: EventType = EventType::ChannelBan;
#[cfg(feature = "twitch_oauth2")]
const SCOPE: &'static [twitch_oauth2::Scope] = &[twitch_oauth2::Scope::ChannelModerate];
const SCOPE: twitch_oauth2::Validator =
twitch_oauth2::validator![twitch_oauth2::Scope::ChannelModerate];
const VERSION: &'static str = "1";
}

Expand Down
5 changes: 4 additions & 1 deletion src/eventsub/channel/channel_points_custom_reward/add.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ impl EventSubscription for ChannelPointsCustomRewardAddV1 {

const EVENT_TYPE: EventType = EventType::ChannelPointsCustomRewardAdd;
#[cfg(feature = "twitch_oauth2")]
const SCOPE: &'static [twitch_oauth2::Scope] = &[twitch_oauth2::Scope::ChannelReadRedemptions];
const SCOPE: twitch_oauth2::Validator = twitch_oauth2::validator![any(
twitch_oauth2::Scope::ChannelReadRedemptions,
twitch_oauth2::Scope::ChannelManageRedemptions
)];
const VERSION: &'static str = "1";
}

Expand Down
5 changes: 4 additions & 1 deletion src/eventsub/channel/channel_points_custom_reward/remove.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ impl EventSubscription for ChannelPointsCustomRewardRemoveV1 {

const EVENT_TYPE: EventType = EventType::ChannelPointsCustomRewardRemove;
#[cfg(feature = "twitch_oauth2")]
const SCOPE: &'static [twitch_oauth2::Scope] = &[twitch_oauth2::Scope::ChannelReadRedemptions];
const SCOPE: twitch_oauth2::Validator = twitch_oauth2::validator![any(
twitch_oauth2::Scope::ChannelReadRedemptions,
twitch_oauth2::Scope::ChannelManageRedemptions
)];
const VERSION: &'static str = "1";
}

Expand Down
5 changes: 4 additions & 1 deletion src/eventsub/channel/channel_points_custom_reward/update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ impl EventSubscription for ChannelPointsCustomRewardUpdateV1 {

const EVENT_TYPE: EventType = EventType::ChannelPointsCustomRewardUpdate;
#[cfg(feature = "twitch_oauth2")]
const SCOPE: &'static [twitch_oauth2::Scope] = &[twitch_oauth2::Scope::ChannelReadRedemptions];
const SCOPE: twitch_oauth2::Validator = twitch_oauth2::validator![any(
twitch_oauth2::Scope::ChannelReadRedemptions,
twitch_oauth2::Scope::ChannelManageRedemptions
)];
const VERSION: &'static str = "1";
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ impl EventSubscription for ChannelPointsCustomRewardRedemptionAddV1 {

const EVENT_TYPE: EventType = EventType::ChannelPointsCustomRewardRedemptionAdd;
#[cfg(feature = "twitch_oauth2")]
const SCOPE: &'static [twitch_oauth2::Scope] = &[twitch_oauth2::Scope::ChannelReadRedemptions];
const SCOPE: twitch_oauth2::Validator = twitch_oauth2::validator![any(
twitch_oauth2::Scope::ChannelReadRedemptions,
twitch_oauth2::Scope::ChannelManageRedemptions
)];
const VERSION: &'static str = "1";
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ impl EventSubscription for ChannelPointsCustomRewardRedemptionUpdateV1 {

const EVENT_TYPE: EventType = EventType::ChannelPointsCustomRewardRedemptionUpdate;
#[cfg(feature = "twitch_oauth2")]
const SCOPE: &'static [twitch_oauth2::Scope] = &[twitch_oauth2::Scope::ChannelReadRedemptions];
const SCOPE: twitch_oauth2::Validator = twitch_oauth2::validator![any(
twitch_oauth2::Scope::ChannelReadRedemptions,
twitch_oauth2::Scope::ChannelManageRedemptions
)];
const VERSION: &'static str = "1";
}

Expand Down
3 changes: 2 additions & 1 deletion src/eventsub/channel/charity_campaign/donate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ impl EventSubscription for ChannelCharityCampaignDonateV1 {

const EVENT_TYPE: EventType = EventType::ChannelCharityCampaignDonate;
#[cfg(feature = "twitch_oauth2")]
const SCOPE: &'static [twitch_oauth2::Scope] = &[twitch_oauth2::Scope::ChannelReadCharity];
const SCOPE: twitch_oauth2::Validator =
twitch_oauth2::validator![twitch_oauth2::Scope::ChannelReadCharity];
const VERSION: &'static str = "1";
}

Expand Down
3 changes: 2 additions & 1 deletion src/eventsub/channel/charity_campaign/progress.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ impl EventSubscription for ChannelCharityCampaignProgressV1 {

const EVENT_TYPE: EventType = EventType::ChannelCharityCampaignProgress;
#[cfg(feature = "twitch_oauth2")]
const SCOPE: &'static [twitch_oauth2::Scope] = &[twitch_oauth2::Scope::ChannelReadCharity];
const SCOPE: twitch_oauth2::Validator =
twitch_oauth2::validator![twitch_oauth2::Scope::ChannelReadCharity];
const VERSION: &'static str = "1";
}

Expand Down
3 changes: 2 additions & 1 deletion src/eventsub/channel/charity_campaign/start.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ impl EventSubscription for ChannelCharityCampaignStartV1 {

const EVENT_TYPE: EventType = EventType::ChannelCharityCampaignStart;
#[cfg(feature = "twitch_oauth2")]
const SCOPE: &'static [twitch_oauth2::Scope] = &[twitch_oauth2::Scope::ChannelReadCharity];
const SCOPE: twitch_oauth2::Validator =
twitch_oauth2::validator![twitch_oauth2::Scope::ChannelReadCharity];
const VERSION: &'static str = "1";
}

Expand Down
3 changes: 2 additions & 1 deletion src/eventsub/channel/charity_campaign/stop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ impl EventSubscription for ChannelCharityCampaignStopV1 {

const EVENT_TYPE: EventType = EventType::ChannelCharityCampaignStop;
#[cfg(feature = "twitch_oauth2")]
const SCOPE: &'static [twitch_oauth2::Scope] = &[twitch_oauth2::Scope::ChannelReadCharity];
const SCOPE: twitch_oauth2::Validator =
twitch_oauth2::validator![twitch_oauth2::Scope::ChannelReadCharity];
const VERSION: &'static str = "1";
}

Expand Down
3 changes: 2 additions & 1 deletion src/eventsub/channel/cheer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ impl EventSubscription for ChannelCheerV1 {

const EVENT_TYPE: EventType = EventType::ChannelCheer;
#[cfg(feature = "twitch_oauth2")]
const SCOPE: &'static [twitch_oauth2::Scope] = &[twitch_oauth2::Scope::BitsRead];
const SCOPE: twitch_oauth2::Validator =
twitch_oauth2::validator![twitch_oauth2::Scope::BitsRead];
const VERSION: &'static str = "1";
}

Expand Down
5 changes: 3 additions & 2 deletions src/eventsub/channel/follow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ impl EventSubscription for ChannelFollowV1 {

const EVENT_TYPE: EventType = EventType::ChannelFollow;
#[cfg(feature = "twitch_oauth2")]
const SCOPE: &'static [twitch_oauth2::Scope] = &[];
const SCOPE: twitch_oauth2::Validator = twitch_oauth2::validator![];
const VERSION: &'static str = "1";
}

Expand Down Expand Up @@ -122,7 +122,8 @@ impl EventSubscription for ChannelFollowV2 {

const EVENT_TYPE: EventType = EventType::ChannelFollow;
#[cfg(feature = "twitch_oauth2")]
const SCOPE: &'static [twitch_oauth2::Scope] = &[twitch_oauth2::Scope::ModeratorReadFollowers];
const SCOPE: twitch_oauth2::Validator =
twitch_oauth2::validator![twitch_oauth2::Scope::ModeratorReadFollowers];
const VERSION: &'static str = "2";
}

Expand Down
Loading