mirror of
https://github.com/bitwarden/server.git
synced 2024-11-21 12:05:42 +01:00
Switched to enqueue mail message.
This commit is contained in:
parent
c273ce79b0
commit
498cc7a5a9
@ -7,6 +7,7 @@ using Bit.Core.Context;
|
||||
using Bit.Core.Entities;
|
||||
using Bit.Core.Enums;
|
||||
using Bit.Core.Exceptions;
|
||||
using Bit.Core.Models.Data.Organizations;
|
||||
using Bit.Core.Repositories;
|
||||
using Bit.Core.Services;
|
||||
using Bit.Core.Settings;
|
||||
@ -141,6 +142,6 @@ public class VerifyOrganizationDomainCommand(
|
||||
|
||||
var organization = await organizationRepository.GetByIdAsync(organizationId);
|
||||
|
||||
await Task.WhenAll(userEmails.Select(email => mailService.SendVerifiedDomainUserEmailAsync(email, organization)));
|
||||
await mailService.SendVerifiedDomainUserEmailAsync(new ManagedUserDomainClaimedEmails(userEmails, organization));
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,5 @@
|
||||
using Bit.Core.AdminConsole.Entities;
|
||||
|
||||
namespace Bit.Core.Models.Data.Organizations;
|
||||
|
||||
public record ManagedUserDomainClaimedEmails(IEnumerable<string> EmailList, Organization Organization);
|
@ -1,6 +1,6 @@
|
||||
namespace Bit.Core.Models.Mail;
|
||||
|
||||
public class VerifiedDomainUserNotificationViewModel : BaseMailModel
|
||||
public class VerifiedDomainUserNotificationViewModel : BaseTitleContactUsMailModel
|
||||
{
|
||||
public string OrganizationName { get; init; }
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ using Bit.Core.AdminConsole.Entities.Provider;
|
||||
using Bit.Core.Auth.Entities;
|
||||
using Bit.Core.Billing.Enums;
|
||||
using Bit.Core.Entities;
|
||||
using Bit.Core.Models.Data.Organizations;
|
||||
using Bit.Core.Models.Mail;
|
||||
|
||||
namespace Bit.Core.Services;
|
||||
@ -91,6 +92,6 @@ public interface IMailService
|
||||
Task SendInitiateDeletProviderEmailAsync(string email, Provider provider, string token);
|
||||
Task SendInitiateDeleteOrganzationEmailAsync(string email, Organization organization, string token);
|
||||
Task SendRequestSMAccessToAdminEmailAsync(IEnumerable<string> adminEmails, string organizationName, string userRequestingAccess, string emailContent);
|
||||
Task SendVerifiedDomainUserEmailAsync(string email, Organization organization);
|
||||
Task SendVerifiedDomainUserEmailAsync(ManagedUserDomainClaimedEmails emailList);
|
||||
}
|
||||
|
||||
|
@ -7,6 +7,7 @@ using Bit.Core.Auth.Models.Mail;
|
||||
using Bit.Core.Billing.Enums;
|
||||
using Bit.Core.Billing.Models.Mail;
|
||||
using Bit.Core.Entities;
|
||||
using Bit.Core.Models.Data.Organizations;
|
||||
using Bit.Core.Models.Mail;
|
||||
using Bit.Core.Models.Mail.FamiliesForEnterprise;
|
||||
using Bit.Core.Models.Mail.Provider;
|
||||
@ -460,17 +461,20 @@ public class HandlebarsMailService : IMailService
|
||||
await _mailDeliveryService.SendEmailAsync(message);
|
||||
}
|
||||
|
||||
public async Task SendVerifiedDomainUserEmailAsync(string email, Organization organization)
|
||||
public async Task SendVerifiedDomainUserEmailAsync(ManagedUserDomainClaimedEmails emailList)
|
||||
{
|
||||
var message = CreateDefaultMessage($"Your Bitwarden account is claimed by {organization.DisplayName()}", email);
|
||||
await EnqueueMailAsync(emailList.EmailList.Select(email =>
|
||||
CreateMessage(email, emailList.Organization)));
|
||||
return;
|
||||
|
||||
var model = new VerifiedDomainUserNotificationViewModel
|
||||
{
|
||||
OrganizationName = CoreHelpers.SanitizeForEmail(organization.DisplayName(), false)
|
||||
};
|
||||
await AddMessageContentAsync(message, "AdminConsole.VerifiedDomainUserNotification", model);
|
||||
message.Category = "VerifiedDomainUserNotification";
|
||||
await _mailDeliveryService.SendEmailAsync(message);
|
||||
MailQueueMessage CreateMessage(string emailAddress, Organization org) =>
|
||||
new(CreateDefaultMessage($"Your Bitwarden account is claimed by {org.DisplayName()}", emailAddress),
|
||||
"AdminConsole.VerifiedDomainUserNotification",
|
||||
new VerifiedDomainUserNotificationViewModel
|
||||
{
|
||||
TitleFirst = $"Hey {emailAddress}, here is a heads up on your claimed account:",
|
||||
OrganizationName = CoreHelpers.SanitizeForEmail(org.DisplayName(), false)
|
||||
});
|
||||
}
|
||||
|
||||
public async Task SendNewDeviceLoggedInEmail(string email, string deviceType, DateTime timestamp, string ip)
|
||||
|
@ -3,6 +3,7 @@ using Bit.Core.AdminConsole.Entities.Provider;
|
||||
using Bit.Core.Auth.Entities;
|
||||
using Bit.Core.Billing.Enums;
|
||||
using Bit.Core.Entities;
|
||||
using Bit.Core.Models.Data.Organizations;
|
||||
using Bit.Core.Models.Mail;
|
||||
|
||||
namespace Bit.Core.Services;
|
||||
@ -302,6 +303,6 @@ public class NoopMailService : IMailService
|
||||
return Task.FromResult(0);
|
||||
}
|
||||
public Task SendRequestSMAccessToAdminEmailAsync(IEnumerable<string> adminEmails, string organizationName, string userRequestingAccess, string emailContent) => throw new NotImplementedException();
|
||||
public Task SendVerifiedDomainUserEmailAsync(string email, Organization organization) => Task.CompletedTask;
|
||||
public Task SendVerifiedDomainUserEmailAsync(ManagedUserDomainClaimedEmails emailList) => Task.CompletedTask;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user