summaryrefslogtreecommitdiff
path: root/src/SMAPI.Web
diff options
context:
space:
mode:
Diffstat (limited to 'src/SMAPI.Web')
-rw-r--r--src/SMAPI.Web/Framework/Clients/Nexus/NexusMod.cs4
-rw-r--r--src/SMAPI.Web/Framework/Clients/Nexus/NexusModStatus.cs18
-rw-r--r--src/SMAPI.Web/Framework/Clients/Nexus/NexusWebScrapeClient.cs8
-rw-r--r--src/SMAPI.Web/Framework/ModRepositories/NexusRepository.cs8
4 files changed, 36 insertions, 2 deletions
diff --git a/src/SMAPI.Web/Framework/Clients/Nexus/NexusMod.cs b/src/SMAPI.Web/Framework/Clients/Nexus/NexusMod.cs
index f4909155..0f1b29d5 100644
--- a/src/SMAPI.Web/Framework/Clients/Nexus/NexusMod.cs
+++ b/src/SMAPI.Web/Framework/Clients/Nexus/NexusMod.cs
@@ -21,6 +21,10 @@ namespace StardewModdingAPI.Web.Framework.Clients.Nexus
[JsonProperty("mod_page_uri")]
public string Url { get; set; }
+ /// <summary>The mod's publication status.</summary>
+ [JsonIgnore]
+ public NexusModStatus Status { get; set; } = NexusModStatus.Ok;
+
/// <summary>A user-friendly error which indicates why fetching the mod info failed (if applicable).</summary>
[JsonIgnore]
public string Error { get; set; }
diff --git a/src/SMAPI.Web/Framework/Clients/Nexus/NexusModStatus.cs b/src/SMAPI.Web/Framework/Clients/Nexus/NexusModStatus.cs
new file mode 100644
index 00000000..c5723093
--- /dev/null
+++ b/src/SMAPI.Web/Framework/Clients/Nexus/NexusModStatus.cs
@@ -0,0 +1,18 @@
+namespace StardewModdingAPI.Web.Framework.Clients.Nexus
+{
+ /// <summary>The status of a Nexus mod.</summary>
+ internal enum NexusModStatus
+ {
+ /// <summary>The mod is published and valid.</summary>
+ Ok,
+
+ /// <summary>The mod is hidden by the author.</summary>
+ Hidden,
+
+ /// <summary>The mod hasn't been published yet.</summary>
+ NotPublished,
+
+ /// <summary>The Nexus API returned an unhandled error.</summary>
+ Other
+ }
+}
diff --git a/src/SMAPI.Web/Framework/Clients/Nexus/NexusWebScrapeClient.cs b/src/SMAPI.Web/Framework/Clients/Nexus/NexusWebScrapeClient.cs
index e83a6041..061de5de 100644
--- a/src/SMAPI.Web/Framework/Clients/Nexus/NexusWebScrapeClient.cs
+++ b/src/SMAPI.Web/Framework/Clients/Nexus/NexusWebScrapeClient.cs
@@ -74,8 +74,14 @@ namespace StardewModdingAPI.Web.Framework.Clients.Nexus
case "not found":
return null;
+ case "hidden mod":
+ return new NexusMod { Error = $"Nexus error: {errorCode} ({errorText}).", Status = NexusModStatus.Hidden };
+
+ case "not published":
+ return new NexusMod { Error = $"Nexus error: {errorCode} ({errorText}).", Status = NexusModStatus.NotPublished };
+
default:
- return new NexusMod { Error = $"Nexus error: {errorCode} ({errorText})." };
+ return new NexusMod { Error = $"Nexus error: {errorCode} ({errorText}).", Status = NexusModStatus.Other };
}
}
diff --git a/src/SMAPI.Web/Framework/ModRepositories/NexusRepository.cs b/src/SMAPI.Web/Framework/ModRepositories/NexusRepository.cs
index 9679f93e..a4ae61eb 100644
--- a/src/SMAPI.Web/Framework/ModRepositories/NexusRepository.cs
+++ b/src/SMAPI.Web/Framework/ModRepositories/NexusRepository.cs
@@ -41,7 +41,13 @@ namespace StardewModdingAPI.Web.Framework.ModRepositories
if (mod == null)
return new ModInfoModel().WithError(RemoteModStatus.DoesNotExist, "Found no Nexus mod with this ID.");
if (mod.Error != null)
- return new ModInfoModel().WithError(RemoteModStatus.TemporaryError, mod.Error);
+ {
+ RemoteModStatus remoteStatus = mod.Status == NexusModStatus.Hidden || mod.Status == NexusModStatus.NotPublished
+ ? RemoteModStatus.DoesNotExist
+ : RemoteModStatus.TemporaryError;
+ return new ModInfoModel().WithError(remoteStatus, mod.Error);
+ }
+
return new ModInfoModel(name: mod.Name, version: this.NormaliseVersion(mod.Version), previewVersion: mod.LatestFileVersion?.ToString(), url: mod.Url);
}
catch (Exception ex)