From f39eb9d8fe1cd1cc2ee76e1448c397f091ba650b Mon Sep 17 00:00:00 2001 From: Hermes Agent Date: Thu, 24 Sep 2026 16:00:06 +0200 Subject: [PATCH] Removed tools feature --- .../Endpoints/Tools/EncodeIdEndpoint.cs | 36 ------------------- .../Extensions/Services.cs | 2 -- .../Services/Tools/ToolCacheService.cs | 34 ------------------ .../Services/Tools/ToolService.cs | 10 ------ 4 files changed, 82 deletions(-) delete mode 100644 PostFundManagement.Api/Endpoints/Tools/EncodeIdEndpoint.cs delete mode 100644 PostFundManagement.Application/Services/Tools/ToolCacheService.cs delete mode 100644 PostFundManagement.Application/Services/Tools/ToolService.cs diff --git a/PostFundManagement.Api/Endpoints/Tools/EncodeIdEndpoint.cs b/PostFundManagement.Api/Endpoints/Tools/EncodeIdEndpoint.cs deleted file mode 100644 index 5a80c05..0000000 --- a/PostFundManagement.Api/Endpoints/Tools/EncodeIdEndpoint.cs +++ /dev/null @@ -1,36 +0,0 @@ -using PostFundManagement.Application.Abstractions.Services; -using PostFundManagement.Application.Extensions; -using PostFundManagement.Domain.Abstractions; -using PostFundManagement.Domain.Errors; -using PostFundManagement.Domain.Extensions; -using PostFundManagement.Domain.Security; -using Problems = Microsoft.AspNetCore.Mvc.ProblemDetails; - -namespace PostFundManagement.Api.Endpoints.Tools; - -[ApiVersionTarget(1)] -public sealed class EncodeIdEndpoint : IEndpoint -{ - public void Map(IEndpointRouteBuilder builder) - { - builder.MapGet("api/tools/hashid/{id64:long}", async (long id64, IToolService service, - CancellationToken cancellationToken) => - await service.EncodeLong(id64, cancellationToken) switch - { - { IsSuccess: true, Value: var hash } => Results.Ok(hash), - var r when r.HasError() => Results.BadRequest(r.Errors.ToProblems()), - var r => Results.InternalServerError(r.Errors.ToProblems()) - }) - .WithDescription("Hashes an int64 identifier") - .RequireAuthorization(Constants.MainScope) - .WithName(typeof(EncodeIdEndpoint).ToEndpointName()) - .MapToApiVersion(new ApiVersion(1)) - .Produces(StatusCodes.Status200OK) - .Produces(StatusCodes.Status401Unauthorized) - .Produces(StatusCodes.Status403Forbidden) - .Produces(StatusCodes.Status400BadRequest) - .Produces(StatusCodes.Status500InternalServerError) - .WithTags(EndpointTags.Tools) - .CacheOutput(); - } -} diff --git a/PostFundManagement.Application/Extensions/Services.cs b/PostFundManagement.Application/Extensions/Services.cs index 7005798..300f634 100644 --- a/PostFundManagement.Application/Extensions/Services.cs +++ b/PostFundManagement.Application/Extensions/Services.cs @@ -8,7 +8,6 @@ using PostFundManagement.Application.Services.Governance; using PostFundManagement.Application.Services.Grants; using PostFundManagement.Application.Services.Projects; using PostFundManagement.Application.Services.Shared; -using PostFundManagement.Application.Services.Tools; using PostFundManagement.Application.Services.Users; using PostFundManagement.Domain.Abstractions; @@ -81,7 +80,6 @@ public static class Services services.AddLoggedAuditedCachedServiceScoped(); services.AddLoggedCachedServiceScoped(); - services.AddLoggedCachedServiceScoped(); services.AddStackExchangeRedisCache(options => { diff --git a/PostFundManagement.Application/Services/Tools/ToolCacheService.cs b/PostFundManagement.Application/Services/Tools/ToolCacheService.cs deleted file mode 100644 index 22a3b3f..0000000 --- a/PostFundManagement.Application/Services/Tools/ToolCacheService.cs +++ /dev/null @@ -1,34 +0,0 @@ -using PostFundManagement.Application.Abstractions; -using PostFundManagement.Application.Abstractions.Services; -using PostFundManagement.Application.Services.Shared; -using static PostFundManagement.Domain.Extensions.Constants; - -namespace PostFundManagement.Application.Services.Tools; - -public sealed class ToolCacheService(ToolService service, IDistributedCache cache, - IFeatureManager featureManager) : ServiceCacheBase, IToolService -{ - public async Task> EncodeLong(long id, CancellationToken cancellationToken) => - await Result.Try((Func>>)(async () => - { - if (!await featureManager.IsEnabledAsync(ServiceCachingFeature)) - return await service.EncodeLong(id, cancellationToken); - - var cacheKey = HashService.ToMd5Hash($"encodelonghash-{id}").Value; - - var cached = await cache.GetStringAsync(cacheKey, cancellationToken); - - if(string.IsNullOrWhiteSpace(cached)) - { - var result = (await service.EncodeLong(id).ConfigureAwait(false)); - - if (result.IsFailed) return result; - - await cache.SetStringAsync(cacheKey, result.Value, cacheOptions, cancellationToken); - - return result.Value; - } - - return Result.Ok(cached); - })); -} diff --git a/PostFundManagement.Application/Services/Tools/ToolService.cs b/PostFundManagement.Application/Services/Tools/ToolService.cs deleted file mode 100644 index b6a494f..0000000 --- a/PostFundManagement.Application/Services/Tools/ToolService.cs +++ /dev/null @@ -1,10 +0,0 @@ -using PostFundManagement.Application.Abstractions.Services; -using PostFundManagement.Application.Services.Shared; - -namespace PostFundManagement.Application.Services.Tools; - -public sealed class ToolService(HashService service) : IToolService -{ - public Task> EncodeLong(long id, CancellationToken cancellationToken = default) => - Task.FromResult(service.HashEncodeLongId(id)); -}