Add admin Erase verb, add checkbox to erase from the ban panel (#20985)

This commit is contained in:
DrSmugleaf
2023-10-14 02:02:56 -07:00
committed by GitHub
parent 3a2482420f
commit 5be0df32ad
22 changed files with 297 additions and 57 deletions

View File

@@ -9,7 +9,6 @@ using Content.Client.Chat.UI;
using Content.Client.Examine;
using Content.Client.Gameplay;
using Content.Client.Ghost;
using Content.Client.Lobby.UI;
using Content.Client.UserInterface.Screens;
using Content.Client.UserInterface.Systems.Chat.Widgets;
using Content.Client.UserInterface.Systems.Gameplay;
@@ -31,7 +30,6 @@ using Robust.Shared.Configuration;
using Robust.Shared.Input.Binding;
using Robust.Shared.Map;
using Robust.Shared.Network;
using Robust.Shared.Random;
using Robust.Shared.Replays;
using Robust.Shared.Timing;
using Robust.Shared.Utility;
@@ -135,7 +133,8 @@ public sealed class ChatUIController : UIController
/// </summary>
private readonly Dictionary<ChatChannel, int> _unreadMessages = new();
public readonly List<(GameTick, ChatMessage)> History = new();
// TODO add a cap for this for non-replays
public readonly List<(GameTick Tick, ChatMessage Msg)> History = new();
// Maintains which channels a client should be able to filter (for showing in the chatbox)
// and select (for attempting to send on).
@@ -166,6 +165,7 @@ public sealed class ChatUIController : UIController
_player.LocalPlayerChanged += OnLocalPlayerChanged;
_state.OnStateChanged += StateChanged;
_net.RegisterNetMessage<MsgChatMessage>(OnChatMessage);
_net.RegisterNetMessage<MsgDeleteChatMessagesBy>(OnDeleteChatMessagesBy);
SubscribeNetworkEvent<DamageForceSayEvent>(OnDamageForceSay);
_speechBubbleRoot = new LayoutContainer();
@@ -867,6 +867,16 @@ public sealed class ChatUIController : UIController
}
}
public void OnDeleteChatMessagesBy(MsgDeleteChatMessagesBy msg)
{
// This will delete messages from an entity even if different players were the author.
// Usages of the erase admin verb should be rare enough that this does not matter.
// Otherwise the client would need to know that one entity has multiple author players,
// or the server would need to track when and which entities a player sent messages as.
History.RemoveAll(h => h.Msg.SenderKey == msg.Key || msg.Entities.Contains(h.Msg.SenderEntity));
Repopulate();
}
public void RegisterChat(ChatBox chat)
{
_chats.Add(chat);