New: Add ValueHash for hidden API keys via the API

This commit is contained in:
Bogdan 2023-07-23 00:26:56 +03:00
parent dee8820b1f
commit d86d78954e
2 changed files with 8 additions and 1 deletions

View File

@ -13,6 +13,7 @@ namespace Sonarr.Http.ClientSchema
public string HelpTextWarning { get; set; }
public string HelpLink { get; set; }
public object Value { get; set; }
public string ValueHash { get; set; }
public string Type { get; set; }
public bool Advanced { get; set; }
public List<SelectOption> SelectOptions { get; set; }

View File

@ -7,6 +7,7 @@ using NzbDrone.Common.EnsureThat;
using NzbDrone.Common.Extensions;
using NzbDrone.Common.Reflection;
using NzbDrone.Common.Serializer;
using NzbDrone.Core;
using NzbDrone.Core.Annotations;
namespace Sonarr.Http.ClientSchema
@ -30,8 +31,13 @@ namespace Sonarr.Http.ClientSchema
field.Value = mapping.GetterFunc(model);
if (field.Value != null && !field.Value.Equals(string.Empty) &&
(field.Privacy == PrivacyLevel.ApiKey || field.Privacy == PrivacyLevel.Password))
field.Privacy is PrivacyLevel.ApiKey or PrivacyLevel.Password)
{
if (field.Privacy == PrivacyLevel.ApiKey)
{
field.ValueHash = field.Value.ToString()?.SHA256Hash()?.AsSpan(0, 6).ToString();
}
field.Value = PRIVATE_VALUE;
}