Fix unban/editing role bans placed in groups. (#30659)

* On editing a roleban, get all the bans with the same time.

* forgoten newline

* Update to check for player ID too.
This commit is contained in:
Repo
2024-11-13 10:03:13 +13:00
committed by GitHub
parent 8b154899b5
commit ef51700094

View File

@@ -512,16 +512,23 @@ namespace Content.Server.Database
public async Task EditServerRoleBan(int id, string reason, NoteSeverity severity, DateTimeOffset? expiration, Guid editedBy, DateTimeOffset editedAt) public async Task EditServerRoleBan(int id, string reason, NoteSeverity severity, DateTimeOffset? expiration, Guid editedBy, DateTimeOffset editedAt)
{ {
await using var db = await GetDb(); await using var db = await GetDb();
var roleBanDetails = await db.DbContext.RoleBan
.Where(b => b.Id == id)
.Select(b => new { b.BanTime, b.PlayerUserId })
.SingleOrDefaultAsync();
var ban = await db.DbContext.RoleBan.SingleOrDefaultAsync(b => b.Id == id); if (roleBanDetails == default)
if (ban is null)
return; return;
ban.Severity = severity;
ban.Reason = reason; await db.DbContext.RoleBan
ban.ExpirationTime = expiration?.UtcDateTime; .Where(b => b.BanTime == roleBanDetails.BanTime && b.PlayerUserId == roleBanDetails.PlayerUserId)
ban.LastEditedById = editedBy; .ExecuteUpdateAsync(setters => setters
ban.LastEditedAt = editedAt.UtcDateTime; .SetProperty(b => b.Severity, severity)
await db.DbContext.SaveChangesAsync(); .SetProperty(b => b.Reason, reason)
.SetProperty(b => b.ExpirationTime, expiration.HasValue ? expiration.Value.UtcDateTime : (DateTime?)null)
.SetProperty(b => b.LastEditedById, editedBy)
.SetProperty(b => b.LastEditedAt, editedAt.UtcDateTime)
);
} }
#endregion #endregion