From 38a42a38a06afefb76341c8087bc9e09531fa0e9 Mon Sep 17 00:00:00 2001 From: Xenne <144433308+Xenne93@users.noreply.github.com> Date: Mon, 17 Aug 2026 12:30:01 +0200 Subject: [PATCH] Fix missing Discord notification for the first player to join after a reconnect The suppress-player-events flag (set on every RCON (re)connect to avoid notifying for players already on the server) was only ever cleared inside the branch of ParsePlayerList that processes a non-empty player list. If the very first playerlist poll after a reconnect found nobody online yet - the common case right after a server restart, since players take time to reconnect - the method returned early before reaching that code, leaving the flag stuck true. Whoever joined live before the next poll (which finally saw players and cleared the flag) had their connect webhook silently and permanently skipped, even though their eventual disconnect fired normally. Moved the flag-clearing logic to run right after every successful poll, regardless of whether the returned list is empty. --- .../RconBackgroundService.Receiving.cs | 22 ++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/RustRconServerManager.Backend/Services/RconBackgroundService.Receiving.cs b/RustRconServerManager.Backend/Services/RconBackgroundService.Receiving.cs index 93d2f30..dd26a61 100644 --- a/RustRconServerManager.Backend/Services/RconBackgroundService.Receiving.cs +++ b/RustRconServerManager.Backend/Services/RconBackgroundService.Receiving.cs @@ -382,6 +382,20 @@ await db.RconServers.Where(r => r.Id == serverId) .ExecuteUpdateAsync(s => s .SetProperty(r => r.LatestPlayerCount, _ => playerList.Count)); + // Clear the suppress flag as soon as the first playerlist poll after a (re)connect + // completes - do this regardless of whether the list is empty, since an empty list + // (nobody online yet right after a reconnect) is still a completed sync. This used to + // be gated behind the non-empty check below, which meant that whenever nobody happened + // to be online yet at the very first poll (the common case right after a server + // restart), the flag stayed stuck "true" until a later poll found someone already + // online - silently and permanently dropping the Discord notification for whoever + // was actually the first player to join live in the meantime. + if (_suppressPlayerEvents.TryGetValue(serverId, out var suppressed) && suppressed) + { + _suppressPlayerEvents[serverId] = false; + _logger.LogInformation("[SERVER {ServerId}] Initial player sync complete - notifications enabled", serverId); + } + // If the list is empty (error or no players online, return if (playerList == null || playerList.Count == 0) return; @@ -479,14 +493,6 @@ await db.RconServers.Where(r => r.Id == serverId) } await db.SaveChangesAsync(); - - // Clear the suppress flag after the first playerlist sync completes - // From this point on, player join/leave events will trigger notifications normally - if (_suppressPlayerEvents.TryGetValue(serverId, out var suppressed) && suppressed) - { - _suppressPlayerEvents[serverId] = false; - _logger.LogInformation("[SERVER {ServerId}] Initial player sync complete - notifications enabled", serverId); - } } catch (Exception ex) {