From 3eb98b565f48c26384f0e83e4012fc9b40f1d819 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sun, 29 Jan 2023 16:37:23 -0500 Subject: simplify & validate manifest mod page URLs This avoids an issue where users are told to download it from the JSON manifest URL. --- .../ResponseModels/UpdateManifestModModel.cs | 14 ++++++++------ .../UpdateManifest/ResponseModels/UpdateManifestModel.cs | 6 +++--- .../ResponseModels/UpdateManifestVersionModel.cs | 15 +++++---------- 3 files changed, 16 insertions(+), 19 deletions(-) (limited to 'src/SMAPI.Web/Framework/Clients/UpdateManifest/ResponseModels') diff --git a/src/SMAPI.Web/Framework/Clients/UpdateManifest/ResponseModels/UpdateManifestModModel.cs b/src/SMAPI.Web/Framework/Clients/UpdateManifest/ResponseModels/UpdateManifestModModel.cs index ee1fbeb6..418fb26b 100644 --- a/src/SMAPI.Web/Framework/Clients/UpdateManifest/ResponseModels/UpdateManifestModModel.cs +++ b/src/SMAPI.Web/Framework/Clients/UpdateManifest/ResponseModels/UpdateManifestModModel.cs @@ -1,4 +1,6 @@ // Copyright 2022 Jamie Taylor +using System; + namespace StardewModdingAPI.Web.Framework.Clients.UpdateManifest.ResponseModels { /// The data model for a mod in an update manifest file. @@ -11,10 +13,10 @@ namespace StardewModdingAPI.Web.Framework.Clients.UpdateManifest.ResponseModels public string? Name { get; } /// The mod page URL from which to download updates. - public string? Url { get; } + public string? ModPageUrl { get; } /// The available versions for this mod. - public UpdateManifestVersionModel[]? Versions { get; } + public UpdateManifestVersionModel[] Versions { get; } /********* @@ -22,13 +24,13 @@ namespace StardewModdingAPI.Web.Framework.Clients.UpdateManifest.ResponseModels *********/ /// Construct an instance. /// The mod's name. - /// The mod page URL from which to download updates. + /// The mod page URL from which to download updates. /// The available versions for this mod. - public UpdateManifestModModel(string? name, string? url, UpdateManifestVersionModel[]? versions) + public UpdateManifestModModel(string? name, string? modPageUrl, UpdateManifestVersionModel[]? versions) { this.Name = name; - this.Url = url; - this.Versions = versions; + this.ModPageUrl = modPageUrl; + this.Versions = versions ?? Array.Empty(); } } } diff --git a/src/SMAPI.Web/Framework/Clients/UpdateManifest/ResponseModels/UpdateManifestModel.cs b/src/SMAPI.Web/Framework/Clients/UpdateManifest/ResponseModels/UpdateManifestModel.cs index ff3dccbc..3b930ff3 100644 --- a/src/SMAPI.Web/Framework/Clients/UpdateManifest/ResponseModels/UpdateManifestModel.cs +++ b/src/SMAPI.Web/Framework/Clients/UpdateManifest/ResponseModels/UpdateManifestModel.cs @@ -13,7 +13,7 @@ namespace StardewModdingAPI.Web.Framework.Clients.UpdateManifest.ResponseModels public string Format { get; } /// The mod info in this update manifest. - public IDictionary? Mods { get; } + public IDictionary Mods { get; } /********* @@ -22,10 +22,10 @@ namespace StardewModdingAPI.Web.Framework.Clients.UpdateManifest.ResponseModels /// Construct an instance. /// The manifest format version. /// The mod info in this update manifest. - public UpdateManifestModel(string format, IDictionary mods) + public UpdateManifestModel(string format, IDictionary? mods) { this.Format = format; - this.Mods = mods; + this.Mods = mods ?? new Dictionary(); } } } diff --git a/src/SMAPI.Web/Framework/Clients/UpdateManifest/ResponseModels/UpdateManifestVersionModel.cs b/src/SMAPI.Web/Framework/Clients/UpdateManifest/ResponseModels/UpdateManifestVersionModel.cs index 1e84501f..7cfb0cfc 100644 --- a/src/SMAPI.Web/Framework/Clients/UpdateManifest/ResponseModels/UpdateManifestVersionModel.cs +++ b/src/SMAPI.Web/Framework/Clients/UpdateManifest/ResponseModels/UpdateManifestVersionModel.cs @@ -10,11 +10,8 @@ namespace StardewModdingAPI.Web.Framework.Clients.UpdateManifest.ResponseModels /// The mod's semantic version. public string? Version { get; } - /// The URL for this version's download page (if any). - public string? DownloadPageUrl { get; } - - /// The URL for this version's direct file download (if any). - public string? DownloadFileUrl { get; } + /// The mod page URL from which to download updates, if different from . + public string? ModPageUrl { get; } /********* @@ -22,13 +19,11 @@ namespace StardewModdingAPI.Web.Framework.Clients.UpdateManifest.ResponseModels *********/ /// Construct an instance. /// The mod's semantic version. - /// This version's download page URL, if any. - /// This version's direct file download URL, if any. - public UpdateManifestVersionModel(string version, string? downloadPageUrl, string? downloadFileUrl) + /// The mod page URL from which to download updates, if different from . + public UpdateManifestVersionModel(string version, string? modPageUrl) { this.Version = version; - this.DownloadPageUrl = downloadPageUrl; - this.DownloadFileUrl = downloadFileUrl; + this.ModPageUrl = modPageUrl; } } } -- cgit