29 lines
978 B
C#
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);
|
|
}
|
|
}
|
|
}
|