Chatfactor: Chat Repository, Admin Commands, Chat Created Events (#26113)
* 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>
This commit is contained in:
committed by
GitHub
parent
126f64a914
commit
b1136c98d7
60
Content.Shared/Chat/V2/Repository/Types.cs
Normal file
60
Content.Shared/Chat/V2/Repository/Types.cs
Normal file
@@ -0,0 +1,60 @@
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using Robust.Shared.Network;
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Shared.Chat.V2.Repository;
|
||||
|
||||
/// <summary>
|
||||
/// The record associated with a specific chat event.
|
||||
/// </summary>
|
||||
public struct ChatRecord(string userName, NetUserId userId, IChatEvent storedEvent, string entityName)
|
||||
{
|
||||
public string UserName = userName;
|
||||
public NetUserId UserId = userId;
|
||||
public string EntityName = entityName;
|
||||
public IChatEvent StoredEvent = storedEvent;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Notifies that a chat message has been created.
|
||||
/// </summary>
|
||||
/// <param name="ev"></param>
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class MessageCreatedEvent(IChatEvent ev) : EntityEventArgs
|
||||
{
|
||||
public IChatEvent Event = ev;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Notifies that a chat message has been changed.
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="newMessage"></param>
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class MessagePatchedEvent(uint id, string newMessage) : EntityEventArgs
|
||||
{
|
||||
public uint MessageId = id;
|
||||
public string NewMessage = newMessage;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Notifies that a chat message has been deleted.
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class MessageDeletedEvent(uint id) : EntityEventArgs
|
||||
{
|
||||
public uint MessageId = id;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Notifies that a player's messages have been nuked.
|
||||
/// </summary>
|
||||
/// <param name="set"></param>
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class MessagesNukedEvent(List<uint> set) : EntityEventArgs
|
||||
{
|
||||
public uint[] MessageIds = CollectionsMarshal.AsSpan(set).ToArray();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user