* Chatfactor: Chat Repository, Admin Commands, Chat Created Events This addition-only PR covers a repository that stores chat messages. This PR defines what chat messages can be stored, what can be done with those stored messages, and what events occur when the repository does things. This PR also includes to admin commands that show how the repository will be used for administration purposes at first. Because all chat messages will be uniquely identified per round (and, as rounds are uniquely identified, are essentially a GUID) we can delete, amend or nuke messages. Note there's no "amend" command right now. The original chatfactor PR didn't include one, and I'm avoiding further feature bloat with these chatfactor PRs... * Remove an event that shouldn't be in this PR * Resolve PR comments. * Resolve peak goober moment * Also make sure we tell the user why if their delete command fails * Supply a reason if the nukeuserids command is malformed * Tidy messages * Some more docstring tidyup * Imagine tests handling IOC correctly chat * Imagine tests handling IOC correctly chat * Resolve PR comments * Fix goobering with needing to use ToolshedCommand * In which we bikeshed toolshed * loud metal pipe sound effect * One must imagine funny boulder pushing man happy * Move commands to new folder * Mald, seethe, cope. * I hate toolshed I hate toolshed I hate toolshed * Fix command ftls * Bit of tidy-up and a YAGNI removal of a get we don't need yet * Whelp lmao * UserIDs are in a weird fucky state I didn't anticipate, so I've removed the remove-by-userID command for the time being. * Rename ChatRepository to ChatRepositorySystem. * Resolve PR review comments --------- Co-authored-by: Your Name <you@example.com>
37 lines
1.1 KiB
C#
37 lines
1.1 KiB
C#
using System.Diagnostics;
|
|
using Content.Server.Administration;
|
|
using Content.Server.Chat.V2.Repository;
|
|
using Content.Shared.Administration;
|
|
using Robust.Shared.Toolshed;
|
|
using Robust.Shared.Toolshed.Errors;
|
|
using Robust.Shared.Utility;
|
|
|
|
namespace Content.Server.Chat.V2.Commands;
|
|
|
|
[ToolshedCommand, AdminCommand(AdminFlags.Admin)]
|
|
public sealed class DeleteChatMessageCommand : ToolshedCommand
|
|
{
|
|
[Dependency] private readonly IEntitySystemManager _manager = default!;
|
|
|
|
[CommandImplementation("id")]
|
|
public void DeleteChatMessage([CommandInvocationContext] IInvocationContext ctx, [CommandArgument] uint messageId)
|
|
{
|
|
if (!_manager.GetEntitySystem<ChatRepositorySystem>().Delete(messageId))
|
|
{
|
|
ctx.ReportError(new MessageIdDoesNotExist());
|
|
}
|
|
}
|
|
}
|
|
|
|
public record struct MessageIdDoesNotExist() : IConError
|
|
{
|
|
public FormattedMessage DescribeInner()
|
|
{
|
|
return FormattedMessage.FromUnformatted(Loc.GetString("command-error-deletechatmessage-id-notexist"));
|
|
}
|
|
|
|
public string? Expression { get; set; }
|
|
public Vector2i? IssueSpan { get; set; }
|
|
public StackTrace? Trace { get; set; }
|
|
}
|