Fixes #26211 Admin messages now have separate "seen" and "dismissed" fields. The idea is that an admin should be able to tell whether a user pressed the "dismiss for now" button. Instead of using "seen" as "show this message to players when they join", "dismissed" is now used for this. Existing notes in the database will automatically be marked as dismissed on migration. A note cannot be dismissed without being seen (enforced via constraint in the database too, aren't I fancy). As part of this, it has become impossible for a player to play without dismissing the message in some form. Instead of a shitty popup window, the popup is now a fullscreen overlay that blocks clicks behind it, making the game unplayable. Also, if a user somehow has multiple messages they will be combined into one popup. Also I had enough respect for the codebase to make it look better and clean up the code somewhat. Yippee.
129 lines
3.4 KiB
C#
129 lines
3.4 KiB
C#
using System.Collections.Immutable;
|
|
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,
|
|
ImmutableArray<byte>? HWId);
|
|
|
|
public sealed record RoundRecord(int Id, DateTimeOffset StartDate, ServerRecord Server);
|
|
|
|
public sealed record ServerRecord(int Id, string Name);
|