feature: #UserDetails[] expression helper ignores hide/obfuscate mode symbols

This commit is contained in:
Gary Sharp
2026-01-22 15:20:23 +11:00
parent 2ab765f2d7
commit 834d2f8fae
+21 -7
View File
@@ -8,6 +8,7 @@ using System;
using System.Collections;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
namespace Disco.Services.Expressions
@@ -200,19 +201,32 @@ namespace Disco.Services.Expressions
var detailsService = new DetailsProviderService(Database);
if (target != null)
{
var detailsTarget = default(User);
if (target is User targetUser)
{
detailsVariables.Add("UserDetails", new LazyDictionary(() => detailsService.GetDetails(targetUser)));
}
detailsTarget = targetUser;
else if (target is Job targetJob)
{
detailsVariables.Add("UserDetails", targetJob.User == null ? (IDictionary<string, string>)new Dictionary<string, string>() : new LazyDictionary(() => detailsService.GetDetails(targetJob.User)));
}
detailsTarget = targetJob.User;
else if (target is Device targetDevice)
detailsTarget = targetDevice.AssignedUser;
if (detailsTarget != null)
detailsVariables.Add("UserDetails", new LazyDictionary(() =>
{
detailsVariables.Add("UserDetails", targetDevice.AssignedUser == null ? (IDictionary<string, string>)new Dictionary<string, string>() : new LazyDictionary(() => detailsService.GetDetails(targetDevice.AssignedUser)));
var details = detailsService.GetDetails(detailsTarget);
foreach (var key in details.Keys.ToList())
{
if (key.EndsWith("*") || key.EndsWith("&"))
{
var baseKey = key.Substring(0, key.Length - 1);
if (!details.ContainsKey(baseKey))
details[baseKey] = details[key];
}
}
return details;
}));
else
detailsVariables.Add("UserDetails", new Dictionary<string, string>());
}
return new Hashtable(detailsVariables)
{