Files
hrynco-notification-service/HrynCo.NotificationService.Services/EmailChannels/GetByService/GetEmailChannelsHandler.cs
T
agrynco 1631786ce2 feat(push): add service-owned firebase channels and delivery
Add push contracts, provider delivery and channel diagnostics. Link email channels to services and document migration and validation.

Ref: IT-1074
2026-10-24 12:31:35 +03:00

35 lines
1.4 KiB
C#

using HrynCo.NotificationService.DAL.Abstract.Providers;
using HrynCo.NotificationService.DAL.Abstract.Repositories;
using HrynCo.NotificationService.Services.Core;
using HrynCo.NotificationService.Services.Logging;
using static HrynCo.NotificationService.Services.Core.ServiceResultHelper;
namespace HrynCo.NotificationService.Services.EmailChannels.GetByService;
internal sealed class GetEmailChannelsHandler
: RequestHandler<GetEmailChannelsQuery, ServiceResult<IReadOnlyList<EmailChannel>>>
{
private readonly IEmailChannelRepository _channels;
private readonly INotificationServiceRepository _services;
public GetEmailChannelsHandler(
IContextualSerilogLogger<GetEmailChannelsQuery> logger,
IEmailChannelRepository channels,
INotificationServiceRepository services)
: base(logger)
{
_channels = channels;
_services = services;
}
protected override async Task<ServiceResult<IReadOnlyList<EmailChannel>>> DoOnHandle(
GetEmailChannelsQuery request, CancellationToken cancellationToken)
{
var service = await _services.GetByNameAsync(request.ServiceName, cancellationToken);
if (service is null)
return Success<IReadOnlyList<EmailChannel>>([]);
var channels = await _channels.GetByServiceAsync(service.Id, cancellationToken);
return Success(channels);
}
}