From c7fab5d36c6b5172d17ee6d2c85d73b6c9af5e9d Mon Sep 17 00:00:00 2001 From: RaidMax Date: Sun, 5 Sep 2021 10:43:48 -0500 Subject: [PATCH] removed commented code and show current alias for ip search --- .../Meta/ReceivedPenaltyResourceQueryHelper.cs | 9 ++++----- SharedLibraryCore/Services/ClientService.cs | 13 +++---------- 2 files changed, 7 insertions(+), 15 deletions(-) diff --git a/Application/Meta/ReceivedPenaltyResourceQueryHelper.cs b/Application/Meta/ReceivedPenaltyResourceQueryHelper.cs index 7b1494e52..ec7d58534 100644 --- a/Application/Meta/ReceivedPenaltyResourceQueryHelper.cs +++ b/Application/Meta/ReceivedPenaltyResourceQueryHelper.cs @@ -40,19 +40,19 @@ namespace IW4MAdmin.Application.Meta var linkId = await ctx.Clients.AsNoTracking() .Where(_client => _client.ClientId == query.ClientId) - .Select(_client => _client.AliasLinkId) + .Select(_client => new {_client.AliasLinkId, _client.CurrentAliasId }) .FirstOrDefaultAsync(); var iqPenalties = ctx.Penalties.AsNoTracking() .Where(_penalty => _penalty.OffenderId == query.ClientId || - linkedPenaltyType.Contains(_penalty.Type) && _penalty.LinkId == linkId); + linkedPenaltyType.Contains(_penalty.Type) && _penalty.LinkId == linkId.AliasLinkId); var iqIpLinkedPenalties = new List().AsQueryable(); if (!_appConfig.EnableImplicitAccountLinking) { var usedIps = await ctx.Aliases.AsNoTracking() - .Where(alias => alias.LinkId == linkId && alias.IPAddress != null) + .Where(alias => (alias.LinkId == linkId.AliasLinkId || alias.AliasId == linkId.CurrentAliasId) && alias.IPAddress != null) .Select(alias => alias.IPAddress).ToListAsync(); var aliasedIds = await ctx.Aliases.AsNoTracking().Where(alias => usedIps.Contains(alias.IPAddress)) @@ -61,8 +61,7 @@ namespace IW4MAdmin.Application.Meta iqIpLinkedPenalties = ctx.Penalties.AsNoTracking() .Where(penalty => - linkedPenaltyType.Contains(penalty.Type) && - /*usedIps.Contains(penalty.Offender.CurrentAlias.IPAddress)*/aliasedIds.Contains(penalty.LinkId)); + linkedPenaltyType.Contains(penalty.Type) && aliasedIds.Contains(penalty.LinkId)); } var penalties = await iqPenalties.Union(iqIpLinkedPenalties) diff --git a/SharedLibraryCore/Services/ClientService.cs b/SharedLibraryCore/Services/ClientService.cs index e784bcd51..3b225da1b 100644 --- a/SharedLibraryCore/Services/ClientService.cs +++ b/SharedLibraryCore/Services/ClientService.cs @@ -339,14 +339,6 @@ namespace SharedLibraryCore.Services if (existingExactAlias != null) { - /*if (existingExactAlias.LinkId != entity.AliasLinkId) - { - _logger.LogInformation("[{Method}] client {Client} is linked to link id {OldLinkId}, but since name and IP match exactly, updating to new link id {NewLinkId}", - nameof(UpdateAliasNew), entity.ToString(), existingExactAlias.LinkId, entity.AliasLinkId); - existingExactAlias.LinkId = entity.AliasLinkId; - await context.SaveChangesAsync(); - }*/ - entity.CurrentAlias = existingExactAlias; entity.CurrentAliasId = existingExactAlias.AliasId; await context.SaveChangesAsync(); @@ -680,7 +672,7 @@ namespace SharedLibraryCore.Services public async Task> FindClientsByIdentifier(string identifier) { var trimmedIdentifier = identifier?.Trim(); - if (trimmedIdentifier?.Length < 3) + if (trimmedIdentifier?.Length < _appConfig.MinimumNameLength) { return new List(); } @@ -718,7 +710,8 @@ namespace SharedLibraryCore.Services .Where(_client => _client.Active); - iqClients = iqClients.Where(_client => networkId == _client.NetworkId || linkIds.Contains(_client.AliasLinkId)); + iqClients = iqClients.Where(_client => networkId == _client.NetworkId || linkIds.Contains(_client.AliasLinkId) + || !_appConfig.EnableImplicitAccountLinking && _client.CurrentAlias.IPAddress == ipAddress); // we want to project our results var iqClientProjection = iqClients.OrderByDescending(_client => _client.LastConnection)