fix: parse current Portal URLS for system and template UUIDs correctly

This commit is contained in:
Andrew Welker
2025-11-12 16:58:23 -06:00
parent c55de61da9
commit 2c49fb9321

View File

@@ -11,11 +11,11 @@ using PepperDash.Core;
namespace PepperDash.Essentials.Core.Config namespace PepperDash.Essentials.Core.Config
{ {
/// <summary> /// <summary>
/// Loads the ConfigObject from the file /// Loads the ConfigObject from the file
/// </summary> /// </summary>
public class EssentialsConfig : BasicConfig public class EssentialsConfig : BasicConfig
{ {
/// <summary> /// <summary>
/// Gets or sets the SystemUrl /// Gets or sets the SystemUrl
/// </summary> /// </summary>
@@ -32,21 +32,22 @@ namespace PepperDash.Essentials.Core.Config
/// Gets the SystemUuid extracted from the SystemUrl /// Gets the SystemUuid extracted from the SystemUrl
/// </summary> /// </summary>
[JsonProperty("systemUuid")] [JsonProperty("systemUuid")]
public string SystemUuid public string SystemUuid
{ {
get get
{ {
if (string.IsNullOrEmpty(SystemUrl)) if (string.IsNullOrEmpty(SystemUrl))
return "missing url"; return "missing url";
if (SystemUrl.Contains("#")) if (SystemUrl.Contains("#"))
{ {
var result = Regex.Match(SystemUrl, @"https?:\/\/.*\/systems\/(.*)\/#.*"); var result = Regex.Match(SystemUrl, @"https?:\/\/.*\/systems\/(.*)\/#.*");
string uuid = result.Groups[1].Value; string uuid = result.Groups[1].Value;
return uuid; return uuid;
} else }
{ else
var result = Regex.Match(SystemUrl, @"https?:\/\/.*\/systems\/(.*)\/.*"); {
var result = Regex.Match(SystemUrl, @"https?:\/\/.*\/systems\/detail\/(.*)\/.*");
string uuid = result.Groups[1].Value; string uuid = result.Groups[1].Value;
return uuid; return uuid;
} }
@@ -57,21 +58,22 @@ namespace PepperDash.Essentials.Core.Config
/// Gets the TemplateUuid extracted from the TemplateUrl /// Gets the TemplateUuid extracted from the TemplateUrl
/// </summary> /// </summary>
[JsonProperty("templateUuid")] [JsonProperty("templateUuid")]
public string TemplateUuid public string TemplateUuid
{ {
get get
{ {
if (string.IsNullOrEmpty(TemplateUrl)) if (string.IsNullOrEmpty(TemplateUrl))
return "missing template url"; return "missing template url";
if (TemplateUrl.Contains("#")) if (TemplateUrl.Contains("#"))
{ {
var result = Regex.Match(TemplateUrl, @"https?:\/\/.*\/templates\/(.*)\/#.*"); var result = Regex.Match(TemplateUrl, @"https?:\/\/.*\/templates\/(.*)\/#.*");
string uuid = result.Groups[1].Value; string uuid = result.Groups[1].Value;
return uuid; return uuid;
} else }
{ else
var result = Regex.Match(TemplateUrl, @"https?:\/\/.*\/system-templates\/(.*)\/system-template-versions\/(.*)\/.*"); {
var result = Regex.Match(TemplateUrl, @"https?:\/\/.*\/system-templates\/detail\/(.*)\/system-template-versions\/detail\/(.*)\/.*");
string uuid = result.Groups[2].Value; string uuid = result.Groups[2].Value;
return uuid; return uuid;
} }
@@ -97,7 +99,7 @@ namespace PepperDash.Essentials.Core.Config
{ {
Rooms = new List<DeviceConfig>(); Rooms = new List<DeviceConfig>();
} }
} }
/// <summary> /// <summary>
/// Represents version data for Essentials and its packages /// Represents version data for Essentials and its packages
@@ -147,7 +149,7 @@ namespace PepperDash.Essentials.Core.Config
/// Represents a SystemTemplateConfigs /// Represents a SystemTemplateConfigs
/// </summary> /// </summary>
public class SystemTemplateConfigs public class SystemTemplateConfigs
{ {
/// <summary> /// <summary>
/// Gets or sets the System /// Gets or sets the System
/// </summary> /// </summary>
@@ -157,5 +159,5 @@ namespace PepperDash.Essentials.Core.Config
/// Gets or sets the Template /// Gets or sets the Template
/// </summary> /// </summary>
public EssentialsConfig Template { get; set; } public EssentialsConfig Template { get; set; }
} }
} }