From 7f4eb230be12d34c3541096987d58877b9ad0b1c Mon Sep 17 00:00:00 2001 From: Amos Date: Sun, 28 May 2023 17:37:27 +0100 Subject: [PATCH] Resolves issue where muted player would be unmuted when flag penalty was removed (#303) * resolves issue where muted player would be unmuted when flag penalty was removed * Revert accidental code format --- Application/IW4MServer.cs | 2 +- SharedLibraryCore/Services/PenaltyService.cs | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Application/IW4MServer.cs b/Application/IW4MServer.cs index 4de860d4a..7c9b79dd3 100644 --- a/Application/IW4MServer.cs +++ b/Application/IW4MServer.cs @@ -540,7 +540,7 @@ namespace IW4MAdmin E.Target.SetLevel(Permission.User, E.Origin); await Manager.GetPenaltyService().RemoveActivePenalties(E.Target.AliasLinkId, E.Target.NetworkId, - E.Target.GameName, E.Target.CurrentAlias?.IPAddress); + E.Target.GameName, E.Target.CurrentAlias?.IPAddress, new[] {EFPenalty.PenaltyType.Flag}); await Manager.GetPenaltyService().Create(unflagPenalty); Manager.QueueEvent(new ClientPenaltyRevokeEvent diff --git a/SharedLibraryCore/Services/PenaltyService.cs b/SharedLibraryCore/Services/PenaltyService.cs index a226fb784..aaef0708e 100644 --- a/SharedLibraryCore/Services/PenaltyService.cs +++ b/SharedLibraryCore/Services/PenaltyService.cs @@ -215,7 +215,8 @@ namespace SharedLibraryCore.Services return await activePenaltiesIds.Select(ids => ids.Penalty).ToListAsync(); } - public virtual async Task RemoveActivePenalties(int aliasLinkId, long networkId, Reference.Game game, int? ipAddress = null) + public virtual async Task RemoveActivePenalties(int aliasLinkId, long networkId, Reference.Game game, int? ipAddress = null, + EFPenalty.PenaltyType[] penaltyTypes = null) { await using var context = _contextFactory.CreateContext(); var now = DateTime.UtcNow; @@ -226,6 +227,7 @@ namespace SharedLibraryCore.Services { var ids = activePenalties.Select(penalty => penalty.PenaltyId); await context.Penalties.Where(penalty => ids.Contains(penalty.PenaltyId)) + .Where(pen => penaltyTypes == null || penaltyTypes.Contains(pen.Type)) .ForEachAsync(penalty => { penalty.Active = false;