1
0
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:
Nick Krantz
2025-04-02 15:18:53 -05:00
committed by GitHub
parent aef05f5fb6
commit 7b2b62e794
4 changed files with 26 additions and 10 deletions

View File

@ -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)