Fix role unbans not applying in real time (#20547)

This commit is contained in:
DrSmugleaf
2023-09-28 16:46:39 -07:00
committed by GitHub
parent a44fa86b68
commit f985e7dc5c
7 changed files with 78 additions and 64 deletions

View File

@@ -1,7 +1,5 @@
using System.Text;
using Content.Server.Database;
using Content.Server.Administration.Managers;
using Content.Shared.Administration;
using Robust.Server.Player;
using Robust.Shared.Console;
namespace Content.Server.Administration.Commands;
@@ -15,9 +13,6 @@ public sealed class RoleUnbanCommand : IConsoleCommand
public async void Execute(IConsoleShell shell, string argStr, string[] args)
{
var player = shell.Player as IPlayerSession;
var dbMan = IoCManager.Resolve<IServerDbManager>();
if (args.Length != 1)
{
shell.WriteLine(Help);
@@ -30,32 +25,9 @@ public sealed class RoleUnbanCommand : IConsoleCommand
return;
}
var ban = await dbMan.GetServerRoleBanAsync(banId);
if (ban == null)
{
shell.WriteLine($"No ban found with id {banId}");
return;
}
if (ban.Unban != null)
{
var response = new StringBuilder("This ban has already been pardoned");
if (ban.Unban.UnbanningAdmin != null)
{
response.Append($" by {ban.Unban.UnbanningAdmin.Value}");
}
response.Append($" in {ban.Unban.UnbanTime}.");
shell.WriteLine(response.ToString());
return;
}
await dbMan.AddServerRoleUnbanAsync(new ServerRoleUnbanDef(banId, player?.UserId, DateTimeOffset.Now));
shell.WriteLine($"Pardoned ban with id {banId}");
var banManager = IoCManager.Resolve<IBanManager>();
var response = await banManager.PardonRoleBan(banId, shell.Player?.UserId, DateTimeOffset.Now);
shell.WriteLine(response);
}
public CompletionResult GetCompletion(IConsoleShell shell, string[] args)