Files
tbd-station-14/Content.Server/Database/DatabaseRecords.cs
Pieter-Jan Briers 4f3db43696 Integrate Modern HWID into content
This should be the primary changes for the future-proof "Modern HWID" system implemented into Robust and the auth server.

HWIDs in the database have been given an additional column representing their version, legacy or modern. This is implemented via an EF Core owned entity. By manually setting the column name of the main value column, we can keep DB compatibility and the migration is just adding some type columns.

This new HWID type has to be plumbed through everywhere, resulting in some breaking changes for the DB layer and such.

New bans and player records are placed with the new modern HWID. Old bans are still checked against legacy HWIDs.

Modern HWIDs are presented with a "V2-" prefix to admins, to allow distinguishing them. This is also integrated into the parsing logic for placing new bans.

There's also some code cleanup to reduce copy pasting around the place from my changes.

Requires latest engine to support ImmutableArray<byte> in NetSerializer.
2024-11-12 01:51:54 +01:00

128 lines
3.3 KiB
C#

using System.Net;
using Content.Shared.Database;
using Robust.Shared.Network;
namespace Content.Server.Database;
// This file contains copies of records returned from the database.
// We can't return the raw EF Core entities as they are often unsuited.
// (e.g. datetime handling of Microsoft.Data.Sqlite)
public interface IAdminRemarksRecord
{
public int Id { get; }
public RoundRecord? Round { get; }
public PlayerRecord? Player { get; }
public TimeSpan PlaytimeAtNote { get; }
public string Message { get; }
public PlayerRecord? CreatedBy { get; }
public DateTimeOffset CreatedAt { get; }
public PlayerRecord? LastEditedBy { get; }
public DateTimeOffset? LastEditedAt { get; }
public DateTimeOffset? ExpirationTime { get; }
public bool Deleted { get; }
}
public sealed record ServerRoleBanNoteRecord(
int Id,
RoundRecord? Round,
PlayerRecord? Player,
TimeSpan PlaytimeAtNote,
string Message,
NoteSeverity Severity,
PlayerRecord? CreatedBy,
DateTimeOffset CreatedAt,
PlayerRecord? LastEditedBy,
DateTimeOffset? LastEditedAt,
DateTimeOffset? ExpirationTime,
bool Deleted,
string[] Roles,
PlayerRecord? UnbanningAdmin,
DateTime? UnbanTime) : IAdminRemarksRecord;
public sealed record ServerBanNoteRecord(
int Id,
RoundRecord? Round,
PlayerRecord? Player,
TimeSpan PlaytimeAtNote,
string Message,
NoteSeverity Severity,
PlayerRecord? CreatedBy,
DateTimeOffset CreatedAt,
PlayerRecord? LastEditedBy,
DateTimeOffset? LastEditedAt,
DateTimeOffset? ExpirationTime,
bool Deleted,
PlayerRecord? UnbanningAdmin,
DateTime? UnbanTime) : IAdminRemarksRecord;
public sealed record AdminNoteRecord(
int Id,
RoundRecord? Round,
PlayerRecord? Player,
TimeSpan PlaytimeAtNote,
string Message,
NoteSeverity Severity,
PlayerRecord? CreatedBy,
DateTimeOffset CreatedAt,
PlayerRecord? LastEditedBy,
DateTimeOffset? LastEditedAt,
DateTimeOffset? ExpirationTime,
bool Deleted,
PlayerRecord? DeletedBy,
DateTimeOffset? DeletedAt,
bool Secret) : IAdminRemarksRecord;
public sealed record AdminWatchlistRecord(
int Id,
RoundRecord? Round,
PlayerRecord? Player,
TimeSpan PlaytimeAtNote,
string Message,
PlayerRecord? CreatedBy,
DateTimeOffset CreatedAt,
PlayerRecord? LastEditedBy,
DateTimeOffset? LastEditedAt,
DateTimeOffset? ExpirationTime,
bool Deleted,
PlayerRecord? DeletedBy,
DateTimeOffset? DeletedAt) : IAdminRemarksRecord;
public sealed record AdminMessageRecord(
int Id,
RoundRecord? Round,
PlayerRecord? Player,
TimeSpan PlaytimeAtNote,
string Message,
PlayerRecord? CreatedBy,
DateTimeOffset CreatedAt,
PlayerRecord? LastEditedBy,
DateTimeOffset? LastEditedAt,
DateTimeOffset? ExpirationTime,
bool Deleted,
PlayerRecord? DeletedBy,
DateTimeOffset? DeletedAt,
bool Seen,
bool Dismissed) : IAdminRemarksRecord;
public sealed record PlayerRecord(
NetUserId UserId,
DateTimeOffset FirstSeenTime,
string LastSeenUserName,
DateTimeOffset LastSeenTime,
IPAddress LastSeenAddress,
ImmutableTypedHwid? HWId);
public sealed record RoundRecord(int Id, DateTimeOffset? StartDate, ServerRecord Server);
public sealed record ServerRecord(int Id, string Name);