summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/SMAPI.Web/Controllers/LogParserController.cs2
-rw-r--r--src/SMAPI.Web/Framework/ConfigModels/LogParserConfig.cs3
-rw-r--r--src/SMAPI.Web/Framework/LogParser/PastebinClient.cs17
-rw-r--r--src/SMAPI.Web/appsettings.Development.json1
-rw-r--r--src/SMAPI.Web/appsettings.json1
5 files changed, 18 insertions, 6 deletions
diff --git a/src/SMAPI.Web/Controllers/LogParserController.cs b/src/SMAPI.Web/Controllers/LogParserController.cs
index f9943707..8e986196 100644
--- a/src/SMAPI.Web/Controllers/LogParserController.cs
+++ b/src/SMAPI.Web/Controllers/LogParserController.cs
@@ -35,7 +35,7 @@ namespace StardewModdingAPI.Web.Controllers
this.Config = configProvider.Value;
string version = this.GetType().Assembly.GetName().Version.ToString(3);
string userAgent = string.Format(this.Config.PastebinUserAgent, version);
- this.PastebinClient = new PastebinClient(this.Config.PastebinBaseUrl, userAgent, this.Config.PastebinDevKey);
+ this.PastebinClient = new PastebinClient(this.Config.PastebinBaseUrl, userAgent, this.Config.PastebinUserKey, this.Config.PastebinDevKey);
}
/***
diff --git a/src/SMAPI.Web/Framework/ConfigModels/LogParserConfig.cs b/src/SMAPI.Web/Framework/ConfigModels/LogParserConfig.cs
index 18d8ff05..df5d605d 100644
--- a/src/SMAPI.Web/Framework/ConfigModels/LogParserConfig.cs
+++ b/src/SMAPI.Web/Framework/ConfigModels/LogParserConfig.cs
@@ -15,6 +15,9 @@ namespace StardewModdingAPI.Web.Framework.ConfigModels
/// <summary>The user agent for the Pastebin API client, where {0} is the SMAPI version.</summary>
public string PastebinUserAgent { get; set; }
+ /// <summary>The user key used to authenticate with the Pastebin API.</summary>
+ public string PastebinUserKey { get; set; }
+
/// <summary>The developer key used to authenticate with the Pastebin API.</summary>
public string PastebinDevKey { get; set; }
}
diff --git a/src/SMAPI.Web/Framework/LogParser/PastebinClient.cs b/src/SMAPI.Web/Framework/LogParser/PastebinClient.cs
index e45a9eed..738330d3 100644
--- a/src/SMAPI.Web/Framework/LogParser/PastebinClient.cs
+++ b/src/SMAPI.Web/Framework/LogParser/PastebinClient.cs
@@ -17,6 +17,9 @@ namespace StardewModdingAPI.Web.Framework.LogParser
/// <summary>The underlying HTTP client.</summary>
private readonly IClient Client;
+ /// <summary>The user key used to authenticate with the Pastebin API.</summary>
+ private readonly string UserKey;
+
/// <summary>The developer key used to authenticate with the Pastebin API.</summary>
private readonly string DevKey;
@@ -27,10 +30,12 @@ namespace StardewModdingAPI.Web.Framework.LogParser
/// <summary>Construct an instance.</summary>
/// <param name="baseUrl">The base URL for the Pastebin API.</param>
/// <param name="userAgent">The user agent for the API client.</param>
+ /// <param name="userKey">The user key used to authenticate with the Pastebin API.</param>
/// <param name="devKey">The developer key used to authenticate with the Pastebin API.</param>
- public PastebinClient(string baseUrl, string userAgent, string devKey)
+ public PastebinClient(string baseUrl, string userAgent, string userKey, string devKey)
{
this.Client = new FluentClient(baseUrl).SetUserAgent(userAgent);
+ this.UserKey = userKey;
this.DevKey = devKey;
}
@@ -75,11 +80,13 @@ namespace StardewModdingAPI.Web.Framework.LogParser
.PostAsync("api/api_post.php")
.WithBodyContent(new FormUrlEncodedContent(new Dictionary<string, string>
{
- ["api_dev_key"] = this.DevKey,
["api_option"] = "paste",
- ["api_paste_private"] = "1",
- ["api_paste_code"] = content,
- ["api_paste_expire_date"] = "1W"
+ ["api_user_key"] = this.UserKey,
+ ["api_dev_key"] = this.DevKey,
+ ["api_paste_private"] = "1", // unlisted
+ ["api_paste_name"] = $"SMAPI log {DateTime.UtcNow:s}",
+ ["api_paste_expire_date"] = "1W", // one week
+ ["api_paste_code"] = content
}))
.AsString();
diff --git a/src/SMAPI.Web/appsettings.Development.json b/src/SMAPI.Web/appsettings.Development.json
index 1080ee00..87c35ca9 100644
--- a/src/SMAPI.Web/appsettings.Development.json
+++ b/src/SMAPI.Web/appsettings.Development.json
@@ -22,6 +22,7 @@
},
"LogParser": {
"SectionUrl": "http://localhost:59482/log/",
+ "PastebinUserKey": null,
"PastebinDevKey": null
}
}
diff --git a/src/SMAPI.Web/appsettings.json b/src/SMAPI.Web/appsettings.json
index 397765eb..eb6ecc9b 100644
--- a/src/SMAPI.Web/appsettings.json
+++ b/src/SMAPI.Web/appsettings.json
@@ -39,6 +39,7 @@
"SectionUrl": null, // see top note
"PastebinBaseUrl": "https://pastebin.com/",
"PastebinUserAgent": "SMAPI/{0} (+https://github.com/Pathoschild/SMAPI)",
+ "PastebinUserKey": null, // see top note
"PastebinDevKey": null // see top note
}
}