Better notes and bans (#14228)
Co-authored-by: Chief-Engineer <119664036+Chief-Engineer@users.noreply.github.com>
This commit is contained in:
49
Content.Server/Administration/Notes/UserNotesEui.cs
Normal file
49
Content.Server/Administration/Notes/UserNotesEui.cs
Normal file
@@ -0,0 +1,49 @@
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Content.Server.EUI;
|
||||
using Content.Shared.Administration.Notes;
|
||||
using Content.Shared.CCVar;
|
||||
using Content.Shared.Database;
|
||||
using Content.Shared.Eui;
|
||||
using Robust.Shared.Configuration;
|
||||
|
||||
namespace Content.Server.Administration.Notes;
|
||||
|
||||
public sealed class UserNotesEui : BaseEui
|
||||
{
|
||||
[Dependency] private readonly IAdminNotesManager _notesMan = default!;
|
||||
[Dependency] private readonly IConfigurationManager _cfg = default!;
|
||||
private readonly bool _seeOwnNotes;
|
||||
|
||||
public UserNotesEui()
|
||||
{
|
||||
IoCManager.InjectDependencies(this);
|
||||
_seeOwnNotes = _cfg.GetCVar(CCVars.SeeOwnNotes);
|
||||
|
||||
if (!_seeOwnNotes)
|
||||
{
|
||||
Logger.WarningS("admin.notes", "User notes initialized when see_own_notes set to false");
|
||||
}
|
||||
}
|
||||
|
||||
private Dictionary<(int, NoteType), SharedAdminNote> Notes { get; set; } = new();
|
||||
|
||||
public override EuiStateBase GetNewState()
|
||||
{
|
||||
return new UserNotesEuiState(
|
||||
Notes
|
||||
);
|
||||
}
|
||||
|
||||
public async Task UpdateNotes()
|
||||
{
|
||||
if (!_seeOwnNotes)
|
||||
{
|
||||
Logger.WarningS("admin.notes", $"User {Player.Name} with ID {Player.UserId} tried to update their own user notes when see_own_notes was set to false");
|
||||
return;
|
||||
}
|
||||
|
||||
Notes = (await _notesMan.GetVisibleRemarks(Player.UserId)).Select(note => note.ToShared()).ToDictionary(note => (note.Id, note.NoteType));
|
||||
StateDirty();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user