From dafe1826250a4f9ac63a1a48967aa0c050fc1c1d Mon Sep 17 00:00:00 2001 From: Vitalii Mikhailov Date: Thu, 9 Nov 2023 22:39:26 +0200 Subject: [PATCH] Huge ass refactor Tighter integration with Vogen, to be replaced tho Switched client to .NET 8 Unified API response Refactored Quartz integration Fixed DynamicExpressions Added Crash Report Analyzer --- .../BUTR.Site.NexusMods.Client.csproj | 34 +- .../Models/DemoUser.cs | 2 +- .../Pages/Administration/QuartzManager.razor | 6 +- .../Pages/Administration/RoleManager.razor | 2 +- .../Pages/Basic/Profile.razor | 8 +- .../Pages/Discord/LinkedRole.razor | 6 +- .../Pages/Discord/OAuthCallback.razor | 2 +- .../Pages/GOG/LinkedRole.razor | 4 +- .../Pages/GOG/OAuthCallback.razor | 2 +- .../Pages/Moderator/AllowUserModuleId.razor | 6 +- .../Pages/Moderator/ManualModuleIdLink.razor | 6 +- .../Pages/Steam/LinkedRole.razor | 4 +- .../Pages/Steam/OpenIdCallback.razor | 2 +- .../Pages/Tools/Articles.razor | 4 +- .../Pages/Tools/ExposedMods.razor | 4 +- .../Pages/Tools/GamePublicApiDiff.razor | 15 +- .../Pages/Tools/GamePublicApiDiffSearch.razor | 2 +- .../Pages/User/AllowUserMod.razor | 6 +- .../Pages/User/CrashReportsViewer.razor | 4 +- .../Pages/User/Mods.razor | 8 +- .../User/StatisticsExceptionTypes.razor.cs | 2 +- .../Pages/User/StatisticsInvolved.razor.cs | 6 +- .../Services/AuthenticationProvider.cs | 4 +- .../Services/CrashReportsClientWithDemo.cs | 19 +- .../HttpClient/TenantDelegatingHandler.cs | 2 +- .../Services/NexusModsModClientWithDemo.cs | 15 +- .../Services/NexusModsUserClientWithDemo.cs | 63 +- .../Services/TenantProvider.cs | 8 +- .../Shared/Header.razor | 10 +- .../BUTR.Site.NexusMods.Server.csproj | 36 +- .../Contexts/AppContextSaveScope.cs | 20 - .../Contexts/AppDbContextRead.cs | 29 +- .../Contexts/AppDbContextWrite.cs | 150 +- .../Contexts/BaseAppDbContext.cs | 42 +- .../Configs/BaseEntityConfiguration.cs | 4 +- .../BaseEntityConfigurationWithTenant.cs | 4 +- .../Configs/CrashReportEntityConfiguration.cs | 13 +- ...hReportIgnoredFileIdEntityConfiguration.cs | 4 +- .../CrashReportToFileIdEntityConfiguration.cs | 6 +- ...rashReportToMetadataEntityConfiguration.cs | 4 +- ...portToModuleMetadataEntityConfiguration.cs | 11 +- .../ExceptionTypeEntityConfiguration.cs | 4 +- ...grationDiscordTokensEntityConfiguration.cs | 5 +- ...tionGOGToOwnedTenantEntityConfiguration.cs | 4 +- ...IntegrationGOGTokensEntityConfiguration.cs | 5 +- ...onSteamToOwnedTenantEntityConfiguration.cs | 4 +- ...tegrationSteamTokensEntityConfiguration.cs | 5 +- .../Configs/ModuleEntityConfiguration.cs | 4 +- .../NexusModsArticleEntityConfiguration.cs | 7 +- .../NexusModsModEntityConfiguration.cs | 4 +- ...sModsModToFileUpdateEntityConfiguration.cs | 5 +- ...NexusModsModToModuleEntityConfiguration.cs | 7 +- ...dToModuleInfoHistoryEntityConfiguration.cs | 9 +- .../NexusModsModToNameEntityConfiguration.cs | 5 +- .../NexusModsUserEntityConfiguration.cs | 4 +- ...odsUserToCrashReportEntityConfiguration.cs | 7 +- ...ToIntegrationDiscordEntityConfiguration.cs | 5 +- ...UserToIntegrationGOGEntityConfiguration.cs | 5 +- ...erToIntegrationSteamEntityConfiguration.cs | 5 +- ...exusModsUserToModuleEntityConfiguration.cs | 7 +- .../NexusModsUserToNameEntityConfiguration.cs | 7 +- ...dsUserToNexusModsModEntityConfiguration.cs | 7 +- .../NexusModsUserToRoleEntityConfiguration.cs | 9 +- .../QuartzExecutionLogEntryConfiguration.cs | 39 +- ...csCrashScoreInvolvedEntityConfiguration.cs | 9 +- ...icsTopExceptionsTypeEntityConfiguration.cs | 5 +- .../Configs/TenantEntityConfiguration.cs | 4 +- .../Contexts/EntityConfigurationFactory.cs | 4 +- .../Contexts/EntityFactory.cs | 36 +- .../Contexts/IAppDbContextSaveScope.cs | 9 + .../Contexts/IAppDbContextWrite.cs | 12 +- .../Controllers/AuthenticationController.cs | 68 +- .../Controllers/ControllerExtended.cs | 32 +- .../CrashReportsAnalyzerController.cs | 171 ++ .../Controllers/CrashReportsController.cs | 103 +- .../Controllers/DiscordController.cs | 27 +- .../Controllers/ExposedModsController.cs | 11 +- .../Controllers/GOGController.cs | 18 +- .../GamePublicApiDiffController.cs | 14 +- .../Controllers/GameSourceDiffController.cs | 23 +- .../Controllers/NexusModsArticleController.cs | 15 +- .../Controllers/NexusModsModController.cs | 43 +- .../Controllers/NexusModsUserController.cs | 124 +- .../Controllers/QuartzController.cs | 16 +- .../RecreateStacktraceController.cs | 2 +- .../Controllers/ReportsController.cs | 4 +- .../Controllers/StatisticsController.cs | 22 +- .../Controllers/SteamController.cs | 30 +- .../DynamicExpressions/DynamicExpressions.cs | 112 ++ .../DynamicFilterBuilder.cs | 59 + .../ExpressionExtensions.cs | 19 + .../DynamicExpressions/FilterOperator.cs | 22 + .../Extensions/DbSetExtensions.cs | 73 + .../Extensions/HttpContextExtensions.cs | 12 +- .../JobExecutionContextExtensions.cs | 35 +- .../Extensions/QueryableExtensions.cs | 36 +- .../Extensions/VogenExtensions.cs | 80 + .../Jobs/AutocompleteProcessorProcessorJob.cs | 6 +- .../Jobs/CrashReportAnalyzerProcessorJob.cs | 6 +- .../Jobs/CrashReportProcessorJob.cs | 303 +--- .../Jobs/NexusModsArticleProcessorJob.cs | 10 +- .../NexusModsArticleUpdatesProcessorJob.cs | 10 +- .../Jobs/NexusModsModFileProcessorJob.cs | 17 +- .../NexusModsModFileUpdatesProcessorJob.cs | 18 +- .../TopExceptionsTypesAnalyzerProcessorJob.cs | 6 +- ...xusModsModToModuleInfoHistory3.Designer.cs | 1455 +++++++++++++++++ ...195044_NexusModsModToModuleInfoHistory3.cs | 42 + .../20231029211041_Quartz.Designer.cs | 1444 ++++++++++++++++ .../Migrations/20231029211041_Quartz.cs | 65 + .../BaseAppDbContextModelSnapshot.cs | 103 +- .../Models/API/MessageResponse.cs | 12 +- .../Models/API/NexusModsModModel.cs | 11 - .../Models/API/PagingData.cs | 4 +- .../Models/API/ProfileModel.cs | 2 +- .../Models/API/ProfileTenantModel.cs | 7 + .../Models/Database/CrashReportEntity.cs | 4 +- .../Models/Database/IEntity.cs | 4 +- .../Models/Database/Json/ModuleInfoModel.cs | 35 + .../Models/Database/NexusModsArticleEntity.cs | 2 +- .../Models/Database/NexusModsModEntity.cs | 4 +- .../NexusModsModToFileUpdateEntity.cs | 2 +- .../Database/NexusModsModToModuleEntity.cs | 2 +- .../NexusModsModToModuleInfoHistoryEntity.cs | 2 +- .../Models/Database/NexusModsUserEntity.cs | 10 +- .../NexusModsUserToIntegrationGOGEntity.cs | 2 +- .../NexusModsUserToIntegrationSteamEntity.cs | 2 +- .../QuartzExecutionLogDetailEntity.cs | 9 +- .../Database/QuartzExecutionLogEntity.cs | 42 +- .../Models/Database/QuartzLogType.cs | 8 - .../Models/FileIdDate.cs | 4 +- .../Models/GOGUserInfo.cs | 7 - .../Models/NexusModsModFileParserResult.cs | 12 - .../{EventArgs.cs => QuartzEventArgs.cs} | 6 +- .../Models/Quartz/SchedulerErrorEventArgs.cs | 13 - .../Models/SteamUserInfo.cs | 7 - .../Models/Vogen/ApplicationRole.cs | 29 +- .../Models/Vogen/CrashReportFileId.cs | 28 +- .../Models/Vogen/CrashReportId.cs | 30 +- .../Models/Vogen/CrashReportUrl.cs | 30 +- .../Models/Vogen/CrashReportVersion.cs | 30 +- .../Models/Vogen/ExceptionTypeId.cs | 30 +- .../Models/Vogen/GameVersion.cs | 26 +- .../Models/Vogen/ModuleId.cs | 30 +- .../Models/Vogen/ModuleVersion.cs | 30 +- .../Models/Vogen/NexusModsApiKey.cs | 29 +- .../Models/Vogen/NexusModsArticleId.cs | 41 +- .../Models/Vogen/NexusModsFileId.cs | 28 +- .../Models/Vogen/NexusModsGameDomain.cs | 51 +- .../Models/Vogen/NexusModsModId.cs | 43 +- .../Models/Vogen/NexusModsUserEMail.cs | 29 +- .../Models/Vogen/NexusModsUserId.cs | 44 +- .../Models/Vogen/NexusModsUserName.cs | 31 +- .../Models/Vogen/TenantId.cs | 38 +- src/BUTR.Site.NexusMods.Server/Program.cs | 39 +- .../Services/CrashReportBatchedHandler.cs | 294 ++++ .../ExternalStorageConstants.cs | 7 - .../ExternalStorage/IDiscordStorage.cs | 7 +- .../Services/ExternalStorage/IGOGStorage.cs | 15 +- .../Services/ExternalStorage/ISteamStorage.cs | 16 +- .../Services/HttpClients/GOGEmbedClient.cs | 8 +- .../Services/HttpClients/SteamAPIClient.cs | 7 +- .../Services/NexusModsModFileParser.cs | 11 +- .../Services/QuartzEventProviderService.cs | 193 +-- .../QuartzListenerBackgroundService.cs | 420 +---- .../Services/SteamDepotDownloader.cs | 3 +- src/BUTR.Site.NexusMods.Server/Startup.cs | 60 +- .../APIResponses/APIResponseActionResult.cs | 16 + .../APIResponseActionResultExecutor.cs | 123 ++ .../APIResponseActionResultModel.cs | 17 + .../APIResponseOperationFilter.cs | 28 + .../APIResponseProblemDetailsWriter.cs | 25 + .../Utils/APIResponses/APIResponseUtils.cs | 16 + .../Utils/AuthResponsesOperationFilter.cs | 2 +- .../BindingSources/BindApiKeyAttribute.cs | 17 + .../Utils/BindingSources/BindIgnoreFilter.cs | 42 + .../Utils/BindingSources/BindRoleAttribute.cs | 17 + .../BindingSources/BindTenantAttribute.cs | 16 + .../BindingSources/BindUserIdAttribute.cs | 17 + .../BindingSources/ClaimsBindingSource.cs | 9 + .../BindingSources/ClaimsValueProvider.cs | 28 + .../ClaimsValueProviderFactory.cs | 18 + .../Utils/BindingSources/IBindIgnore.cs | 3 + .../Utils/BlockUntilDateConstraint.cs | 2 +- .../ButrNexusModsAuthorizationAttribute.cs | 13 + .../Utils/CopyHelper.cs | 28 + .../Utils/{ => Http}/HttpRangeStream.cs | 15 +- .../Logging/SyncLoggingHttpMessageHandler.cs | 2 +- .../SyncLoggingScopeHttpMessageHandler.cs | 2 +- .../ImmutableArrayToArrayConverter.cs | 4 +- .../Utils/PlainTextOutput2.cs | 135 -- .../Utils/{ => Quartz}/JobDataMapKeys.cs | 2 +- .../Utils/RecreateStacktraceUtils.cs | 8 +- .../{ => Reflection}/CSharpILMixedLanguage.cs | 4 +- .../Utils/Reflection/SignatureType.cs | 2 +- .../Utils/ResponseContentTypeHelper.cs | 68 + .../Utils/TenantNotRequiredAttribute.cs | 32 + .../Utils/TenantRequiredAttribute.cs | 55 + .../Utils/Vogen/IHasCopy.cs | 6 + .../Utils/Vogen/IHasDefaultValue.cs | 6 + .../Utils/Vogen/IHasDeserialize.cs | 6 + .../Utils/Vogen/IHasIsInitialized.cs | 6 + .../Utils/Vogen/IHasRandomValueGenerator.cs | 11 + .../Utils/Vogen/IVogen.cs | 58 + .../Utils/Vogen/VogenDefaults.cs | 39 + .../Utils/Vogen/VogenDefaultsParsable.cs | 33 + .../VogenDefaultsRandomValueGenerator.cs | 23 + .../Utils/Vogen/VogenDefaultsSpanParsable.cs | 33 + .../Vogen/VogenDefaultsUtf8SpanParsable.cs | 33 + .../Utils/Vogen/VogenJsonConverter.cs | 34 + .../Utils/Vogen/VogenSchemaFilter.cs | 22 + .../Utils/Vogen/VogenTypeConverter.cs | 23 + .../Utils/Vogen/VogenValueComparer.cs | 18 + .../Vogen/VogenValueComparerReference.cs | 17 + .../Utils/Vogen/VogenValueConverter.cs | 15 + .../Utils/VogenSchemaGenerator.cs | 37 - .../BUTR.Site.NexusMods.ServerClient.csproj | 6 +- .../Clients.cs | 91 +- .../Utils/PagingStreamingData.cs | 6 +- .../BUTR.Site.NexusMods.Shared.csproj | 2 +- .../Helpers/TenantUtils.cs | 14 +- src/nuget.config | 1 + 221 files changed, 6539 insertions(+), 2134 deletions(-) delete mode 100644 src/BUTR.Site.NexusMods.Server/Contexts/AppContextSaveScope.cs create mode 100644 src/BUTR.Site.NexusMods.Server/Contexts/IAppDbContextSaveScope.cs create mode 100644 src/BUTR.Site.NexusMods.Server/Controllers/CrashReportsAnalyzerController.cs create mode 100644 src/BUTR.Site.NexusMods.Server/DynamicExpressions/DynamicExpressions.cs create mode 100644 src/BUTR.Site.NexusMods.Server/DynamicExpressions/DynamicFilterBuilder.cs create mode 100644 src/BUTR.Site.NexusMods.Server/DynamicExpressions/ExpressionExtensions.cs create mode 100644 src/BUTR.Site.NexusMods.Server/DynamicExpressions/FilterOperator.cs create mode 100644 src/BUTR.Site.NexusMods.Server/Extensions/DbSetExtensions.cs create mode 100644 src/BUTR.Site.NexusMods.Server/Extensions/VogenExtensions.cs create mode 100644 src/BUTR.Site.NexusMods.Server/Migrations/20231017195044_NexusModsModToModuleInfoHistory3.Designer.cs create mode 100644 src/BUTR.Site.NexusMods.Server/Migrations/20231017195044_NexusModsModToModuleInfoHistory3.cs create mode 100644 src/BUTR.Site.NexusMods.Server/Migrations/20231029211041_Quartz.Designer.cs create mode 100644 src/BUTR.Site.NexusMods.Server/Migrations/20231029211041_Quartz.cs delete mode 100644 src/BUTR.Site.NexusMods.Server/Models/API/NexusModsModModel.cs create mode 100644 src/BUTR.Site.NexusMods.Server/Models/API/ProfileTenantModel.cs delete mode 100644 src/BUTR.Site.NexusMods.Server/Models/Database/QuartzLogType.cs delete mode 100644 src/BUTR.Site.NexusMods.Server/Models/GOGUserInfo.cs delete mode 100644 src/BUTR.Site.NexusMods.Server/Models/NexusModsModFileParserResult.cs rename src/BUTR.Site.NexusMods.Server/Models/Quartz/{EventArgs.cs => QuartzEventArgs.cs} (63%) delete mode 100644 src/BUTR.Site.NexusMods.Server/Models/Quartz/SchedulerErrorEventArgs.cs delete mode 100644 src/BUTR.Site.NexusMods.Server/Models/SteamUserInfo.cs create mode 100644 src/BUTR.Site.NexusMods.Server/Services/CrashReportBatchedHandler.cs create mode 100644 src/BUTR.Site.NexusMods.Server/Utils/APIResponses/APIResponseActionResult.cs create mode 100644 src/BUTR.Site.NexusMods.Server/Utils/APIResponses/APIResponseActionResultExecutor.cs create mode 100644 src/BUTR.Site.NexusMods.Server/Utils/APIResponses/APIResponseActionResultModel.cs create mode 100644 src/BUTR.Site.NexusMods.Server/Utils/APIResponses/APIResponseOperationFilter.cs create mode 100644 src/BUTR.Site.NexusMods.Server/Utils/APIResponses/APIResponseProblemDetailsWriter.cs create mode 100644 src/BUTR.Site.NexusMods.Server/Utils/APIResponses/APIResponseUtils.cs create mode 100644 src/BUTR.Site.NexusMods.Server/Utils/BindingSources/BindApiKeyAttribute.cs create mode 100644 src/BUTR.Site.NexusMods.Server/Utils/BindingSources/BindIgnoreFilter.cs create mode 100644 src/BUTR.Site.NexusMods.Server/Utils/BindingSources/BindRoleAttribute.cs create mode 100644 src/BUTR.Site.NexusMods.Server/Utils/BindingSources/BindTenantAttribute.cs create mode 100644 src/BUTR.Site.NexusMods.Server/Utils/BindingSources/BindUserIdAttribute.cs create mode 100644 src/BUTR.Site.NexusMods.Server/Utils/BindingSources/ClaimsBindingSource.cs create mode 100644 src/BUTR.Site.NexusMods.Server/Utils/BindingSources/ClaimsValueProvider.cs create mode 100644 src/BUTR.Site.NexusMods.Server/Utils/BindingSources/ClaimsValueProviderFactory.cs create mode 100644 src/BUTR.Site.NexusMods.Server/Utils/BindingSources/IBindIgnore.cs create mode 100644 src/BUTR.Site.NexusMods.Server/Utils/ButrNexusModsAuthorizationAttribute.cs create mode 100644 src/BUTR.Site.NexusMods.Server/Utils/CopyHelper.cs rename src/BUTR.Site.NexusMods.Server/Utils/{ => Http}/HttpRangeStream.cs (95%) rename src/BUTR.Site.NexusMods.Server/Utils/{ => Npgsql}/ImmutableArrayToArrayConverter.cs (79%) delete mode 100644 src/BUTR.Site.NexusMods.Server/Utils/PlainTextOutput2.cs rename src/BUTR.Site.NexusMods.Server/Utils/{ => Quartz}/JobDataMapKeys.cs (78%) rename src/BUTR.Site.NexusMods.Server/Utils/{ => Reflection}/CSharpILMixedLanguage.cs (97%) create mode 100644 src/BUTR.Site.NexusMods.Server/Utils/ResponseContentTypeHelper.cs create mode 100644 src/BUTR.Site.NexusMods.Server/Utils/TenantNotRequiredAttribute.cs create mode 100644 src/BUTR.Site.NexusMods.Server/Utils/TenantRequiredAttribute.cs create mode 100644 src/BUTR.Site.NexusMods.Server/Utils/Vogen/IHasCopy.cs create mode 100644 src/BUTR.Site.NexusMods.Server/Utils/Vogen/IHasDefaultValue.cs create mode 100644 src/BUTR.Site.NexusMods.Server/Utils/Vogen/IHasDeserialize.cs create mode 100644 src/BUTR.Site.NexusMods.Server/Utils/Vogen/IHasIsInitialized.cs create mode 100644 src/BUTR.Site.NexusMods.Server/Utils/Vogen/IHasRandomValueGenerator.cs create mode 100644 src/BUTR.Site.NexusMods.Server/Utils/Vogen/IVogen.cs create mode 100644 src/BUTR.Site.NexusMods.Server/Utils/Vogen/VogenDefaults.cs create mode 100644 src/BUTR.Site.NexusMods.Server/Utils/Vogen/VogenDefaultsParsable.cs create mode 100644 src/BUTR.Site.NexusMods.Server/Utils/Vogen/VogenDefaultsRandomValueGenerator.cs create mode 100644 src/BUTR.Site.NexusMods.Server/Utils/Vogen/VogenDefaultsSpanParsable.cs create mode 100644 src/BUTR.Site.NexusMods.Server/Utils/Vogen/VogenDefaultsUtf8SpanParsable.cs create mode 100644 src/BUTR.Site.NexusMods.Server/Utils/Vogen/VogenJsonConverter.cs create mode 100644 src/BUTR.Site.NexusMods.Server/Utils/Vogen/VogenSchemaFilter.cs create mode 100644 src/BUTR.Site.NexusMods.Server/Utils/Vogen/VogenTypeConverter.cs create mode 100644 src/BUTR.Site.NexusMods.Server/Utils/Vogen/VogenValueComparer.cs create mode 100644 src/BUTR.Site.NexusMods.Server/Utils/Vogen/VogenValueComparerReference.cs create mode 100644 src/BUTR.Site.NexusMods.Server/Utils/Vogen/VogenValueConverter.cs delete mode 100644 src/BUTR.Site.NexusMods.Server/Utils/VogenSchemaGenerator.cs diff --git a/src/BUTR.Site.NexusMods.Client/BUTR.Site.NexusMods.Client.csproj b/src/BUTR.Site.NexusMods.Client/BUTR.Site.NexusMods.Client.csproj index 1f2e558b..29023f83 100644 --- a/src/BUTR.Site.NexusMods.Client/BUTR.Site.NexusMods.Client.csproj +++ b/src/BUTR.Site.NexusMods.Client/BUTR.Site.NexusMods.Client.csproj @@ -1,7 +1,7 @@ - net7.0 + net8.0 false false true @@ -10,24 +10,24 @@ - - - - - - - - - + + + + + + + + + - - - - - + + + + + - - + +