From 040ade364e7900d4f88a97c963dd39d27e7066d3 Mon Sep 17 00:00:00 2001 From: RaidMax Date: Mon, 18 Nov 2019 08:08:09 -0600 Subject: [PATCH] Fix small issue with query optimization missing a FK set Fix accidentally rename of controller method --- Application/Application.csproj | 6 ++++++ Application/ApplicationManager.cs | 8 ++++---- Application/IO/GameLogEventDetection.cs | 8 ++++---- SharedLibraryCore/PartialEntities/EFClient.cs | 6 ++---- SharedLibraryCore/Services/ClientService.cs | 1 + SharedLibraryCore/SharedLibraryCore.csproj | 5 +++++ WebfrontCore/Controllers/ClientController.cs | 2 +- 7 files changed, 23 insertions(+), 13 deletions(-) diff --git a/Application/Application.csproj b/Application/Application.csproj index 9e718b01..8f0cba87 100644 --- a/Application/Application.csproj +++ b/Application/Application.csproj @@ -42,6 +42,12 @@ + + none + full + true + + true diff --git a/Application/ApplicationManager.cs b/Application/ApplicationManager.cs index 988b1e1b..4bff1ede 100644 --- a/Application/ApplicationManager.cs +++ b/Application/ApplicationManager.cs @@ -116,26 +116,26 @@ namespace IW4MAdmin.Application // this happens if a plugin requires login catch (AuthorizationException ex) { - newEvent.FailReason = GameEvent.EventFailReason.Permission; + newEvent.FailReason = EventFailReason.Permission; newEvent.Origin.Tell($"{Utilities.CurrentLocalization.LocalizationIndex["COMMAND_NOTAUTHORIZED"]} - {ex.Message}"); } catch (NetworkException ex) { - newEvent.FailReason = GameEvent.EventFailReason.Exception; + newEvent.FailReason = EventFailReason.Exception; Logger.WriteError(ex.Message); Logger.WriteDebug(ex.GetExceptionInfo()); } catch (ServerException ex) { - newEvent.FailReason = GameEvent.EventFailReason.Exception; + newEvent.FailReason = EventFailReason.Exception; Logger.WriteWarning(ex.Message); } catch (Exception ex) { - newEvent.FailReason = GameEvent.EventFailReason.Exception; + newEvent.FailReason = EventFailReason.Exception; Logger.WriteError(Utilities.CurrentLocalization.LocalizationIndex["SERVER_ERROR_EXCEPTION"].FormatExt(newEvent.Owner)); Logger.WriteDebug(ex.GetExceptionInfo()); } diff --git a/Application/IO/GameLogEventDetection.cs b/Application/IO/GameLogEventDetection.cs index 695080e5..bf09b87c 100644 --- a/Application/IO/GameLogEventDetection.cs +++ b/Application/IO/GameLogEventDetection.cs @@ -23,7 +23,7 @@ namespace IW4MAdmin.Application.IO public GameLogEventDetection(Server server, string gameLogPath, Uri gameLogServerUri) { _gameLogFile = gameLogPath; - _reader = gameLogServerUri != null ? new GameLogReaderHttp(gameLogServerUri, gameLogPath, server.EventParser) : _reader = new GameLogReader(gameLogPath, server.EventParser); + _reader = gameLogServerUri != null ? new GameLogReaderHttp(gameLogServerUri, gameLogPath, server.EventParser) : _reader = new GameLogReader(gameLogPath, server.EventParser); _server = server; _ignoreBots = server.Manager.GetApplicationSettings().Configuration().IgnoreBots; } @@ -45,7 +45,7 @@ namespace IW4MAdmin.Application.IO _server.Logger.WriteDebug(e.GetExceptionInfo()); } } - + await Task.Delay(_reader.UpdateInterval, _server.Manager.CancellationToken); } @@ -76,11 +76,11 @@ namespace IW4MAdmin.Application.IO #if DEBUG _server.Logger.WriteVerbose(gameEvent.Data); #endif + gameEvent.Owner = _server; + // we don't want to add the event if ignoreBots is on and the event comes from a bot if (!_ignoreBots || (_ignoreBots && !((gameEvent.Origin?.IsBot ?? false) || (gameEvent.Target?.IsBot ?? false)))) { - gameEvent.Owner = _server; - if ((gameEvent.RequiredEntity & GameEvent.EventRequiredEntity.Origin) == GameEvent.EventRequiredEntity.Origin && gameEvent.Origin.NetworkId != 1) { gameEvent.Origin = _server.GetClientsAsList().First(_client => _client.NetworkId == gameEvent.Origin?.NetworkId); diff --git a/SharedLibraryCore/PartialEntities/EFClient.cs b/SharedLibraryCore/PartialEntities/EFClient.cs index 587b7eb7..6c1d1457 100644 --- a/SharedLibraryCore/PartialEntities/EFClient.cs +++ b/SharedLibraryCore/PartialEntities/EFClient.cs @@ -103,7 +103,7 @@ namespace SharedLibraryCore.Database.Models } [NotMapped] - public string CleanedName => Name.StripColors(); + public string CleanedName => Name?.StripColors(); [NotMapped] public virtual int? IPAddress @@ -463,8 +463,7 @@ namespace SharedLibraryCore.Database.Models { var loc = Utilities.CurrentLocalization.LocalizationIndex; - string strippedName = Name.StripColors(); - if (string.IsNullOrWhiteSpace(Name) || strippedName.Replace(" ", "").Length < 3) + if (string.IsNullOrWhiteSpace(Name) || CleanedName.Replace(" ", "").Length < 3) { CurrentServer.Logger.WriteDebug($"Kicking {this} because their name is too short"); Kick(loc["SERVER_KICK_MINNAME"], Utilities.IW4MAdminClient(CurrentServer)); @@ -575,7 +574,6 @@ namespace SharedLibraryCore.Database.Models // we want to get any penalties that are tied to their IP or AliasLink (but not necessarily their GUID) var activePenalties = await CurrentServer.Manager.GetPenaltyService().GetActivePenaltiesAsync(AliasLinkId, ipAddress); - var banPenalty = activePenalties.FirstOrDefault(_penalty => _penalty.Type == EFPenalty.PenaltyType.Ban); var tempbanPenalty = activePenalties.FirstOrDefault(_penalty => _penalty.Type == EFPenalty.PenaltyType.TempBan); var flagPenalty = activePenalties.FirstOrDefault(_penalty => _penalty.Type == EFPenalty.PenaltyType.Flag); diff --git a/SharedLibraryCore/Services/ClientService.cs b/SharedLibraryCore/Services/ClientService.cs index 40e33666..f62ebbdd 100644 --- a/SharedLibraryCore/Services/ClientService.cs +++ b/SharedLibraryCore/Services/ClientService.cs @@ -340,6 +340,7 @@ namespace SharedLibraryCore.Services client.AliasLink = new EFAliasLink() { + AliasLinkId = client.AliasLinkId, Children = await context.Aliases .Where(_alias => _alias.LinkId == client.AliasLinkId) .Select(_alias => new EFAlias() diff --git a/SharedLibraryCore/SharedLibraryCore.csproj b/SharedLibraryCore/SharedLibraryCore.csproj index ffbd2334..ded7da95 100644 --- a/SharedLibraryCore/SharedLibraryCore.csproj +++ b/SharedLibraryCore/SharedLibraryCore.csproj @@ -21,6 +21,11 @@ MIT + + full + true + + diff --git a/WebfrontCore/Controllers/ClientController.cs b/WebfrontCore/Controllers/ClientController.cs index 492f4d46..f580acc0 100644 --- a/WebfrontCore/Controllers/ClientController.cs +++ b/WebfrontCore/Controllers/ClientController.cs @@ -152,7 +152,7 @@ namespace WebfrontCore.Controllers return View("Find/Index", clientsDto); } - public async Task GetMeta(int id, int count, int offset, DateTime? startAt) + public async Task Meta(int id, int count, int offset, DateTime? startAt) { IEnumerable meta = await MetaService.GetRuntimeMeta(id, startAt == null ? offset : 0, count, startAt ?? DateTime.UtcNow);