Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,9 @@ public sealed class HelldiversSyncConfiguration
/// Get the maximum number of entries returned by ArrowHead from the newsfeed API.
/// </summary>
public uint NewsFeedMaxEntries { get; set; } = 1024;

/// <summary>
/// Get all news feed entries that were published after this timestamp
/// </summary>
public uint NewsFeedFromTimestamp { get; set; } = 1000;
}
6 changes: 4 additions & 2 deletions src/Helldivers-2-Sync/Services/ArrowHeadApiService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,16 +74,18 @@ public async Task<Memory<byte>> GetWarStatus(string season, string language, Can
public async Task<Memory<byte>> 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);

// Throw on error responses so we don't have to look down the entire serialisation tree.
response.EnsureSuccessStatusCode();

await using var stream = await response.Content.ReadAsStreamAsync(cancellationToken);

return await CollectStream(stream, cancellationToken);
}

Expand Down