Skip to content

Commit 0df02d4

Browse files
[Core] Add IMailService.SendBusinessUnitConversionInviteAsync
1 parent 06c0c4c commit 0df02d4

File tree

6 files changed

+58
-0
lines changed

6 files changed

+58
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{{#>FullHtmlLayout}}
2+
<table width="100%" cellpadding="0" cellspacing="0" style="margin: 0; box-sizing: border-box; color: #333; line-height: 25px; -webkit-font-smoothing: antialiased; -webkit-text-size-adjust: none;">
3+
<tr style="margin: 0; box-sizing: border-box; color: #333; line-height: 25px; -webkit-font-smoothing: antialiased; -webkit-text-size-adjust: none;">
4+
<td class="content-block" style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; box-sizing: border-box; font-size: 16px; color: #333; line-height: 25px; margin: 0; -webkit-font-smoothing: antialiased; padding: 0 0 10px; -webkit-text-size-adjust: none; text-align: left;" valign="top" align="center">
5+
You have been invited to set up a new Business Unit Portal within Bitwarden.
6+
<br style="margin: 0; box-sizing: border-box; color: #333; line-height: 25px; -webkit-font-smoothing: antialiased; -webkit-text-size-adjust: none;" />
7+
<br style="margin: 0; box-sizing: border-box; color: #333; line-height: 25px; -webkit-font-smoothing: antialiased; -webkit-text-size-adjust: none;" />
8+
</td>
9+
</tr>
10+
<tr style="margin: 0; box-sizing: border-box; color: #333; line-height: 25px; -webkit-font-smoothing: antialiased; -webkit-text-size-adjust: none;">
11+
<td class="content-block" style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; box-sizing: border-box; font-size: 16px; color: #333; line-height: 25px; margin: 0; -webkit-font-smoothing: antialiased; padding: 0 0 10px; -webkit-text-size-adjust: none; text-align: center;" valign="top" align="center">
12+
<a href="{{{Url}}}" clicktracking=off target="_blank" style="color: #ffffff; text-decoration: none; text-align: center; cursor: pointer; display: inline-block; border-radius: 5px; background-color: #175DDC; border-color: #175DDC; border-style: solid; border-width: 10px 20px; margin: 0; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; box-sizing: border-box; font-size: 16px; line-height: 25px; -webkit-font-smoothing: antialiased; -webkit-text-size-adjust: none;">
13+
Set Up Business Unit Portal Now
14+
</a>
15+
<br style="margin: 0; box-sizing: border-box; color: #333; line-height: 25px; -webkit-font-smoothing: antialiased; -webkit-text-size-adjust: none;" />
16+
</td>
17+
</tr>
18+
</table>
19+
{{/FullHtmlLayout}}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{{#>BasicTextLayout}}
2+
You have been invited to set up a new Business Unit Portal within Bitwarden. To continue, click the following link:
3+
4+
{{{Url}}}
5+
{{/BasicTextLayout}}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
namespace Bit.Core.Models.Mail.Billing;
2+
3+
public class BusinessUnitConversionInviteModel : BaseMailModel
4+
{
5+
public string OrganizationId { get; set; }
6+
public string Email { get; set; }
7+
public string Token { get; set; }
8+
9+
public string Url =>
10+
$"{WebVaultUrl}/providers/setup-business-unit?organizationId={OrganizationId}&email={Email}&token={Token}";
11+
}

src/Core/Services/IMailService.cs

+1
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ Task SendInvoiceUpcoming(
7070
Task SendEnqueuedMailMessageAsync(IMailQueueMessage queueMessage);
7171
Task SendAdminResetPasswordEmailAsync(string email, string userName, string orgName);
7272
Task SendProviderSetupInviteEmailAsync(Provider provider, string token, string email);
73+
Task SendBusinessUnitConversionInviteAsync(Organization organization, string token, string email);
7374
Task SendProviderInviteEmailAsync(string providerName, ProviderUser providerUser, string token, string email);
7475
Task SendProviderConfirmedEmailAsync(string providerName, string email);
7576
Task SendProviderUserRemoved(string providerName, string email);

src/Core/Services/Implementations/HandlebarsMailService.cs

+17
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
using Bit.Core.Entities;
1212
using Bit.Core.Models.Data.Organizations;
1313
using Bit.Core.Models.Mail;
14+
using Bit.Core.Models.Mail.Billing;
1415
using Bit.Core.Models.Mail.FamiliesForEnterprise;
1516
using Bit.Core.Models.Mail.Provider;
1617
using Bit.Core.SecretsManager.Models.Mail;
@@ -951,6 +952,22 @@ public async Task SendProviderSetupInviteEmailAsync(Provider provider, string to
951952
await _mailDeliveryService.SendEmailAsync(message);
952953
}
953954

955+
public async Task SendBusinessUnitConversionInviteAsync(Organization organization, string token, string email)
956+
{
957+
var message = CreateDefaultMessage("Set Up Business Unit", email);
958+
var model = new BusinessUnitConversionInviteModel
959+
{
960+
WebVaultUrl = _globalSettings.BaseServiceUri.VaultWithHash,
961+
SiteName = _globalSettings.SiteName,
962+
OrganizationId = organization.Id.ToString(),
963+
Email = WebUtility.UrlEncode(email),
964+
Token = WebUtility.UrlEncode(token)
965+
};
966+
await AddMessageContentAsync(message, "Billing.BusinessUnitConversionInvite", model);
967+
message.Category = "BusinessUnitConversionInvite";
968+
await _mailDeliveryService.SendEmailAsync(message);
969+
}
970+
954971
public async Task SendProviderInviteEmailAsync(string providerName, ProviderUser providerUser, string token, string email)
955972
{
956973
var message = CreateDefaultMessage($"Join {providerName}", email);

src/Core/Services/NoopImplementations/NoopMailService.cs

+5
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,11 @@ public Task SendProviderSetupInviteEmailAsync(Provider provider, string token, s
212212
return Task.FromResult(0);
213213
}
214214

215+
public Task SendBusinessUnitConversionInviteAsync(Organization organization, string token, string email)
216+
{
217+
return Task.FromResult(0);
218+
}
219+
215220
public Task SendProviderInviteEmailAsync(string providerName, ProviderUser providerUser, string token, string email)
216221
{
217222
return Task.FromResult(0);

0 commit comments

Comments
 (0)