Files
tbd-station-14/Content.Shared/Administration/Notes/SharedAdminNote.cs
Pieter-Jan Briers 2e6eaa45c5 Fix admin notes and database time nonsense. (#25280)
God bloody christ. There's like three layers of shit here.

So firstly, apparently we were still using Npgsql.EnableLegacyTimestampBehavior. This means that time values (which are stored UTC in the database) were converted to local time when read out. This meant they were passed around as kind Local to clients (instead of UTC in the case of SQLite). That's easy enough to fix just turn off the flag and fix the couple spots we're passing a local DateTime ez.

Oh but it turns out there's a DIFFERENT problem with SQLite: See SQLite we definitely store the DateTimes as UTC, but when Microsoft.Data.Sqlite reads them it reads them as Kind Unspecified instead of Utc.

Why are these so bad? Because the admin notes system passes DateTime instances from EF Core straight to the rest of the game code. And that means it's a PAIN IN THE ASS to run the necessary conversions to fix the DateTime instances. GOD DAMNIT now I have to make a whole new set of "Record" entities so we avoid leaking the EF Core model entities. WAAAAAAA.

Fixes #19897
2024-02-20 10:13:31 +01:00

28 lines
1.4 KiB
C#

using Content.Shared.Database;
using Robust.Shared.Network;
using Robust.Shared.Serialization;
namespace Content.Shared.Administration.Notes;
[Serializable, NetSerializable]
public sealed record SharedAdminNote(
int Id, // Id of note, message, watchlist, ban or role ban. Should be paired with NoteType to uniquely identify a shared admin note.
NetUserId Player, // Notes player
int? Round, // Which round was it added in?
string? ServerName, // Which server was this added on?
TimeSpan PlaytimeAtNote, // Playtime at the time of getting the note
NoteType NoteType, // Type of note
string Message, // Attached message
NoteSeverity? NoteSeverity, // Severity of the note, ban or role ban. Otherwise null.
bool Secret, // Is it visible to the player (only relevant if players can see their own notes)
string CreatedByName, // Who created it?
string EditedByName, // Who edited it last?
DateTime CreatedAt, // When was it created?
DateTime? LastEditedAt, // When was it last edited?
DateTime? ExpiryTime, // Does it expire?
string[]? BannedRoles, // Only valid for role bans. List of banned roles
DateTime? UnbannedTime, // Only valid for bans. Set if unbanned
string? UnbannedByName, // Only valid for bans. Set if unbanned
bool? Seen // Only valid for messages, otherwise should be null. Has the user seen this message?
);