diff --git a/src/Helldivers-2-Sync/Configuration/HelldiversSyncConfiguration.cs b/src/Helldivers-2-Sync/Configuration/HelldiversSyncConfiguration.cs index d82dc62..61819c7 100644 --- a/src/Helldivers-2-Sync/Configuration/HelldiversSyncConfiguration.cs +++ b/src/Helldivers-2-Sync/Configuration/HelldiversSyncConfiguration.cs @@ -35,4 +35,9 @@ public sealed class HelldiversSyncConfiguration /// Get the maximum number of entries returned by ArrowHead from the newsfeed API. /// public uint NewsFeedMaxEntries { get; set; } = 1024; + + /// + /// Get all news feed entries that were published after this timestamp + /// + public uint NewsFeedFromTimestamp { get; set; } = 1000; } diff --git a/src/Helldivers-2-Sync/Services/ArrowHeadApiService.cs b/src/Helldivers-2-Sync/Services/ArrowHeadApiService.cs index 0e2223a..1ac5ae1 100644 --- a/src/Helldivers-2-Sync/Services/ArrowHeadApiService.cs +++ b/src/Helldivers-2-Sync/Services/ArrowHeadApiService.cs @@ -74,9 +74,10 @@ public async Task> GetWarStatus(string season, string language, Can public async Task> LoadFeed(string season, string language, CancellationToken cancellationToken) { // If the `NewsFeedMaxEntries` flag is not set to 0 we pass it in. + // This parameter needs to be passed or a 400 status code will be returned occasionally. var request = options.Value.NewsFeedMaxEntries is 0 - ? BuildRequest($"/api/NewsFeed/{season}", language) - : BuildRequest($"/api/NewsFeed/{season}?maxEntries=${options.Value.NewsFeedMaxEntries}", language); + ? BuildRequest($"/api/NewsFeed/{season}?fromTimestamp={options.Value.NewsFeedFromTimestamp}", language) + : BuildRequest($"/api/NewsFeed/{season}?maxEntries={options.Value.NewsFeedMaxEntries}&fromTimestamp={options.Value.NewsFeedFromTimestamp}", language); using var response = await http.SendAsync(request, cancellationToken); @@ -84,6 +85,7 @@ public async Task> LoadFeed(string season, string language, Cancell response.EnsureSuccessStatusCode(); await using var stream = await response.Content.ReadAsStreamAsync(cancellationToken); + return await CollectStream(stream, cancellationToken); }