mirror of
https://github.com/bitwarden/server.git
synced 2025-07-06 18:42:49 -05:00
[PM-18858] Security Task email plurality (#5588)
* use handlebars helper for plurality of text rather than logic within the template * Remove `TaskCountPlural` - unused
This commit is contained in:
@ -794,6 +794,29 @@ public class HandlebarsMailService : IMailService
|
||||
|
||||
writer.WriteSafeString($"{outputMessage}");
|
||||
});
|
||||
|
||||
// Returns the singular or plural form of a word based on the provided numeric value.
|
||||
Handlebars.RegisterHelper("plurality", (writer, context, parameters) =>
|
||||
{
|
||||
if (parameters.Length != 3)
|
||||
{
|
||||
writer.WriteSafeString(string.Empty);
|
||||
return;
|
||||
}
|
||||
|
||||
var numeric = parameters[0];
|
||||
var singularText = parameters[1].ToString();
|
||||
var pluralText = parameters[2].ToString();
|
||||
|
||||
if (numeric is int number)
|
||||
{
|
||||
writer.WriteSafeString(number == 1 ? singularText : pluralText);
|
||||
}
|
||||
else
|
||||
{
|
||||
writer.WriteSafeString(string.Empty);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public async Task SendEmergencyAccessInviteEmailAsync(EmergencyAccess emergencyAccess, string name, string token)
|
||||
|
Reference in New Issue
Block a user