add device linking logs (#17555)
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using Content.Server.Administration.Logs;
|
||||||
using Content.Server.DeviceLinking.Systems;
|
using Content.Server.DeviceLinking.Systems;
|
||||||
using Content.Server.DeviceNetwork.Components;
|
using Content.Server.DeviceNetwork.Components;
|
||||||
using Content.Server.UserInterface;
|
using Content.Server.UserInterface;
|
||||||
@@ -33,6 +34,7 @@ public sealed class NetworkConfiguratorSystem : SharedNetworkConfiguratorSystem
|
|||||||
[Dependency] private readonly AudioSystem _audioSystem = default!;
|
[Dependency] private readonly AudioSystem _audioSystem = default!;
|
||||||
[Dependency] private readonly SharedAppearanceSystem _appearanceSystem = default!;
|
[Dependency] private readonly SharedAppearanceSystem _appearanceSystem = default!;
|
||||||
[Dependency] private readonly IGameTiming _gameTiming = default!;
|
[Dependency] private readonly IGameTiming _gameTiming = default!;
|
||||||
|
[Dependency] private readonly IAdminLogManager _adminLogger = default!;
|
||||||
|
|
||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
{
|
{
|
||||||
@@ -133,7 +135,10 @@ public sealed class NetworkConfiguratorSystem : SharedNetworkConfiguratorSystem
|
|||||||
_popupSystem.PopupCursor(Loc.GetString("network-configurator-device-saved", ("address", device.Address), ("device", targetUid)),
|
_popupSystem.PopupCursor(Loc.GetString("network-configurator-device-saved", ("address", device.Address), ("device", targetUid)),
|
||||||
userUid, PopupType.Medium);
|
userUid, PopupType.Medium);
|
||||||
|
|
||||||
UpdateListUiState(configurator.Owner, configurator);
|
var configuratorUid = configurator.Owner;
|
||||||
|
_adminLogger.Add(LogType.DeviceLinking, LogImpact.Low, $"{ToPrettyString(userUid):actor} saved {ToPrettyString(targetUid.Value):subject} to {ToPrettyString(configuratorUid):tool}");
|
||||||
|
|
||||||
|
UpdateListUiState(configuratorUid, configurator);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void TryLinkDevice(EntityUid uid, NetworkConfiguratorComponent configurator, EntityUid? target, EntityUid user)
|
private void TryLinkDevice(EntityUid uid, NetworkConfiguratorComponent configurator, EntityUid? target, EntityUid user)
|
||||||
@@ -521,6 +526,9 @@ public sealed class NetworkConfiguratorSystem : SharedNetworkConfiguratorSystem
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private void OnRemoveDevice(EntityUid uid, NetworkConfiguratorComponent component, NetworkConfiguratorRemoveDeviceMessage args)
|
private void OnRemoveDevice(EntityUid uid, NetworkConfiguratorComponent component, NetworkConfiguratorRemoveDeviceMessage args)
|
||||||
{
|
{
|
||||||
|
if (component.Devices.TryGetValue(args.Address, out var removedDevice) && args.Session.AttachedEntity != null)
|
||||||
|
_adminLogger.Add(LogType.DeviceLinking, LogImpact.Low,
|
||||||
|
$"{ToPrettyString(args.Session.AttachedEntity.Value):actor} removed buffered device {ToPrettyString(removedDevice):subject} from {ToPrettyString(uid):tool}");
|
||||||
component.Devices.Remove(args.Address);
|
component.Devices.Remove(args.Address);
|
||||||
UpdateListUiState(uid, component);
|
UpdateListUiState(uid, component);
|
||||||
}
|
}
|
||||||
@@ -528,8 +536,11 @@ public sealed class NetworkConfiguratorSystem : SharedNetworkConfiguratorSystem
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Clears the saved devices
|
/// Clears the saved devices
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void OnClearDevice(EntityUid uid, NetworkConfiguratorComponent component, NetworkConfiguratorClearDevicesMessage _)
|
private void OnClearDevice(EntityUid uid, NetworkConfiguratorComponent component, NetworkConfiguratorClearDevicesMessage args)
|
||||||
{
|
{
|
||||||
|
if (args.Session.AttachedEntity != null)
|
||||||
|
_adminLogger.Add(LogType.DeviceLinking, LogImpact.Low,
|
||||||
|
$"{ToPrettyString(args.Session.AttachedEntity.Value):actor} cleared buffered devices from {ToPrettyString(uid):tool}");
|
||||||
component.Devices.Clear();
|
component.Devices.Clear();
|
||||||
UpdateListUiState(uid, component);
|
UpdateListUiState(uid, component);
|
||||||
}
|
}
|
||||||
@@ -539,6 +550,10 @@ public sealed class NetworkConfiguratorSystem : SharedNetworkConfiguratorSystem
|
|||||||
if (!configurator.ActiveDeviceLink.HasValue || !configurator.DeviceLinkTarget.HasValue)
|
if (!configurator.ActiveDeviceLink.HasValue || !configurator.DeviceLinkTarget.HasValue)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (args.Session.AttachedEntity != null)
|
||||||
|
_adminLogger.Add(LogType.DeviceLinking, LogImpact.Low,
|
||||||
|
$"{ToPrettyString(args.Session.AttachedEntity.Value):actor} cleared links between {ToPrettyString(configurator.ActiveDeviceLink.Value):subject} and {ToPrettyString(configurator.DeviceLinkTarget.Value):subject2} with {ToPrettyString(uid):tool}");
|
||||||
|
|
||||||
if (HasComp<DeviceLinkSourceComponent>(configurator.ActiveDeviceLink) && HasComp<DeviceLinkSinkComponent>(configurator.DeviceLinkTarget))
|
if (HasComp<DeviceLinkSourceComponent>(configurator.ActiveDeviceLink) && HasComp<DeviceLinkSinkComponent>(configurator.DeviceLinkTarget))
|
||||||
{
|
{
|
||||||
_deviceLinkSystem.RemoveSinkFromSource(
|
_deviceLinkSystem.RemoveSinkFromSource(
|
||||||
@@ -661,15 +676,29 @@ public sealed class NetworkConfiguratorSystem : SharedNetworkConfiguratorSystem
|
|||||||
switch (args.ButtonKey)
|
switch (args.ButtonKey)
|
||||||
{
|
{
|
||||||
case NetworkConfiguratorButtonKey.Set:
|
case NetworkConfiguratorButtonKey.Set:
|
||||||
|
if (args.Session.AttachedEntity != null)
|
||||||
|
_adminLogger.Add(LogType.DeviceLinking, LogImpact.Low,
|
||||||
|
$"{ToPrettyString(args.Session.AttachedEntity.Value):actor} set device links to {ToPrettyString(component.ActiveDeviceList.Value):subject} with {ToPrettyString(uid):tool}");
|
||||||
|
|
||||||
result = _deviceListSystem.UpdateDeviceList(component.ActiveDeviceList.Value, new HashSet<EntityUid>(component.Devices.Values));
|
result = _deviceListSystem.UpdateDeviceList(component.ActiveDeviceList.Value, new HashSet<EntityUid>(component.Devices.Values));
|
||||||
break;
|
break;
|
||||||
case NetworkConfiguratorButtonKey.Add:
|
case NetworkConfiguratorButtonKey.Add:
|
||||||
|
if (args.Session.AttachedEntity != null)
|
||||||
|
_adminLogger.Add(LogType.DeviceLinking, LogImpact.Low,
|
||||||
|
$"{ToPrettyString(args.Session.AttachedEntity.Value):actor} added device links to {ToPrettyString(component.ActiveDeviceList.Value):subject} with {ToPrettyString(uid):tool}");
|
||||||
|
|
||||||
result = _deviceListSystem.UpdateDeviceList(component.ActiveDeviceList.Value, new HashSet<EntityUid>(component.Devices.Values), true);
|
result = _deviceListSystem.UpdateDeviceList(component.ActiveDeviceList.Value, new HashSet<EntityUid>(component.Devices.Values), true);
|
||||||
break;
|
break;
|
||||||
case NetworkConfiguratorButtonKey.Clear:
|
case NetworkConfiguratorButtonKey.Clear:
|
||||||
|
if (args.Session.AttachedEntity != null)
|
||||||
|
_adminLogger.Add(LogType.DeviceLinking, LogImpact.Low,
|
||||||
|
$"{ToPrettyString(args.Session.AttachedEntity.Value):actor} cleared device links from {ToPrettyString(component.ActiveDeviceList.Value):subject} with {ToPrettyString(uid):tool}");
|
||||||
result = _deviceListSystem.UpdateDeviceList(component.ActiveDeviceList.Value, new HashSet<EntityUid>());
|
result = _deviceListSystem.UpdateDeviceList(component.ActiveDeviceList.Value, new HashSet<EntityUid>());
|
||||||
break;
|
break;
|
||||||
case NetworkConfiguratorButtonKey.Copy:
|
case NetworkConfiguratorButtonKey.Copy:
|
||||||
|
if (args.Session.AttachedEntity != null)
|
||||||
|
_adminLogger.Add(LogType.DeviceLinking, LogImpact.Low,
|
||||||
|
$"{ToPrettyString(args.Session.AttachedEntity.Value):actor} copied devices from {ToPrettyString(component.ActiveDeviceList.Value):subject} to {ToPrettyString(uid):tool}");
|
||||||
component.Devices = _deviceListSystem.GetDeviceList(component.ActiveDeviceList.Value);
|
component.Devices = _deviceListSystem.GetDeviceList(component.ActiveDeviceList.Value);
|
||||||
UpdateListUiState(uid, component);
|
UpdateListUiState(uid, component);
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -87,4 +87,5 @@ public enum LogType
|
|||||||
EntityDelete = 82,
|
EntityDelete = 82,
|
||||||
Vote = 83,
|
Vote = 83,
|
||||||
ItemConfigure = 84,
|
ItemConfigure = 84,
|
||||||
|
DeviceLinking = 85,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
using Content.Shared.Administration.Logs;
|
||||||
|
using Content.Shared.Database;
|
||||||
using Content.Shared.DeviceLinking.Events;
|
using Content.Shared.DeviceLinking.Events;
|
||||||
using Content.Shared.Popups;
|
using Content.Shared.Popups;
|
||||||
using Robust.Shared.Prototypes;
|
using Robust.Shared.Prototypes;
|
||||||
@@ -9,6 +11,7 @@ public abstract class SharedDeviceLinkSystem : EntitySystem
|
|||||||
{
|
{
|
||||||
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
||||||
[Dependency] private readonly SharedPopupSystem _popupSystem = default!;
|
[Dependency] private readonly SharedPopupSystem _popupSystem = default!;
|
||||||
|
[Dependency] private readonly ISharedAdminLogManager _adminLogger = default!;
|
||||||
private ISawmill _sawmill = default!;
|
private ISawmill _sawmill = default!;
|
||||||
|
|
||||||
public const string InvokedPort = "link_port";
|
public const string InvokedPort = "link_port";
|
||||||
@@ -255,6 +258,11 @@ public abstract class SharedDeviceLinkSystem : EntitySystem
|
|||||||
if (!Resolve(sourceUid, ref sourceComponent) || !Resolve(sinkUid, ref sinkComponent))
|
if (!Resolve(sourceUid, ref sourceComponent) || !Resolve(sinkUid, ref sinkComponent))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (userId != null)
|
||||||
|
_adminLogger.Add(LogType.DeviceLinking, LogImpact.Low, $"{ToPrettyString(userId.Value):actor} is linking defaults between {ToPrettyString(sourceUid):source} and {ToPrettyString(sinkUid):sink}");
|
||||||
|
else
|
||||||
|
_adminLogger.Add(LogType.DeviceLinking, LogImpact.Low, $"linking defaults between {ToPrettyString(sourceUid):source} and {ToPrettyString(sinkUid):sink}");
|
||||||
|
|
||||||
var sourcePorts = GetSourcePorts(sourceUid, sourceComponent);
|
var sourcePorts = GetSourcePorts(sourceUid, sourceComponent);
|
||||||
var defaults = GetDefaults(sourcePorts);
|
var defaults = GetDefaults(sourcePorts);
|
||||||
SaveLinks(userId, sourceUid, sinkUid, defaults, sourceComponent, sinkComponent);
|
SaveLinks(userId, sourceUid, sinkUid, defaults, sourceComponent, sinkComponent);
|
||||||
@@ -413,6 +421,11 @@ public abstract class SharedDeviceLinkSystem : EntitySystem
|
|||||||
|
|
||||||
if (linkedPorts.Contains((source, sink)))
|
if (linkedPorts.Contains((source, sink)))
|
||||||
{
|
{
|
||||||
|
if (userId != null)
|
||||||
|
_adminLogger.Add(LogType.DeviceLinking, LogImpact.Low, $"{ToPrettyString(userId.Value):actor} unlinked {ToPrettyString(sourceUid):source} {source} and {ToPrettyString(sinkUid):sink} {sink}");
|
||||||
|
else
|
||||||
|
_adminLogger.Add(LogType.DeviceLinking, LogImpact.Low, $"unlinked {ToPrettyString(sourceUid):source} {source} and {ToPrettyString(sinkUid):sink} {sink}");
|
||||||
|
|
||||||
RaiseLocalEvent(sourceUid, new PortDisconnectedEvent(source));
|
RaiseLocalEvent(sourceUid, new PortDisconnectedEvent(source));
|
||||||
RaiseLocalEvent(sinkUid, new PortDisconnectedEvent(sink));
|
RaiseLocalEvent(sinkUid, new PortDisconnectedEvent(sink));
|
||||||
|
|
||||||
@@ -497,6 +510,11 @@ public abstract class SharedDeviceLinkSystem : EntitySystem
|
|||||||
|
|
||||||
private void SendNewLinkEvent(EntityUid? user, EntityUid sourceUid, string source, EntityUid sinkUid, string sink)
|
private void SendNewLinkEvent(EntityUid? user, EntityUid sourceUid, string source, EntityUid sinkUid, string sink)
|
||||||
{
|
{
|
||||||
|
if (user != null)
|
||||||
|
_adminLogger.Add(LogType.DeviceLinking, LogImpact.Low, $"{ToPrettyString(user.Value):actor} linked {ToPrettyString(sourceUid):source} {source} and {ToPrettyString(sinkUid):sink} {sink}");
|
||||||
|
else
|
||||||
|
_adminLogger.Add(LogType.DeviceLinking, LogImpact.Low, $"linked {ToPrettyString(sourceUid):source} {source} and {ToPrettyString(sinkUid):sink} {sink}");
|
||||||
|
|
||||||
var newLinkEvent = new NewLinkEvent(user, sourceUid, source, sinkUid, sink);
|
var newLinkEvent = new NewLinkEvent(user, sourceUid, source, sinkUid, sink);
|
||||||
RaiseLocalEvent(sourceUid, newLinkEvent);
|
RaiseLocalEvent(sourceUid, newLinkEvent);
|
||||||
RaiseLocalEvent(sinkUid, newLinkEvent);
|
RaiseLocalEvent(sinkUid, newLinkEvent);
|
||||||
|
|||||||
Reference in New Issue
Block a user