]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Fix unban/editing role bans placed in groups. (#30659)
authorRepo <47093363+Titian3@users.noreply.github.com>
Tue, 12 Nov 2024 21:03:13 +0000 (10:03 +1300)
committerGitHub <noreply@github.com>
Tue, 12 Nov 2024 21:03:13 +0000 (22:03 +0100)
* On editing a roleban, get all the bans with the same time.

* forgoten newline

* Update to check for player ID too.

Content.Server/Database/ServerDbBase.cs

index c85b774e381037f7ef7bd03e16ff93f119fa306d..3806241e34592b8377685184fccd80b9af027f0a 100644 (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)
         {
             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 (ban is null)
+            if (roleBanDetails == default)
                 return;
-            ban.Severity = severity;
-            ban.Reason = reason;
-            ban.ExpirationTime = expiration?.UtcDateTime;
-            ban.LastEditedById = editedBy;
-            ban.LastEditedAt = editedAt.UtcDateTime;
-            await db.DbContext.SaveChangesAsync();
+
+            await db.DbContext.RoleBan
+                .Where(b => b.BanTime == roleBanDetails.BanTime && b.PlayerUserId == roleBanDetails.PlayerUserId)
+                .ExecuteUpdateAsync(setters => setters
+                    .SetProperty(b => b.Severity, severity)
+                    .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