Files
tbd-station-14/Content.Server/Administration/Managers/IBanManager.cs
Pieter-Jan Briers 4a5178a538 Fix role ban loading bugs (#32725)
This code was a mess. Now it's less of a mess and user UserDbDataManager now.

Fixes the following bugs:

* If you connect to a server, restart your client, connect again in the same round, you role bans would not be visible in the client.
* If you role ban somebody who is not connected to the server, then they connect within the round, they will only have the recently-applied ban.

Likely fixes #24781, #27282
2024-10-14 14:30:31 +11:00

56 lines
2.8 KiB
C#

using System.Collections.Immutable;
using System.Net;
using System.Threading.Tasks;
using Content.Shared.Database;
using Content.Shared.Roles;
using Robust.Shared.Network;
using Robust.Shared.Player;
using Robust.Shared.Prototypes;
namespace Content.Server.Administration.Managers;
public interface IBanManager
{
public void Initialize();
public void Restart();
/// <summary>
/// Bans the specified target, address range and / or HWID. One of them must be non-null
/// </summary>
/// <param name="target">Target user, username or GUID, null for none</param>
/// <param name="banningAdmin">The person who banned our target</param>
/// <param name="addressRange">Address range, null for none</param>
/// <param name="hwid">H</param>
/// <param name="minutes">Number of minutes to ban for. 0 and null mean permanent</param>
/// <param name="severity">Severity of the resulting ban note</param>
/// <param name="reason">Reason for the ban</param>
public void CreateServerBan(NetUserId? target, string? targetUsername, NetUserId? banningAdmin, (IPAddress, int)? addressRange, ImmutableArray<byte>? hwid, uint? minutes, NoteSeverity severity, string reason);
public HashSet<string>? GetRoleBans(NetUserId playerUserId);
public HashSet<ProtoId<JobPrototype>>? GetJobBans(NetUserId playerUserId);
/// <summary>
/// Creates a job ban for the specified target, username or GUID
/// </summary>
/// <param name="target">Target user, username or GUID, null for none</param>
/// <param name="role">Role to be banned from</param>
/// <param name="severity">Severity of the resulting ban note</param>
/// <param name="reason">Reason for the ban</param>
/// <param name="minutes">Number of minutes to ban for. 0 and null mean permanent</param>
/// <param name="timeOfBan">Time when the ban was applied, used for grouping role bans</param>
public void CreateRoleBan(NetUserId? target, string? targetUsername, NetUserId? banningAdmin, (IPAddress, int)? addressRange, ImmutableArray<byte>? hwid, string role, uint? minutes, NoteSeverity severity, string reason, DateTimeOffset timeOfBan);
/// <summary>
/// Pardons a role ban for the specified target, username or GUID
/// </summary>
/// <param name="banId">The id of the role ban to pardon.</param>
/// <param name="unbanningAdmin">The admin, if any, that pardoned the role ban.</param>
/// <param name="unbanTime">The time at which this role ban was pardoned.</param>
public Task<string> PardonRoleBan(int banId, NetUserId? unbanningAdmin, DateTimeOffset unbanTime);
/// <summary>
/// Sends role bans to the target
/// </summary>
/// <param name="pSession">Player's session</param>
public void SendRoleBans(ICommonSession pSession);
}