Skip to content

Commit

Permalink
Resolve issue with ban exporter bans not deserializing correctly (#58)
Browse files Browse the repository at this point in the history
  • Loading branch information
bobbah authored Jul 9, 2023
1 parent 666683d commit 2ef0c4b
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 8 deletions.
2 changes: 0 additions & 2 deletions CentCom.API/CentCom.API.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@

<ItemGroup>
<PackageReference Include="BuildBundlerMinifier" Version="3.2.449" />
<PackageReference Include="Enums.NET" Version="4.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="7.0.8" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="7.0.8" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.8" />
<PackageReference Include="MinVer" Version="4.3.0">
Expand Down
5 changes: 5 additions & 0 deletions CentCom.API/CentCom.API.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions CentCom.API/Models/AppVersionDTO.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ namespace CentCom.API.Models;
/// </summary>
/// <param name="Version">The version of the application in semver</param>
/// <param name="Commit">The commit hash of the build that the application is running</param>
/// <param name="CopyrightNotice">The copyright notice for this version of the application</param>
public record AppVersionDTO(string Version, string Commit, string CopyrightNotice)
{
internal AppVersionDTO(AssemblyInformation assemblyInfo) : this(assemblyInfo.Version, assemblyInfo.Commit,
Expand Down
1 change: 0 additions & 1 deletion CentCom.Common/CentCom.Common.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
<PackageReference Include="Npgsql" Version="7.0.4" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="7.0.4" />
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="7.0.0" />
<PackageReference Include="Quartz" Version="3.6.3" />
<PackageReference Include="Remora.Rest" Version="3.2.0" />
</ItemGroup>

Expand Down
2 changes: 2 additions & 0 deletions CentCom.Common/Models/Rest/RestBan.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Text.Json.Serialization;
using CentCom.Common.Abstract;

namespace CentCom.Common.Models.Rest;
Expand All @@ -15,5 +16,6 @@ public record RestBan
DateTimeOffset? Expires,
ICKey UnbannedBy,
IReadOnlyList<IRestJobBan> JobBans,
[property: JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
int? RoundId
) : IRestBan;
5 changes: 1 addition & 4 deletions CentCom.Server/Services/StandardProviderService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,11 @@
using System.Text.Json;
using System.Text.Json.Serialization;
using System.Threading.Tasks;
using CentCom.Common.Abstract;
using CentCom.Common.Extensions;
using CentCom.Common.Models;
using CentCom.Common.Models.Rest;
using CentCom.Server.Configuration;
using Microsoft.Extensions.Logging;
using Remora.Rest.Extensions;
using RestSharp;
using RestSharp.Serializers.Json;

Expand All @@ -34,7 +32,7 @@ private async Task<IEnumerable<Ban>> GetBansAsync(int? cursor = null)
var request = new RestRequest("api/ban");
if (cursor.HasValue)
request.AddQueryParameter("cursor", cursor.ToString());
var response = await Client.ExecuteAsync<IEnumerable<IRestBan>>(request);
var response = await Client.ExecuteAsync<IEnumerable<RestBan>>(request);

if (response.StatusCode != HttpStatusCode.OK)
FailedRequest(response);
Expand Down Expand Up @@ -92,7 +90,6 @@ public void Configure(StandardProviderConfiguration config)
// Setup JSON for client
var options = new JsonSerializerOptions();
options.AddCentComOptions();
options.AddDataObjectConverter<IRestBan, RestBan>();
options.PropertyNamingPolicy = JsonNamingPolicy.CamelCase;
options.Converters.Insert(0, new JsonStringEnumConverter());

Expand Down
1 change: 0 additions & 1 deletion CentCom.Test/CentCom.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@

<ItemGroup>
<ProjectReference Include="..\CentCom.Common\CentCom.Common.csproj" />
<ProjectReference Include="..\CentCom.Exporter\CentCom.Exporter.csproj" />
<ProjectReference Include="..\CentCom.Server\CentCom.Server.csproj" />
</ItemGroup>

Expand Down

0 comments on commit 2ef0c4b

Please sign in to comment.