diff --git a/Content.Server/Administration/Managers/BanManager.cs b/Content.Server/Administration/Managers/BanManager.cs index c65059f55d..2d76c434e9 100644 --- a/Content.Server/Administration/Managers/BanManager.cs +++ b/Content.Server/Administration/Managers/BanManager.cs @@ -165,6 +165,8 @@ public sealed partial class BanManager : IBanManager, IPostInjectInit null); await _db.AddServerBanAsync(banDef); + if (_cfg.GetCVar(CCVars.ServerBanResetLastReadRules) && target != null) + await _db.SetLastReadRules(target.Value, null); // Reset their last read rules. They probably need a refresher! var adminName = banningAdmin == null ? Loc.GetString("system-user") : (await _db.GetPlayerRecordByUserId(banningAdmin.Value))?.LastSeenUserName ?? Loc.GetString("system-user"); diff --git a/Content.Server/Database/ServerDbBase.cs b/Content.Server/Database/ServerDbBase.cs index b75870ac0e..ccbaf276cd 100644 --- a/Content.Server/Database/ServerDbBase.cs +++ b/Content.Server/Database/ServerDbBase.cs @@ -1112,7 +1112,7 @@ INSERT INTO player_round (players_id, rounds_id) VALUES ({players[player]}, {id} .SingleOrDefaultAsync()); } - public async Task SetLastReadRules(NetUserId player, DateTimeOffset date) + public async Task SetLastReadRules(NetUserId player, DateTimeOffset? date) { await using var db = await GetDb(); @@ -1122,7 +1122,7 @@ INSERT INTO player_round (players_id, rounds_id) VALUES ({players[player]}, {id} return; } - dbPlayer.LastReadRules = date.UtcDateTime; + dbPlayer.LastReadRules = date?.UtcDateTime; await db.DbContext.SaveChangesAsync(); } diff --git a/Content.Server/Database/ServerDbManager.cs b/Content.Server/Database/ServerDbManager.cs index 5ddb3a590c..e3cfb66c7f 100644 --- a/Content.Server/Database/ServerDbManager.cs +++ b/Content.Server/Database/ServerDbManager.cs @@ -282,7 +282,7 @@ namespace Content.Server.Database #region Rules Task GetLastReadRules(NetUserId player); - Task SetLastReadRules(NetUserId player, DateTimeOffset time); + Task SetLastReadRules(NetUserId player, DateTimeOffset? time); #endregion @@ -830,7 +830,7 @@ namespace Content.Server.Database return RunDbCommand(() => _db.GetLastReadRules(player)); } - public Task SetLastReadRules(NetUserId player, DateTimeOffset time) + public Task SetLastReadRules(NetUserId player, DateTimeOffset? time) { DbWriteOpsMetric.Inc(); return RunDbCommand(() => _db.SetLastReadRules(player, time)); diff --git a/Content.Server/Info/RulesManager.cs b/Content.Server/Info/RulesManager.cs index f4d9e57bd4..224d7f7d9a 100644 --- a/Content.Server/Info/RulesManager.cs +++ b/Content.Server/Info/RulesManager.cs @@ -34,7 +34,7 @@ public sealed class RulesManager { PopupTime = _cfg.GetCVar(CCVars.RulesWaitTime), CoreRules = _cfg.GetCVar(CCVars.RulesFile), - ShouldShowRules = !isLocalhost && !hasCooldown + ShouldShowRules = !isLocalhost && !hasCooldown, }; _netManager.ServerSendMessage(showRulesMessage, e.Channel); } diff --git a/Content.Shared/CCVar/CCVars.Admin.cs b/Content.Shared/CCVar/CCVars.Admin.cs index bbce533ed1..f05eb3376e 100644 --- a/Content.Shared/CCVar/CCVars.Admin.cs +++ b/Content.Shared/CCVar/CCVars.Admin.cs @@ -89,6 +89,12 @@ public sealed partial class CCVars public static readonly CVarDef ServerBanErasePlayer = CVarDef.Create("admin.server_ban_erase_player", false, CVar.ARCHIVE | CVar.SERVER | CVar.REPLICATED); + /// + /// If true, will reset the last time the player has read the rules. This will mean on their next login they will be shown the rules again. + /// + public static readonly CVarDef ServerBanResetLastReadRules = + CVarDef.Create("admin.server_ban_reset_last_read_rules", true, CVar.ARCHIVE | CVar.SERVER); + /// /// Minimum players sharing a connection required to create an alert. -1 to disable the alert. ///