mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-02-23 14:40:36 +01:00
* Onboarding: Invite new users - Separates the user self-registration and invite cases - Adds invitation email for users created by the admin - Adds invitation tokens to verify user was invited - Adds handler action for invite links - Refactors `UserEventHostedService` - Fixes #5726. * Add permissioned form tag helper * Better way of changing a user's role * Test fixes
46 lines
1.6 KiB
C#
46 lines
1.6 KiB
C#
using System;
|
|
using System.Threading.Tasks;
|
|
using BTCPayServer.Data;
|
|
using BTCPayServer.Logging;
|
|
using BTCPayServer.Services.Stores;
|
|
|
|
namespace BTCPayServer.Services.Mails
|
|
{
|
|
class StoreEmailSender : EmailSender
|
|
{
|
|
public StoreEmailSender(StoreRepository storeRepository,
|
|
EmailSender fallback,
|
|
IBackgroundJobClient backgroundJobClient,
|
|
string storeId,
|
|
Logs logs) : base(backgroundJobClient, logs)
|
|
{
|
|
StoreId = storeId ?? throw new ArgumentNullException(nameof(storeId));
|
|
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;
|
|
}
|
|
|
|
if (FallbackSender != null)
|
|
return await FallbackSender?.GetEmailSettings();
|
|
return null;
|
|
}
|
|
|
|
public override async Task<string> GetPrefixedSubject(string subject)
|
|
{
|
|
var store = await StoreRepository.FindStore(StoreId);
|
|
return string.IsNullOrEmpty(store?.StoreName) ? subject : $"{store.StoreName}: {subject}";
|
|
}
|
|
}
|
|
}
|