From e9135e8af66887a29b242390851127264b2e583f Mon Sep 17 00:00:00 2001 From: Matthew Olivo Date: Wed, 20 Sep 2023 21:13:10 -0700 Subject: [PATCH] - Adding in check for YouTube membership capabilities before performing any queries for data related to it --- .../Platform/YouTubeUserPlatformV2Model.cs | 31 ++++++++++--------- .../YouTube/YouTubePlatformService.cs | 4 +-- .../Services/YouTube/YouTubeSessionService.cs | 2 ++ 3 files changed, 21 insertions(+), 16 deletions(-) diff --git a/MixItUp.Base/Model/User/Platform/YouTubeUserPlatformV2Model.cs b/MixItUp.Base/Model/User/Platform/YouTubeUserPlatformV2Model.cs index f01223f88..6b82711ac 100644 --- a/MixItUp.Base/Model/User/Platform/YouTubeUserPlatformV2Model.cs +++ b/MixItUp.Base/Model/User/Platform/YouTubeUserPlatformV2Model.cs @@ -95,21 +95,24 @@ public void SetMessageProperties(LiveChatMessage message) public async Task RefreshMembershipDetails() { - Member membership = await ServiceManager.Get().UserConnection.CheckIfMember(this.ID); - if (membership != null) + if (ServiceManager.Get().HasMembershipCapabilities) { - this.Roles.Add(UserRoleEnum.YouTubeMember); - this.Roles.Add(UserRoleEnum.Subscriber); - this.SubscribeDate = DateTime.Parse(membership.Snippet.MembershipsDetails.MembershipsDuration.MemberSince); - this.MemberLevels.Clear(); - this.MemberLevels.AddRange(membership.Snippet.MembershipsDetails.AccessibleLevels); - } - else - { - this.Roles.Remove(UserRoleEnum.YouTubeMember); - this.Roles.Remove(UserRoleEnum.Subscriber); - this.SubscribeDate = null; - this.MemberLevels.Clear(); + Member membership = await ServiceManager.Get().UserConnection.CheckIfMember(this.ID); + if (membership != null) + { + this.Roles.Add(UserRoleEnum.YouTubeMember); + this.Roles.Add(UserRoleEnum.Subscriber); + this.SubscribeDate = DateTime.Parse(membership.Snippet.MembershipsDetails.MembershipsDuration.MemberSince); + this.MemberLevels.Clear(); + this.MemberLevels.AddRange(membership.Snippet.MembershipsDetails.AccessibleLevels); + } + else + { + this.Roles.Remove(UserRoleEnum.YouTubeMember); + this.Roles.Remove(UserRoleEnum.Subscriber); + this.SubscribeDate = null; + this.MemberLevels.Clear(); + } } } diff --git a/MixItUp.Base/Services/YouTube/YouTubePlatformService.cs b/MixItUp.Base/Services/YouTube/YouTubePlatformService.cs index 9bb8a9046..25698bd83 100644 --- a/MixItUp.Base/Services/YouTube/YouTubePlatformService.cs +++ b/MixItUp.Base/Services/YouTube/YouTubePlatformService.cs @@ -105,8 +105,6 @@ public YouTubePlatformService(YouTubeConnection connection) public async Task