1
0
mirror of https://github.com/bitwarden/server synced 2025-12-13 06:43:45 +00:00

Alter Integration Template processing to remove keys when encountering null values (#6309)

This commit is contained in:
Brant DeBow
2025-09-10 14:17:45 -04:00
committed by GitHub
parent a458db319e
commit e57569ad57
4 changed files with 114 additions and 22 deletions

View File

@@ -1,6 +1,5 @@
#nullable enable
using System.Text.Json;
using System.Text.RegularExpressions;
namespace Bit.Core.AdminConsole.Utilities;
@@ -20,15 +19,14 @@ public static partial class IntegrationTemplateProcessor
return TokenRegex().Replace(template, match =>
{
var propertyName = match.Groups[1].Value;
if (propertyName == "EventMessage")
var property = type.GetProperty(propertyName);
if (property == null)
{
return JsonSerializer.Serialize(values);
}
else
{
var property = type.GetProperty(propertyName);
return property?.GetValue(values)?.ToString() ?? match.Value;
return match.Value; // Return unknown keys as keys - i.e. #Key#
}
return property?.GetValue(values)?.ToString() ?? "";
});
}