From 6c9071b22b9405d44268244a937d26d385cbf5d4 Mon Sep 17 00:00:00 2001 From: Glax Date: Wed, 28 Feb 2024 02:32:36 +0100 Subject: [PATCH] Reset UserAgent --- Tranga/Server.cs | 4 ++++ Tranga/TrangaSettings.cs | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Tranga/Server.cs b/Tranga/Server.cs index 2f94991..c1d7fbb 100644 --- a/Tranga/Server.cs +++ b/Tranga/Server.cs @@ -423,6 +423,10 @@ public class Server : GlobalBase settings.UpdateUserAgent(customUserAgent); SendResponse(HttpStatusCode.Accepted, response); break; + case "Settings/userAgent/Reset": + settings.UpdateUserAgent(null); + SendResponse(HttpStatusCode.Accepted, response); + break; case "Settings/customRequestLimit": if (!requestVariables.TryGetValue("requestType", out string? requestTypeStr) || !requestVariables.TryGetValue("requestsPerMinute", out string? requestsPerMinuteStr) || diff --git a/Tranga/TrangaSettings.cs b/Tranga/TrangaSettings.cs index 534e357..4fae2fb 100644 --- a/Tranga/TrangaSettings.cs +++ b/Tranga/TrangaSettings.cs @@ -129,9 +129,9 @@ public class TrangaSettings ExportSettings(); } - public void UpdateUserAgent(string customUserAgent) + public void UpdateUserAgent(string? customUserAgent) { - this.userAgent = customUserAgent.Length < 1 ? DefaultUserAgent : customUserAgent; + this.userAgent = customUserAgent ?? DefaultUserAgent; ExportSettings(); }