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
This commit is contained in:
Amos 2023-05-28 17:37:27 +01:00 committed by GitHub
parent 108dddb5cc
commit cdf9485903
2 changed files with 4 additions and 2 deletions

View File

@ -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

View File

@ -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;