Files
Hushian/Infrastructure/Infrastructure/MessageSender.cs
mmrbnjd c535cb078e ...
2025-08-20 14:15:10 +03:30

29 lines
978 B
C#

using Common.Contracts.Infrastructure;
using Hushian.Application.Models.Message;
using Microsoft.Extensions.Options;
namespace Hushian.Infrastructure
{
public class MessageSender : IMessageSender
{
private readonly Melipayamak.RestClient _restClient;
private MessageSetting _msgSettings;
public MessageSender(Melipayamak.RestClient restClient, IOptions<MessageSetting> msgSettings)
{
_restClient = restClient;
_msgSettings = msgSettings.Value;
}
public async Task<bool> SendMessageVerification(string To,string Code)
{
return await SendMassage(new Message(To,$"برای ادامه از کد {Code} استفاده کنید"));
}
private Task<bool> SendMassage(Message message)
{
string From = _msgSettings.From;
_restClient.Send(message.To, From, message.msg, false);
return Task.Run(()=>true);
}
}
}