feat: import/export settings, send backup of settings when leaving guild
This commit is contained in:
parent
e6d68338db
commit
db5d7bb4f8
18 changed files with 392 additions and 39 deletions
|
|
@ -14,13 +14,9 @@
|
|||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
using System.Net;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
using System.Threading.RateLimiting;
|
||||
using Humanizer;
|
||||
using NodaTime;
|
||||
using NodaTime.Serialization.SystemTextJson;
|
||||
using NodaTime.Text;
|
||||
using Polly;
|
||||
|
||||
namespace Catalogger.Backend.Services;
|
||||
|
|
@ -32,17 +28,6 @@ public class PluralkitApiService(ILogger logger)
|
|||
private readonly HttpClient _client = new();
|
||||
private readonly ILogger _logger = logger.ForContext<PluralkitApiService>();
|
||||
|
||||
private readonly JsonSerializerOptions _jsonOptions = new JsonSerializerOptions
|
||||
{
|
||||
PropertyNamingPolicy = JsonNamingPolicy.SnakeCaseLower,
|
||||
NumberHandling = JsonNumberHandling.AllowReadingFromString,
|
||||
}.ConfigureForNodaTime(
|
||||
new NodaJsonSettings
|
||||
{
|
||||
InstantConverter = new NodaPatternConverter<Instant>(InstantPattern.ExtendedIso),
|
||||
}
|
||||
);
|
||||
|
||||
private readonly ResiliencePipeline _pipeline = new ResiliencePipelineBuilder()
|
||||
.AddRateLimiter(
|
||||
new FixedWindowRateLimiter(
|
||||
|
|
@ -86,7 +71,7 @@ public class PluralkitApiService(ILogger logger)
|
|||
throw new CataloggerError("Non-200 status code from PluralKit API");
|
||||
}
|
||||
|
||||
return await resp.Content.ReadFromJsonAsync<T>(_jsonOptions, ct)
|
||||
return await resp.Content.ReadFromJsonAsync<T>(JsonUtils.ApiJsonOptions, ct)
|
||||
?? throw new CataloggerError("JSON response from PluralKit API was null");
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue