Retrofit on "mentors" (admins with no perm except +ADMINHELP) (#5626)

Co-authored-by: Leon Friedrich <60421075+ElectroJr@users.noreply.github.com>
This commit is contained in:
Moony
2021-12-14 15:17:08 -06:00
committed by GitHub
parent d7b8c0cdfd
commit d24ce4b58d
2 changed files with 17 additions and 11 deletions

View File

@@ -1,15 +1,9 @@
#nullable enable #nullable enable
using System.Linq; using System.Linq;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using Content.Server.Administration.Managers; using Content.Server.Administration.Managers;
using Content.Shared.Administration; using Content.Shared.Administration;
using JetBrains.Annotations; using JetBrains.Annotations;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.GameObjects.Components;
using Robust.Shared.Map;
using Robust.Shared.Players;
using Robust.Shared.Network;
using Robust.Shared.Localization; using Robust.Shared.Localization;
using Robust.Server.Player; using Robust.Server.Player;
using Robust.Shared.IoC; using Robust.Shared.IoC;
@@ -32,8 +26,8 @@ namespace Content.Server.Administration
// TODO: Sanitize text? // TODO: Sanitize text?
// Confirm that this person is actually allowed to send a message here. // Confirm that this person is actually allowed to send a message here.
var senderPersonalChannel = senderSession.UserId == message.ChannelId; var senderPersonalChannel = senderSession.UserId == message.ChannelId;
var senderAdmin = _adminManager.GetAdminData(senderSession) != null; var senderAdmin = _adminManager.GetAdminData(senderSession);
var authorized = senderPersonalChannel || senderAdmin; var authorized = senderPersonalChannel || senderAdmin != null;
if (!authorized) if (!authorized)
{ {
// Unauthorized bwoink (log?) // Unauthorized bwoink (log?)
@@ -42,9 +36,16 @@ namespace Content.Server.Administration
var escapedText = Basic.EscapeText(message.Text); var escapedText = Basic.EscapeText(message.Text);
var bwoinkText = senderAdmin
? $"[color=red]{senderSession.Name}[/color]: {escapedText}" var bwoinkText = senderAdmin switch
: $"{senderSession.Name}: {escapedText}"; {
var x when x is not null && x.Flags == AdminFlags.Adminhelp =>
$"[color=purple]{senderSession.Name}[/color]: {escapedText}",
var x when x is not null && x.HasFlag(AdminFlags.Adminhelp) =>
$"[color=red]{senderSession.Name}[/color]: {escapedText}",
_ => $"{senderSession.Name}: {escapedText}",
};
var msg = new BwoinkTextMessage(message.ChannelId, senderSession.UserId, bwoinkText); var msg = new BwoinkTextMessage(message.ChannelId, senderSession.UserId, bwoinkText);
LogBwoink(msg); LogBwoink(msg);

View File

@@ -75,6 +75,11 @@ namespace Content.Shared.Administration
/// </summary> /// </summary>
Query = 1 << 11, Query = 1 << 11,
/// <summary>
/// Lets you use the admin help system.
/// </summary>
Adminhelp = 1 << 12,
/// <summary> /// <summary>
/// Dangerous host permissions like scsi. /// Dangerous host permissions like scsi.
/// </summary> /// </summary>