Add pardon command and tests (#3190)

* Add pardon command

* Make pardoning check for an existing ban and unban first

* Add pardon test and documentation
This commit is contained in:
DrSmugleaf
2021-02-13 17:51:54 +01:00
committed by GitHub
parent 1c4e3ff8d5
commit f4978d1b9e
9 changed files with 390 additions and 6 deletions

View File

@@ -15,8 +15,8 @@ using Robust.Shared.ContentPack;
using Robust.Shared.IoC;
using Robust.Shared.Log;
using Robust.Shared.Network;
using MSLogLevel = Microsoft.Extensions.Logging.LogLevel;
using LogLevel = Robust.Shared.Log.LogLevel;
using MSLogLevel = Microsoft.Extensions.Logging.LogLevel;
#nullable enable
@@ -41,9 +41,36 @@ namespace Content.Server.Database
Task<NetUserId?> GetAssignedUserIdAsync(string name);
// Ban stuff
/// <summary>
/// Looks up a ban by id.
/// This will return a pardoned ban as well.
/// </summary>
/// <param name="id">The ban id to look for.</param>
/// <returns>The ban with the given id or null if none exist.</returns>
Task<ServerBanDef?> GetServerBanAsync(int id);
/// <summary>
/// Looks up an user's most recent received un-pardoned ban.
/// This will NOT return a pardoned ban.
/// One of <see cref="address"/> or <see cref="userId"/> need to not be null.
/// </summary>
/// <param name="address">The ip address of the user.</param>
/// <param name="userId">The id of the user.</param>
/// <returns>The user's latest received un-pardoned ban, or null if none exist.</returns>
Task<ServerBanDef?> GetServerBanAsync(IPAddress? address, NetUserId? userId);
/// <summary>
/// Looks up an user's ban history.
/// This will return pardoned bans as well.
/// One of <see cref="address"/> or <see cref="userId"/> need to not be null.
/// </summary>
/// <param name="address">The ip address of the user.</param>
/// <param name="userId">The id of the user.</param>
/// <returns>The user's ban history.</returns>
Task<List<ServerBanDef>> GetServerBansAsync(IPAddress? address, NetUserId? userId);
Task AddServerBanAsync(ServerBanDef serverBan);
Task AddServerUnbanAsync(ServerUnbanDef serverBan);
// Player records
Task UpdatePlayerRecordAsync(NetUserId userId, string userName, IPAddress address);
@@ -139,6 +166,11 @@ namespace Content.Server.Database
return _db.GetAssignedUserIdAsync(name);
}
public Task<ServerBanDef?> GetServerBanAsync(int id)
{
return _db.GetServerBanAsync(id);
}
public Task<ServerBanDef?> GetServerBanAsync(IPAddress? address, NetUserId? userId)
{
return _db.GetServerBanAsync(address, userId);
@@ -154,6 +186,11 @@ namespace Content.Server.Database
return _db.AddServerBanAsync(serverBan);
}
public Task AddServerUnbanAsync(ServerUnbanDef serverUnban)
{
return _db.AddServerUnbanAsync(serverUnban);
}
public Task UpdatePlayerRecordAsync(NetUserId userId, string userName, IPAddress address)
{
return _db.UpdatePlayerRecord(userId, userName, address);