2757869176
Add contract validation, SMTP delivery results, terminal failure context, neutral development seeding, and local Docker setup. Ref: IT-1033
36 lines
1.2 KiB
C#
36 lines
1.2 KiB
C#
namespace HrynCo.NotificationService.Worker.Services.EmailProcessing;
|
|
|
|
using HrynCo.NotificationService.DAL.Abstract.Repositories;
|
|
using HrynCo.NotificationService.DAL.Abstract.Templates;
|
|
|
|
internal sealed class EmailTemplateService : IEmailTemplateService
|
|
{
|
|
private readonly IEmailTemplateRepository _templateRepository;
|
|
|
|
public EmailTemplateService(IEmailTemplateRepository templateRepository)
|
|
{
|
|
_templateRepository = templateRepository;
|
|
}
|
|
|
|
public async Task<EmailTemplate> GetAsync(
|
|
string serviceName,
|
|
string templateKey,
|
|
string? languageCode,
|
|
CancellationToken cancellationToken)
|
|
{
|
|
if (string.IsNullOrWhiteSpace(languageCode))
|
|
throw new InvalidDataException("LanguageCode is required.");
|
|
|
|
string lang = languageCode.Trim().ToLowerInvariant();
|
|
EmailTemplate? template = await _templateRepository.GetAsync(
|
|
serviceName,
|
|
templateKey,
|
|
lang,
|
|
cancellationToken);
|
|
|
|
return template
|
|
?? throw new InvalidOperationException(
|
|
$"Template not found: service='{serviceName}' key='{templateKey}' language='{lang}'.");
|
|
}
|
|
}
|