diff --git a/SharedLibraryCore/Services/ClientService.cs b/SharedLibraryCore/Services/ClientService.cs index d65380518..f8019b721 100644 --- a/SharedLibraryCore/Services/ClientService.cs +++ b/SharedLibraryCore/Services/ClientService.cs @@ -597,51 +597,16 @@ namespace SharedLibraryCore.Services /// public virtual async Task UpdateLevel(Permission newPermission, EFClient temporalClient, EFClient origin) { - await using var ctx = _contextFactory.CreateContext(); - var entity = await ctx.Clients - .Where(_client => _client.ClientId == temporalClient.ClientId) + await using var context = _contextFactory.CreateContext(); + var entity = await context.Clients + .Where(client => client.ClientId == temporalClient.ClientId) .FirstAsync(); - var oldPermission = entity.Level; + _logger.LogInformation("Updating {ClientId} from {OldPermission} to {NewPermission} ", + temporalClient.ClientId, entity.Level, newPermission); entity.Level = newPermission; - await ctx.SaveChangesAsync(); - - using (LogContext.PushProperty("Server", temporalClient?.CurrentServer?.ToString())) - { - _logger.LogInformation("Updated {clientId} to {newPermission}", temporalClient.ClientId, newPermission); - - var linkedPermissionSet = new[] { Permission.Banned, Permission.Flagged }; - // if their permission level has been changed to level that needs to be updated on all accounts - if (linkedPermissionSet.Contains(newPermission) || linkedPermissionSet.Contains(oldPermission)) - { - //get all clients that have the same linkId - var iqMatchingClients = ctx.Clients - .Where(_client => _client.AliasLinkId == entity.AliasLinkId); - - var iqLinkClients = new List().AsQueryable(); - if (!_appConfig.EnableImplicitAccountLinking) - { - var linkIds = await ctx.Aliases.Where(alias => - alias.IPAddress != null && alias.IPAddress == temporalClient.IPAddress) - .Select(alias => alias.LinkId) - .ToListAsync(); - iqLinkClients = ctx.Clients.Where(client => linkIds.Contains(client.AliasLinkId)); - } - - // this updates the level for all the clients with the same LinkId - // only if their new level is flagged or banned - await iqMatchingClients.Union(iqLinkClients).ForEachAsync(_client => - { - _client.Level = newPermission; - _logger.LogInformation("Updated linked {clientId} to {newPermission}", _client.ClientId, - newPermission); - }); - - await ctx.SaveChangesAsync(); - } - } - + await context.SaveChangesAsync(); temporalClient.Level = newPermission; } diff --git a/WebfrontCore/Controllers/Client/ClientController.cs b/WebfrontCore/Controllers/Client/ClientController.cs index e22070a86..bcae0de52 100644 --- a/WebfrontCore/Controllers/Client/ClientController.cs +++ b/WebfrontCore/Controllers/Client/ClientController.cs @@ -53,6 +53,14 @@ namespace WebfrontCore.Controllers client.SetAdditionalProperty(EFMeta.ClientTag, tag.LinkedMeta.Value); } + // even though we haven't set their level to "banned" yet + // (ie they haven't reconnected with the infringing player identifier) + // we want to show them as banned as to not confuse people. + if (activePenalties.Any(penalty => penalty.Type == EFPenalty.PenaltyType.Ban)) + { + client.Level = Data.Models.Client.EFClient.Permission.Banned; + } + var displayLevelInt = (int)client.Level; var displayLevel = client.Level.ToLocalizedLevelName();