From 8f52714fb796ddb2d9f06bbef1261d20c63f6035 Mon Sep 17 00:00:00 2001 From: RaidMax Date: Wed, 20 Oct 2021 11:16:35 -0500 Subject: [PATCH] fix issue with detecting bans on accounts with new ips when implicit linking is disabled --- SharedLibraryCore/Services/PenaltyService.cs | 26 +++++++++++++++----- WebfrontCore/WebfrontCore.csproj | 6 +---- 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/SharedLibraryCore/Services/PenaltyService.cs b/SharedLibraryCore/Services/PenaltyService.cs index cd7eeaefd..f392ccc1a 100644 --- a/SharedLibraryCore/Services/PenaltyService.cs +++ b/SharedLibraryCore/Services/PenaltyService.cs @@ -162,15 +162,29 @@ namespace SharedLibraryCore.Services .Where(p => p.LinkId == linkId) .Where(filter); - var iqIpPenalties = _appConfig.EnableImplicitAccountLinking - ? context.Aliases + IQueryable iqIpPenalties; + + if (_appConfig.EnableImplicitAccountLinking) + { + iqIpPenalties = context.Aliases .Where(a => a.IPAddress != null && a.IPAddress == ip) .SelectMany(a => a.Link.ReceivedPenalties) - .Where(filter) - : context.Penalties.Where(penalty => - penalty.Offender.CurrentAlias.IPAddress != null && - penalty.Offender.CurrentAlias.IPAddress == ip) .Where(filter); + } + else + { + var aliasIps = await context.Aliases.Where(alias => alias.LinkId == linkId && alias.IPAddress != null) + .Select(alias => alias.IPAddress) + .ToListAsync(); + if (ip != null) + { + aliasIps.Add(ip); + } + + iqIpPenalties = context.Penalties + .Where(penalty => aliasIps.Contains(penalty.Offender.CurrentAlias.IPAddress)) + .Where(filter); + } var activePenalties = (await iqLinkPenalties.ToListAsync()) .Union(await iqIpPenalties.ToListAsync()) diff --git a/WebfrontCore/WebfrontCore.csproj b/WebfrontCore/WebfrontCore.csproj index f58dc4d16..3d55f87a3 100644 --- a/WebfrontCore/WebfrontCore.csproj +++ b/WebfrontCore/WebfrontCore.csproj @@ -78,10 +78,6 @@ - - - - @@ -96,7 +92,7 @@ - +