[Feat] Socket unjobban command (#78)
* Socket unjobban command * fix for CPR system
This commit is contained in:
@@ -235,10 +235,9 @@ namespace Content.Server.Body.Systems
|
|||||||
// WD start
|
// WD start
|
||||||
private void OnHandInteract(EntityUid uid, RespiratorComponent component, InteractHandEvent args)
|
private void OnHandInteract(EntityUid uid, RespiratorComponent component, InteractHandEvent args)
|
||||||
{
|
{
|
||||||
if (!CanCPR(uid, component, args.User))
|
if (CanCPR(uid, component, args.User))
|
||||||
return;
|
|
||||||
|
|
||||||
DoCPR(uid, component, args.User);
|
DoCPR(uid, component, args.User);
|
||||||
|
|
||||||
args.Handled = true;
|
args.Handled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,57 @@
|
|||||||
|
using Content.Server.Administration;
|
||||||
|
using Content.Server.Database;
|
||||||
|
|
||||||
|
namespace Content.Server.UtkaIntegration;
|
||||||
|
|
||||||
|
public sealed class UtkaUnJobBanCommand : IUtkaCommand
|
||||||
|
{
|
||||||
|
[Dependency] private UtkaTCPWrapper _utkaSocketWrapper = default!;
|
||||||
|
|
||||||
|
public string Name => "unjobban";
|
||||||
|
public Type RequestMessageType => typeof(UtkaUnJobBanRequest);
|
||||||
|
public async void Execute(UtkaTCPSession session, UtkaBaseMessage baseMessage)
|
||||||
|
{
|
||||||
|
if (baseMessage is not UtkaUnJobBanRequest message) return;
|
||||||
|
|
||||||
|
var dbMan = IoCManager.Resolve<IServerDbManager>();
|
||||||
|
var locator = IoCManager.Resolve<IPlayerLocator>();
|
||||||
|
IoCManager.InjectDependencies(this);
|
||||||
|
|
||||||
|
var located = await locator.LookupIdByNameOrIdAsync(message.ACkey!);
|
||||||
|
if (located == null)
|
||||||
|
{
|
||||||
|
UtkaSendResponse(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var player = located.UserId;
|
||||||
|
|
||||||
|
var ban = await dbMan.GetServerRoleBanAsync(message.Bid!.Value);
|
||||||
|
if (ban == null || ban.Unban != null)
|
||||||
|
{
|
||||||
|
UtkaSendResponse(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var adminData = await dbMan.GetAdminDataForAsync(player);
|
||||||
|
if (adminData?.AdminRank == null || ban.ServerName != "unknown" && adminData.AdminServer is not (null or "unknown") && adminData.AdminServer != ban.ServerName)
|
||||||
|
{
|
||||||
|
UtkaSendResponse(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
await dbMan.AddServerRoleUnbanAsync(new ServerRoleUnbanDef(message.Bid!.Value, player, DateTimeOffset.Now));
|
||||||
|
|
||||||
|
UtkaSendResponse(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void UtkaSendResponse(bool unbanned)
|
||||||
|
{
|
||||||
|
var utkaResponse = new UtkaUnJobBanResponse()
|
||||||
|
{
|
||||||
|
Unbanned = unbanned
|
||||||
|
};
|
||||||
|
|
||||||
|
_utkaSocketWrapper.SendMessageToAll(utkaResponse);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -316,3 +316,24 @@ public sealed class UtkaUnbanResponse : UtkaBaseMessage
|
|||||||
[JsonPropertyName("unbanned")]
|
[JsonPropertyName("unbanned")]
|
||||||
public bool? Unbanned { get; set; }
|
public bool? Unbanned { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public sealed class UtkaUnJobBanRequest : UtkaBaseMessage
|
||||||
|
{
|
||||||
|
[JsonPropertyName("command")]
|
||||||
|
public override string? Command => "unjobban";
|
||||||
|
|
||||||
|
[JsonPropertyName("a_ckey")]
|
||||||
|
public string? ACkey { get; set; }
|
||||||
|
|
||||||
|
[JsonPropertyName("bid")]
|
||||||
|
public int? Bid { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public sealed class UtkaUnJobBanResponse : UtkaBaseMessage
|
||||||
|
{
|
||||||
|
[JsonPropertyName("command")]
|
||||||
|
public override string? Command => "unjobban";
|
||||||
|
|
||||||
|
[JsonPropertyName("unbanned")]
|
||||||
|
public bool? Unbanned { get; set; }
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user