diff --git a/ExternalAPIs/TwitchTv/Helix/TwitchTvHelixHelixReadonlyClient.cs b/ExternalAPIs/TwitchTv/Helix/TwitchTvHelixHelixReadonlyClient.cs index 164fe10..51b7e4a 100644 --- a/ExternalAPIs/TwitchTv/Helix/TwitchTvHelixHelixReadonlyClient.cs +++ b/ExternalAPIs/TwitchTv/Helix/TwitchTvHelixHelixReadonlyClient.cs @@ -198,10 +198,9 @@ public void SetAccessToken(string accessToken) private Task ExecuteRequest(string request, CancellationToken cancellationToken = default) { HttpClient httpClient = HttpClientExtensions.CreateCompressionHttpClient(); + httpClient.DefaultRequestHeaders.Add(RequestConstants.ClientIdHeaderKey, RequestConstants.ClientIdHeaderValue); if (_accessToken != null) - httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", _accessToken); - else - httpClient.DefaultRequestHeaders.Add(RequestConstants.ClientIdHeaderKey, RequestConstants.ClientIdHeaderValue); + httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", _accessToken); return httpClient.ExecuteRequest(request, cancellationToken); } diff --git a/GlobalAssemblyInfo.cs b/GlobalAssemblyInfo.cs index b7adc97..7b9a007 100644 --- a/GlobalAssemblyInfo.cs +++ b/GlobalAssemblyInfo.cs @@ -22,5 +22,5 @@ // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("2.12.6.0")] -[assembly: AssemblyFileVersion("2.12.6.0")] \ No newline at end of file +[assembly: AssemblyVersion("2.12.7.0")] +[assembly: AssemblyFileVersion("2.12.7.0")] \ No newline at end of file diff --git a/Livestream.Monitor/Model/ApiClients/TwitchApiClient.cs b/Livestream.Monitor/Model/ApiClients/TwitchApiClient.cs index a41a8dc..333bb32 100644 --- a/Livestream.Monitor/Model/ApiClients/TwitchApiClient.cs +++ b/Livestream.Monitor/Model/ApiClients/TwitchApiClient.cs @@ -28,7 +28,7 @@ public class TwitchApiClient : IApiClient private readonly ITwitchTvV5ReadonlyClient twitchTvV5ReadonlyClient; private readonly ITwitchTvHelixReadonlyClient twitchTvHelixClient; private readonly ISettingsHandler settingsHandler; - private readonly HashSet moniteredChannels = new HashSet(); + private readonly HashSet monitoredChannels = new HashSet(); private readonly Dictionary gameNameToIdMap = new Dictionary(); private readonly Dictionary gameIdToNameMap = new Dictionary(); private readonly Dictionary channelIdToUserMap = new Dictionary(); @@ -193,7 +193,7 @@ public async Task> AddChannel(ChannelIdentifier newC if (queryResults.All(x => x.IsSuccess)) { - moniteredChannels.Add(newChannel); + monitoredChannels.Add(newChannel); } return queryResults; } @@ -201,20 +201,20 @@ public async Task> AddChannel(ChannelIdentifier newC public void AddChannelWithoutQuerying(ChannelIdentifier newChannel) { if (newChannel == null) throw new ArgumentNullException(nameof(newChannel)); - moniteredChannels.Add(newChannel); + monitoredChannels.Add(newChannel); } public Task RemoveChannel(ChannelIdentifier channelIdentifier) { channelIdToUserMap.Remove(channelIdentifier.ChannelId); - moniteredChannels.Remove(channelIdentifier); + monitoredChannels.Remove(channelIdentifier); return Task.CompletedTask; } public async Task> QueryChannels(CancellationToken cancellationToken) { var queryResults = new List(); - if (moniteredChannels.Count == 0) return queryResults; + if (monitoredChannels.Count == 0) return queryResults; // Twitch "get streams" call only returns online streams so to determine if the stream actually exists/is still valid, we must specifically ask for channel details. List onlineStreams = new List(); @@ -226,7 +226,7 @@ public async Task> QueryChannels(CancellationToken c try { var query = new GetStreamsQuery(); - query.UserIds.AddRange(moniteredChannels.Select(x => x.ChannelId)); + query.UserIds.AddRange(monitoredChannels.Select(x => x.ChannelId)); onlineStreams = await twitchTvHelixClient.GetStreams(query, cancellationToken); success = true; } @@ -241,7 +241,7 @@ public async Task> QueryChannels(CancellationToken c { if (cancellationToken.IsCancellationRequested) return queryResults; - var channelIdentifier = moniteredChannels.First(x => x.ChannelId.IsEqualTo(onlineStream.UserId)); + var channelIdentifier = monitoredChannels.First(x => x.ChannelId.IsEqualTo(onlineStream.UserId)); var gameName = await GetGameNameById(onlineStream.GameId); var livestream = new LivestreamModel(onlineStream.UserId, channelIdentifier); @@ -253,7 +253,7 @@ public async Task> QueryChannels(CancellationToken c }); } - var offlineStreams = moniteredChannels.Where(x => onlineStreams.All(y => y.UserId != x.ChannelId)).ToList(); + var offlineStreams = monitoredChannels.Where(x => onlineStreams.All(y => y.UserId != x.ChannelId)).ToList(); foreach (var offlineStream in offlineStreams) { var queryResult = new LivestreamQueryResult(offlineStream) @@ -421,7 +421,7 @@ public async Task Initialize(CancellationToken cancellationToken = default) { // initialize user cache var usersQuery = new GetUsersQuery(); - usersQuery.UserIds.AddRange(moniteredChannels.Select(x => x.ChannelId)); + usersQuery.UserIds.AddRange(monitoredChannels.Select(x => x.ChannelId)); var users = await twitchTvHelixClient.GetUsers(usersQuery, cancellationToken); foreach (var user in users) {