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:
@@ -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() ?? "";
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user