summaryrefslogtreecommitdiff
path: root/src/SMAPI.Web/Framework/Clients/UpdateManifest/ResponseModels
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2023-01-29 16:37:23 -0500
committerJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2023-01-29 16:37:23 -0500
commit3eb98b565f48c26384f0e83e4012fc9b40f1d819 (patch)
treef88ae302c3b0913228fb18dcd2a2babf14134ada /src/SMAPI.Web/Framework/Clients/UpdateManifest/ResponseModels
parent610e2722c6687591faacb942d6f752c5f3c620d7 (diff)
downloadSMAPI-3eb98b565f48c26384f0e83e4012fc9b40f1d819.tar.gz
SMAPI-3eb98b565f48c26384f0e83e4012fc9b40f1d819.tar.bz2
SMAPI-3eb98b565f48c26384f0e83e4012fc9b40f1d819.zip
simplify & validate manifest mod page URLs
This avoids an issue where users are told to download it from the JSON manifest URL.
Diffstat (limited to 'src/SMAPI.Web/Framework/Clients/UpdateManifest/ResponseModels')
-rw-r--r--src/SMAPI.Web/Framework/Clients/UpdateManifest/ResponseModels/UpdateManifestModModel.cs14
-rw-r--r--src/SMAPI.Web/Framework/Clients/UpdateManifest/ResponseModels/UpdateManifestModel.cs6
-rw-r--r--src/SMAPI.Web/Framework/Clients/UpdateManifest/ResponseModels/UpdateManifestVersionModel.cs15
3 files changed, 16 insertions, 19 deletions
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
{
/// <summary>The data model for a mod in an update manifest file.</summary>
@@ -11,10 +13,10 @@ namespace StardewModdingAPI.Web.Framework.Clients.UpdateManifest.ResponseModels
public string? Name { get; }
/// <summary>The mod page URL from which to download updates.</summary>
- public string? Url { get; }
+ public string? ModPageUrl { get; }
/// <summary>The available versions for this mod.</summary>
- public UpdateManifestVersionModel[]? Versions { get; }
+ public UpdateManifestVersionModel[] Versions { get; }
/*********
@@ -22,13 +24,13 @@ namespace StardewModdingAPI.Web.Framework.Clients.UpdateManifest.ResponseModels
*********/
/// <summary>Construct an instance.</summary>
/// <param name="name">The mod's name.</param>
- /// <param name="url">The mod page URL from which to download updates.</param>
+ /// <param name="modPageUrl">The mod page URL from which to download updates.</param>
/// <param name="versions">The available versions for this mod.</param>
- 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<UpdateManifestVersionModel>();
}
}
}
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; }
/// <summary>The mod info in this update manifest.</summary>
- public IDictionary<string, UpdateManifestModModel>? Mods { get; }
+ public IDictionary<string, UpdateManifestModModel> Mods { get; }
/*********
@@ -22,10 +22,10 @@ namespace StardewModdingAPI.Web.Framework.Clients.UpdateManifest.ResponseModels
/// <summary>Construct an instance.</summary>
/// <param name="format">The manifest format version.</param>
/// <param name="mods">The mod info in this update manifest.</param>
- public UpdateManifestModel(string format, IDictionary<string, UpdateManifestModModel> mods)
+ public UpdateManifestModel(string format, IDictionary<string, UpdateManifestModModel>? mods)
{
this.Format = format;
- this.Mods = mods;
+ this.Mods = mods ?? new Dictionary<string, UpdateManifestModModel>();
}
}
}
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
/// <summary>The mod's semantic version.</summary>
public string? Version { get; }
- /// <summary>The URL for this version's download page (if any).</summary>
- public string? DownloadPageUrl { get; }
-
- /// <summary>The URL for this version's direct file download (if any).</summary>
- public string? DownloadFileUrl { get; }
+ /// <summary>The mod page URL from which to download updates, if different from <see cref="UpdateManifestModModel.ModPageUrl"/>.</summary>
+ public string? ModPageUrl { get; }
/*********
@@ -22,13 +19,11 @@ namespace StardewModdingAPI.Web.Framework.Clients.UpdateManifest.ResponseModels
*********/
/// <summary>Construct an instance.</summary>
/// <param name="version">The mod's semantic version.</param>
- /// <param name="downloadPageUrl">This version's download page URL, if any.</param>
- /// <param name="downloadFileUrl">This version's direct file download URL, if any.</param>
- public UpdateManifestVersionModel(string version, string? downloadPageUrl, string? downloadFileUrl)
+ /// <param name="modPageUrl">The mod page URL from which to download updates, if different from <see cref="UpdateManifestModModel.ModPageUrl"/>.</param>
+ public UpdateManifestVersionModel(string version, string? modPageUrl)
{
this.Version = version;
- this.DownloadPageUrl = downloadPageUrl;
- this.DownloadFileUrl = downloadFileUrl;
+ this.ModPageUrl = modPageUrl;
}
}
}