btcpayserver/BTCPayServer/Services/Mails/StoreEmailSender.cs

41 lines
1.3 KiB
C#
Raw Normal View History

2020-06-28 21:44:35 -05:00
using System;
2019-01-06 15:53:37 +01:00
using System.Threading.Tasks;
using BTCPayServer.Data;
2021-11-22 17:16:08 +09:00
using BTCPayServer.Logging;
2020-06-28 17:55:27 +09:00
using BTCPayServer.Services.Stores;
2019-01-06 15:53:37 +01:00
namespace BTCPayServer.Services.Mails
{
class StoreEmailSender : EmailSender
{
public StoreEmailSender(StoreRepository storeRepository,
EmailSender fallback,
IBackgroundJobClient backgroundJobClient,
2021-11-22 17:16:08 +09:00
string storeId,
Logs logs) : base(backgroundJobClient, logs)
2019-01-06 15:53:37 +01:00
{
2020-12-08 08:12:29 +01:00
StoreId = storeId ?? throw new ArgumentNullException(nameof(storeId));
2019-01-06 15:53:37 +01:00
StoreRepository = storeRepository;
FallbackSender = fallback;
}
public StoreRepository StoreRepository { get; }
public EmailSender FallbackSender { get; }
public string StoreId { get; }
public override async Task<EmailSettings> GetEmailSettings()
{
var store = await StoreRepository.FindStore(StoreId);
var emailSettings = store.GetStoreBlob().EmailSettings;
if (emailSettings?.IsComplete() == true)
{
return emailSettings;
}
2020-12-08 08:12:29 +01:00
2021-12-31 16:59:02 +09:00
if (FallbackSender != null)
return await FallbackSender?.GetEmailSettings();
2020-12-08 08:12:29 +01:00
return null;
2019-01-06 15:53:37 +01:00
}
}
}