2
0

Fix Settings not returning as JSON

This commit is contained in:
Glax 2024-08-26 12:59:19 +02:00
parent 2d848843d0
commit 6f3bba99b0
2 changed files with 5 additions and 3 deletions

View File

@ -198,7 +198,7 @@ public class Server : GlobalBase
SendResponse(HttpStatusCode.OK, response, _parent.jobBoss.jobs.Where(jjob => jjob is DownloadNewChapters).OrderBy(jjob => ((DownloadNewChapters)jjob).manga.sortName)); SendResponse(HttpStatusCode.OK, response, _parent.jobBoss.jobs.Where(jjob => jjob is DownloadNewChapters).OrderBy(jjob => ((DownloadNewChapters)jjob).manga.sortName));
break; break;
case "Settings": case "Settings":
SendResponse(HttpStatusCode.OK, response, TrangaSettings.Serialize()); SendResponse(HttpStatusCode.OK, response, TrangaSettings.AsJObject());
break; break;
case "Settings/userAgent": case "Settings/userAgent":
SendResponse(HttpStatusCode.OK, response, TrangaSettings.userAgent); SendResponse(HttpStatusCode.OK, response, TrangaSettings.userAgent);

View File

@ -154,7 +154,7 @@ public static class TrangaSettings
File.WriteAllText(settingsFilePath, Serialize()); File.WriteAllText(settingsFilePath, Serialize());
} }
public static string Serialize() public static JObject AsJObject()
{ {
JObject jobj = new JObject(); JObject jobj = new JObject();
jobj.Add("downloadLocation", JToken.FromObject(TrangaSettings.downloadLocation)); jobj.Add("downloadLocation", JToken.FromObject(TrangaSettings.downloadLocation));
@ -164,9 +164,11 @@ public static class TrangaSettings
jobj.Add("aprilFoolsMode", JToken.FromObject(TrangaSettings.aprilFoolsMode)); jobj.Add("aprilFoolsMode", JToken.FromObject(TrangaSettings.aprilFoolsMode));
jobj.Add("version", JToken.FromObject(TrangaSettings.version)); jobj.Add("version", JToken.FromObject(TrangaSettings.version));
jobj.Add("requestLimits", JToken.FromObject(TrangaSettings.requestLimits)); jobj.Add("requestLimits", JToken.FromObject(TrangaSettings.requestLimits));
return jobj.ToString(); return jobj;
} }
public static string Serialize() => AsJObject().ToString();
public static void Deserialize(string serialized) public static void Deserialize(string serialized)
{ {
JObject jobj = JObject.Parse(serialized); JObject jobj = JObject.Parse(serialized);