1
0
mirror of https://github.com/bitwarden/server synced 2025-12-14 23:33:41 +00:00

[PM 19727] Update InvoiceUpcoming email content (#6168)

* changes to implement the email

* Refactoring and fix the unit testing

* refactor the code and remove used method

* Fix the failing test

* Update the email templates

* remove the extra space here

* Refactor the descriptions

* Fix the wrong subject header

* Add the in the hyperlink rather than just Help center
This commit is contained in:
cyprain-okeke
2025-09-03 20:33:32 +05:30
committed by GitHub
parent 1dade9d4b8
commit fa8d65cc1f
10 changed files with 914 additions and 1 deletions

View File

@@ -478,6 +478,33 @@ public class HandlebarsMailService : IMailService
await _mailDeliveryService.SendEmailAsync(message);
}
public async Task SendProviderInvoiceUpcoming(
IEnumerable<string> emails,
decimal amount,
DateTime dueDate,
List<string> items,
string? collectionMethod = null,
bool hasPaymentMethod = true,
string? paymentMethodDescription = null)
{
var message = CreateDefaultMessage("Your upcoming Bitwarden invoice", emails);
var model = new InvoiceUpcomingViewModel
{
WebVaultUrl = _globalSettings.BaseServiceUri.VaultWithHash,
SiteName = _globalSettings.SiteName,
AmountDue = amount,
DueDate = dueDate,
Items = items,
MentionInvoices = false,
CollectionMethod = collectionMethod,
HasPaymentMethod = hasPaymentMethod,
PaymentMethodDescription = paymentMethodDescription
};
await AddMessageContentAsync(message, "ProviderInvoiceUpcoming", model);
message.Category = "ProviderInvoiceUpcoming";
await _mailDeliveryService.SendEmailAsync(message);
}
public async Task SendPaymentFailedAsync(string email, decimal amount, bool mentionInvoices)
{
var message = CreateDefaultMessage("Payment Failed", email);
@@ -708,6 +735,8 @@ public class HandlebarsMailService : IMailService
Handlebars.RegisterTemplate("SecurityTasksHtmlLayout", securityTasksHtmlLayoutSource);
var securityTasksTextLayoutSource = await ReadSourceAsync("Layouts.SecurityTasks.text");
Handlebars.RegisterTemplate("SecurityTasksTextLayout", securityTasksTextLayoutSource);
var providerFullHtmlLayoutSource = await ReadSourceAsync("Layouts.ProviderFull.html");
Handlebars.RegisterTemplate("ProviderFull", providerFullHtmlLayoutSource);
Handlebars.RegisterHelper("date", (writer, context, parameters) =>
{
@@ -863,6 +892,19 @@ public class HandlebarsMailService : IMailService
writer.WriteSafeString(string.Empty);
}
});
// Equality comparison helper for conditional templates.
Handlebars.RegisterHelper("eq", (context, arguments) =>
{
if (arguments.Length != 2)
{
return false;
}
var value1 = arguments[0]?.ToString();
var value2 = arguments[1]?.ToString();
return string.Equals(value1, value2, StringComparison.OrdinalIgnoreCase);
});
}
public async Task SendEmergencyAccessInviteEmailAsync(EmergencyAccess emergencyAccess, string name, string token)