1
0
mirror of https://github.com/bitwarden/server synced 2025-12-13 14:53:34 +00:00

[PM-17562] Add support for extended properties on event integrations (#5755)

* [PM-17562] Add support for extended properties on event integrations

* Clean up IntegrationEventHandlerBase

* Respond to PR feedback
This commit is contained in:
Brant DeBow
2025-05-05 08:04:59 -04:00
committed by GitHub
parent 9511c26683
commit 75a2da3c4b
7 changed files with 445 additions and 63 deletions

View File

@@ -10,8 +10,9 @@ public static partial class IntegrationTemplateProcessor
public static string ReplaceTokens(string template, object values)
{
if (string.IsNullOrEmpty(template) || values == null)
{
return template;
}
var type = values.GetType();
return TokenRegex().Replace(template, match =>
{
@@ -20,4 +21,36 @@ public static partial class IntegrationTemplateProcessor
return property?.GetValue(values)?.ToString() ?? match.Value;
});
}
public static bool TemplateRequiresUser(string template)
{
if (string.IsNullOrEmpty(template))
{
return false;
}
return template.Contains("#UserName#", StringComparison.Ordinal)
|| template.Contains("#UserEmail#", StringComparison.Ordinal);
}
public static bool TemplateRequiresActingUser(string template)
{
if (string.IsNullOrEmpty(template))
{
return false;
}
return template.Contains("#ActingUserName#", StringComparison.Ordinal)
|| template.Contains("#ActingUserEmail#", StringComparison.Ordinal);
}
public static bool TemplateRequiresOrganization(string template)
{
if (string.IsNullOrEmpty(template))
{
return false;
}
return template.Contains("#OrganizationName#", StringComparison.Ordinal);
}
}