Skip to content

Commit

Permalink
fix(post/edit): Fix various validation issues
Browse files Browse the repository at this point in the history
- In NotificationBase.cs, fixed the initialization of EmittedAt property to use DateTimeOffset.UtcNow instead of DateTime.UtcNow.
- In PostModAction.cs, removed redundant empty lines.
- In ReplayChatMessageDTO.cs, marked PlayerId, Username, MessageGroup, and MessageContent properties as nullable to disable API validation.
- In ReplayDTO.cs, initialized DownloadUri with an empty string and Players and ChatMessages properties with empty arrays.
  • Loading branch information
SakuraIsayeki committed Jan 11, 2024
1 parent 2a44118 commit 10129fe
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public abstract record NotificationBase : INotification

public abstract NotificationType Type { get; private protected init; }

public DateTimeOffset EmittedAt { get; private protected init; } = DateTime.UtcNow;
public DateTimeOffset EmittedAt { get; private protected init; } = DateTimeOffset.UtcNow;
public DateTimeOffset? AcknowledgedAt { get; set; }

public virtual NotificationBaseDTO ToDTO() => new()
Expand Down
2 changes: 0 additions & 2 deletions WowsKarma.Api/Data/Models/PostModAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ public record PostModAction
public Post Post { get; init; }
public Guid PostId { get; init; }



public ModActionType ActionType { get; init; }

public Player Mod { get; init; }
Expand Down
11 changes: 7 additions & 4 deletions WowsKarma.Common/Models/DTOs/Replays/ReplayChatMessageDTO.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
namespace WowsKarma.Common.Models.DTOs.Replays;

/// <remarks>
/// HACK: Fields are set as nullable to disable API validation.
/// </remarks>
public struct ReplayChatMessageDTO
{
public uint PlayerId { get; init; }
public string Username { get; init; }
public uint? PlayerId { get; init; }
public string? Username { get; init; }

public string MessageGroup { get; init; }
public string? MessageGroup { get; init; }

public string MessageContent { get; init; }
public string? MessageContent { get; init; }
}
8 changes: 4 additions & 4 deletions WowsKarma.Common/Models/DTOs/Replays/ReplayDTO.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
namespace WowsKarma.Common.Models.DTOs.Replays;

public record ReplayDTO
public sealed record ReplayDTO
{
public Guid Id { get; init; }

public Guid PostId { get; init; }

public string DownloadUri { get; init; }
public string DownloadUri { get; init; } = "";

public string? MinimapUri { get; init; }

public IEnumerable<ReplayPlayerDTO> Players { get; set; }
public IEnumerable<ReplayPlayerDTO> Players { get; set; } = [];

public IEnumerable<ReplayChatMessageDTO> ChatMessages { get; set; }
public IEnumerable<ReplayChatMessageDTO> ChatMessages { get; set; } = [];
}
3 changes: 2 additions & 1 deletion WowsKarma.Common/WowsKarma.Common.csproj
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<LangVersion>preview</LangVersion>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

<ItemGroup>
Expand Down

0 comments on commit 10129fe

Please sign in to comment.