feature: #UserDetails[] expression helper ignores hide/obfuscate mode symbols
This commit is contained in:
@@ -8,6 +8,7 @@ using System;
|
|||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace Disco.Services.Expressions
|
namespace Disco.Services.Expressions
|
||||||
@@ -200,19 +201,32 @@ namespace Disco.Services.Expressions
|
|||||||
var detailsService = new DetailsProviderService(Database);
|
var detailsService = new DetailsProviderService(Database);
|
||||||
if (target != null)
|
if (target != null)
|
||||||
{
|
{
|
||||||
|
var detailsTarget = default(User);
|
||||||
if (target is User targetUser)
|
if (target is User targetUser)
|
||||||
{
|
detailsTarget = targetUser;
|
||||||
detailsVariables.Add("UserDetails", new LazyDictionary(() => detailsService.GetDetails(targetUser)));
|
|
||||||
}
|
|
||||||
else if (target is Job targetJob)
|
else if (target is Job targetJob)
|
||||||
{
|
detailsTarget = targetJob.User;
|
||||||
detailsVariables.Add("UserDetails", targetJob.User == null ? (IDictionary<string, string>)new Dictionary<string, string>() : new LazyDictionary(() => detailsService.GetDetails(targetJob.User)));
|
|
||||||
}
|
|
||||||
else if (target is Device targetDevice)
|
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)
|
return new Hashtable(detailsVariables)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user