From 790a62920b15f1f948724f5b2a70a937829355dd Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sat, 28 Oct 2017 14:05:29 -0400 Subject: link pastes to Pastebin account & tweak paste options (#358) --- src/SMAPI.Web/Framework/ConfigModels/LogParserConfig.cs | 3 +++ src/SMAPI.Web/Framework/LogParser/PastebinClient.cs | 17 ++++++++++++----- 2 files changed, 15 insertions(+), 5 deletions(-) (limited to 'src/SMAPI.Web/Framework') 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 /// The user agent for the Pastebin API client, where {0} is the SMAPI version. public string PastebinUserAgent { get; set; } + /// The user key used to authenticate with the Pastebin API. + public string PastebinUserKey { get; set; } + /// The developer key used to authenticate with the Pastebin API. 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 /// The underlying HTTP client. private readonly IClient Client; + /// The user key used to authenticate with the Pastebin API. + private readonly string UserKey; + /// The developer key used to authenticate with the Pastebin API. private readonly string DevKey; @@ -27,10 +30,12 @@ namespace StardewModdingAPI.Web.Framework.LogParser /// Construct an instance. /// The base URL for the Pastebin API. /// The user agent for the API client. + /// The user key used to authenticate with the Pastebin API. /// The developer key used to authenticate with the Pastebin API. - 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 { - ["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(); -- cgit