diff options
author | Jesse Plamondon-Willard <Pathoschild@users.noreply.github.com> | 2021-11-27 23:59:13 -0500 |
---|---|---|
committer | Jesse Plamondon-Willard <Pathoschild@users.noreply.github.com> | 2021-11-27 23:59:13 -0500 |
commit | 3ca6fb562417748c87567d6bb6915d56b2c1b57c (patch) | |
tree | 207953024f9d79b52af2b5b9a384a3e3bc57b556 /src/SMAPI.Web | |
parent | b64cec918d1511b6b71c9d2e30f987e9b5cc24fd (diff) | |
download | SMAPI-3ca6fb562417748c87567d6bb6915d56b2c1b57c.tar.gz SMAPI-3ca6fb562417748c87567d6bb6915d56b2c1b57c.tar.bz2 SMAPI-3ca6fb562417748c87567d6bb6915d56b2c1b57c.zip |
automatically include beta versions on Nexus for SMAPI update checks
Diffstat (limited to 'src/SMAPI.Web')
-rw-r--r-- | src/SMAPI.Web/Controllers/ModsApiController.cs | 7 | ||||
-rw-r--r-- | src/SMAPI.Web/Framework/ConfigModels/ModUpdateCheckConfig.cs | 3 | ||||
-rw-r--r-- | src/SMAPI.Web/Framework/ConfigModels/SmapiInfoConfig.cs | 15 | ||||
-rw-r--r-- | src/SMAPI.Web/appsettings.json | 7 |
4 files changed, 31 insertions, 1 deletions
diff --git a/src/SMAPI.Web/Controllers/ModsApiController.cs b/src/SMAPI.Web/Controllers/ModsApiController.cs index dcddaf10..37d763cc 100644 --- a/src/SMAPI.Web/Controllers/ModsApiController.cs +++ b/src/SMAPI.Web/Controllers/ModsApiController.cs @@ -81,6 +81,8 @@ namespace StardewModdingAPI.Web.Controllers if (model?.Mods == null) return new ModEntryModel[0]; + ModUpdateCheckConfig config = this.Config.Value; + // fetch wiki data WikiModEntry[] wikiData = this.WikiCache.GetWikiMods().Select(p => p.Data).ToArray(); IDictionary<string, ModEntryModel> mods = new Dictionary<string, ModEntryModel>(StringComparer.CurrentCultureIgnoreCase); @@ -89,6 +91,11 @@ namespace StardewModdingAPI.Web.Controllers if (string.IsNullOrWhiteSpace(mod.ID)) continue; + // special case: if this is an update check for the official SMAPI repo, check the Nexus mod page for beta versions + if (mod.ID == config.SmapiInfo.ID && mod.UpdateKeys?.Any(key => key == config.SmapiInfo.DefaultUpdateKey) == true && mod.InstalledVersion?.IsPrerelease() == true) + mod.UpdateKeys = mod.UpdateKeys.Concat(config.SmapiInfo.AddBetaUpdateKeys).ToArray(); + + // fetch result ModEntryModel result = await this.GetModData(mod, wikiData, model.IncludeExtendedMetadata, model.ApiVersion); if (!model.IncludeExtendedMetadata && (model.ApiVersion == null || mod.InstalledVersion == null)) { diff --git a/src/SMAPI.Web/Framework/ConfigModels/ModUpdateCheckConfig.cs b/src/SMAPI.Web/Framework/ConfigModels/ModUpdateCheckConfig.cs index bd58dba0..aea695b8 100644 --- a/src/SMAPI.Web/Framework/ConfigModels/ModUpdateCheckConfig.cs +++ b/src/SMAPI.Web/Framework/ConfigModels/ModUpdateCheckConfig.cs @@ -14,5 +14,8 @@ namespace StardewModdingAPI.Web.Framework.ConfigModels /// <summary>Update-check metadata to override.</summary> public ModOverrideConfig[] ModOverrides { get; set; } + + /// <summary>The update-check config for SMAPI's own update checks.</summary> + public SmapiInfoConfig SmapiInfo { get; set; } } } diff --git a/src/SMAPI.Web/Framework/ConfigModels/SmapiInfoConfig.cs b/src/SMAPI.Web/Framework/ConfigModels/SmapiInfoConfig.cs new file mode 100644 index 00000000..d69fabb3 --- /dev/null +++ b/src/SMAPI.Web/Framework/ConfigModels/SmapiInfoConfig.cs @@ -0,0 +1,15 @@ +namespace StardewModdingAPI.Web.Framework.ConfigModels +{ + /// <summary>The update-check config for SMAPI's own update checks.</summary> + internal class SmapiInfoConfig + { + /// <summary>The mod ID used for SMAPI update checks.</summary> + public string ID { get; set; } + + /// <summary>The default update key used for SMAPI update checks.</summary> + public string DefaultUpdateKey { get; set; } + + /// <summary>The update keys to add for SMAPI update checks when the player has a beta version installed.</summary> + public string[] AddBetaUpdateKeys { get; set; } + } +} diff --git a/src/SMAPI.Web/appsettings.json b/src/SMAPI.Web/appsettings.json index 1837170b..0265a928 100644 --- a/src/SMAPI.Web/appsettings.json +++ b/src/SMAPI.Web/appsettings.json @@ -75,6 +75,11 @@ "ID": "MartyrPher.SMAPI-Android-Installer", "AllowNonStandardVersions": true } - ] + ], + "SmapiInfo": { + "ID": "Pathoschild.SMAPI", + "DefaultUpdateKey": "GitHub:Pathoschild/SMAPI", + "AddBetaUpdateKeys": [ "Nexus:2400" ] + } } } |