Skip to content

Commit

Permalink
Resolves issues in code review
Browse files Browse the repository at this point in the history
Added comment in ClientController.cs
Fixed order of operations in MuteManager.cs
Fixed condition in MuteManager.cs
  • Loading branch information
Ayymoss authored and RaidMax committed Oct 23, 2022
1 parent 34da216 commit 9778bea
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
7 changes: 4 additions & 3 deletions Plugins/Mute/MuteManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public async Task<bool> Unmute(Server server, EFClient origin, EFClient target,
if (clientMuteMeta.MuteState is MuteState.Unmuted && clientMuteMeta.CommandExecuted) return false;
if (!target.IsIngame && clientMuteMeta.MuteState is MuteState.Unmuting) return false;

if (clientMuteMeta.MuteState is not MuteState.Unmuting || origin.ClientId != 1)
if (clientMuteMeta.MuteState is not MuteState.Unmuting && origin.ClientId != 1)
{
await CreatePenalty(MuteState.Unmuted, origin, target, DateTime.UtcNow, reason);
}
Expand Down Expand Up @@ -149,8 +149,9 @@ private async Task ExpireMutePenalties(EFClient client)
await using var context = _databaseContextFactory.CreateContext();
var mutePenalties = await context.Penalties
.Where(penalty => penalty.OffenderId == client.ClientId &&
penalty.Type == EFPenalty.PenaltyType.Mute || penalty.Type == EFPenalty.PenaltyType.TempMute &&
penalty.Expires == null || penalty.Expires > DateTime.UtcNow)
(penalty.Type == EFPenalty.PenaltyType.Mute ||
penalty.Type == EFPenalty.PenaltyType.TempMute) &&
(penalty.Expires == null || penalty.Expires > DateTime.UtcNow))
.ToListAsync();

foreach (var mutePenalty in mutePenalties)
Expand Down
1 change: 1 addition & 0 deletions WebfrontCore/Controllers/Client/ClientController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ public async Task<IActionResult> Profile(int id, MetaType? metaFilterType, Cance
});
}

// Reducing the enum value for Temp/Mute so bans appear in client banner first
clientDto.ActivePenalty = activePenalties.MaxBy(penalty => penalty.Type switch
{
EFPenalty.PenaltyType.TempMute => 0,
Expand Down

0 comments on commit 9778bea

Please sign in to comment.