refactor(MessagingService): umbenannt in SmsSender

This commit is contained in:
Developer 02 2025-01-31 10:37:59 +01:00
parent e54d9d2da8
commit 22347a0202
6 changed files with 14 additions and 12 deletions

View File

@ -2,7 +2,8 @@
namespace EnvelopeGenerator.Application.Contracts;
public interface IMessagingService
//TODO: move to DigitalData.Core
public interface ISmsSender
{
string ServiceProvider { get; }

View File

@ -60,7 +60,7 @@ namespace EnvelopeGenerator.Application.Extensions
services.Configure<EnvelopeReceiverCacheParams>(envelopeReceiverCacheParamsSection);
services.AddHttpClientService<SmsParams>(smsConfigSection);
services.TryAddSingleton<IMessagingService, GtxMessagingService>();
services.TryAddSingleton<ISmsSender, GTXSmsSender>();
services.TryAddSingleton<ICodeGenerator, CodeGenerator>();
services.TryAddSingleton<QRCodeGenerator>();

View File

@ -17,13 +17,13 @@ namespace EnvelopeGenerator.Application.Services
{
private readonly IStringLocalizer<Resource> _localizer;
private readonly IMessagingService _messagingService;
private readonly ISmsSender _smsSender;
public EnvelopeReceiverService(IEnvelopeReceiverRepository repository, IStringLocalizer<Resource> localizer, IMapper mapper, IMessagingService messagingService)
public EnvelopeReceiverService(IEnvelopeReceiverRepository repository, IStringLocalizer<Resource> localizer, IMapper mapper, ISmsSender smsSender)
: base(repository, mapper)
{
_localizer = localizer;
_messagingService = messagingService;
_smsSender = smsSender;
}
public async Task<DataResult<IEnumerable<EnvelopeReceiverDto>>> ReadBySignatureAsync(string signature, bool withEnvelope = false, bool withReceiver = true, bool readOnly = true)
@ -171,7 +171,7 @@ namespace EnvelopeGenerator.Application.Services
.Message(Key.PhoneNumberNonexists)
.Notice(LogLevel.Error, Flag.NotFound, $"An attempt was made to send sms to the user whose phone number is null. Envelope recipient ID is {envelopeReceiverId}, UUID is {uuid} and signature is {signature}.");
var res = await _messagingService.SendSmsAsync(recipient: env_rcv.PhoneNumber, message: message);
var res = await _smsSender.SendSmsAsync(recipient: env_rcv.PhoneNumber, message: message);
return Result.Success(res);
}

View File

@ -8,7 +8,8 @@ using Microsoft.Extensions.Options;
namespace EnvelopeGenerator.Application.Services;
public class GtxMessagingService : IMessagingService
//TODO: move to DigitalData.Core
public class GTXSmsSender : ISmsSender
{
private readonly IHttpClientService<SmsParams> _smsClient;
@ -18,7 +19,7 @@ public class GtxMessagingService : IMessagingService
public string ServiceProvider { get; }
public GtxMessagingService(IHttpClientService<SmsParams> smsClient, IOptions<SmsParams> smsParamsOptions, IMapper mapper)
public GTXSmsSender(IHttpClientService<SmsParams> smsClient, IOptions<SmsParams> smsParamsOptions, IMapper mapper)
{
_smsClient = smsClient;
_smsParams = smsParamsOptions.Value;

View File

@ -38,13 +38,13 @@ namespace EnvelopeGenerator.Web.Controllers
private readonly Cultures _cultures;
private readonly IEnvelopeMailService _mailService;
private readonly IEnvelopeReceiverReadOnlyService _readOnlyService;
private readonly IMessagingService _msgService;
private readonly ISmsSender _msgService;
private readonly ICodeGenerator _codeGenerator;
private readonly IReceiverService _rcvService;
private readonly IDistributedCache _dCache;
private readonly TotpSmsParams _totpSmsParams;
public HomeController(EnvelopeOldService envelopeOldService, ILogger<HomeController> logger, IEnvelopeReceiverService envelopeReceiverService, IEnvelopeHistoryService historyService, IStringLocalizer<Resource> localizer, IConfiguration configuration, HtmlSanitizer sanitizer, Cultures cultures, IEnvelopeMailService envelopeMailService, IEnvelopeReceiverReadOnlyService readOnlyService, IMessagingService messagingService, ICodeGenerator codeGenerator, IReceiverService receiverService, IDistributedCache distributedCache, IOptions<TotpSmsParams> totpSmsParamsOptions)
public HomeController(EnvelopeOldService envelopeOldService, ILogger<HomeController> logger, IEnvelopeReceiverService envelopeReceiverService, IEnvelopeHistoryService historyService, IStringLocalizer<Resource> localizer, IConfiguration configuration, HtmlSanitizer sanitizer, Cultures cultures, IEnvelopeMailService envelopeMailService, IEnvelopeReceiverReadOnlyService readOnlyService, ISmsSender messagingService, ICodeGenerator codeGenerator, IReceiverService receiverService, IDistributedCache distributedCache, IOptions<TotpSmsParams> totpSmsParamsOptions)
{
this.envelopeOldService = envelopeOldService;
_envRcvService = envelopeReceiverService;

View File

@ -7,9 +7,9 @@ namespace EnvelopeGenerator.Web.Controllers.Test
[ApiController]
public class TestMessagingController : ControllerBase
{
private readonly IMessagingService _service;
private readonly ISmsSender _service;
public TestMessagingController(IMessagingService service)
public TestMessagingController(ISmsSender service)
{
_service = service;
}