Move AddedWho config to RecActionOptions and refactor usage

Centralize AddedWho under RecAction in appsettings.json and add it to RecActionOptions. Update InvokeRecActionViewCommandHandler to use IOptions<RecActionOptions> for strongly-typed configuration access, replacing previous config-based retrieval. Removes global AddedWho property for improved maintainability.
This commit is contained in:
2026-03-16 13:32:34 +01:00
parent 636397efb8
commit f67579dba9
3 changed files with 7 additions and 3 deletions

View File

@@ -20,11 +20,14 @@ public record InvokeRecActionViewCommand : IRequest<bool>
}
public class InvokeRecActionViewCommandHandler(
IOptions<RecActionOptions> options,
ISender sender,
IHttpClientFactory clientFactory,
IConfiguration? config = null
) : IRequestHandler<InvokeRecActionViewCommand, bool>
{
private readonly RecActionOptions _options = options.Value;
public async Task<bool> Handle(InvokeRecActionViewCommand request, CancellationToken cancel)
{
var action = request.Action;
@@ -135,7 +138,7 @@ public class InvokeRecActionViewCommandHandler(
ActionId = action.Id,
Header = JsonSerializer.Serialize(resHeaders, options: new() { WriteIndented = false }),
Body = resBody
}, config?["AddedWho"], cancel);
}, _options.AddedWho, cancel);
return response.IsSuccessStatusCode;
}