Skip to content

Commit

Permalink
fix: response message & try get value
Browse files Browse the repository at this point in the history
  • Loading branch information
GZTimeWalker committed Apr 1, 2024
1 parent 6842585 commit 133c3d3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
5 changes: 1 addition & 4 deletions src/GZCTF/Controllers/GameController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -533,10 +533,7 @@ public async Task<IActionResult> ChallengesWithTeamInfo([FromRoute] int id, Canc

ScoreboardModel scoreboard = await gameRepository.GetScoreboard(context.Game!, token);

ScoreboardItem? boardItem = scoreboard.Items[context.Participation!.TeamId];

// make sure team info is not null
boardItem ??= new ScoreboardItem
ScoreboardItem boardItem = scoreboard.Items.TryGetValue(context.Participation!.TeamId, out var item) ? item : new()
{
Avatar = context.Participation!.Team.AvatarUrl,
SolvedCount = 0,
Expand Down
4 changes: 2 additions & 2 deletions src/GZCTF/Middlewares/RateLimiter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public static void ConfigureRateLimiter(RateLimiterOptions options)

context.HttpContext.Response.Headers.RetryAfter = afterSec.ToString(NumberFormatInfo.InvariantInfo);
await context.HttpContext.Response.WriteAsJsonAsync(
new RequestResponse(localizer[nameof(Resources.Program.RateLimit_TooManyRequests)],
new RequestResponse(localizer[nameof(Resources.Program.RateLimit_TooManyRequests), afterSec],
StatusCodes.Status429TooManyRequests
), cancellationToken);
};
Expand All @@ -109,4 +109,4 @@ await context.HttpContext.Response.WriteAsJsonAsync(
o.ReplenishmentPeriod = TimeSpan.FromSeconds(5);
});
}
}
}

0 comments on commit 133c3d3

Please sign in to comment.