From 1c1169e5ce36e9b3c882a8c7bb1562bbd0da6ef5 Mon Sep 17 00:00:00 2001 From: glax Date: Thu, 31 Aug 2023 16:02:02 +0200 Subject: [PATCH] Renamed Managers to Connectors --- Tranga/GlobalBase.cs | 6 ++-- Tranga/NotificationConnectors/Gotify.cs | 2 +- Tranga/NotificationConnectors/LunaSea.cs | 2 +- .../NotificationConnector.cs | 8 ++--- .../NotificationManagerJsonConverter.cs | 6 ++-- Tranga/Server.cs | 34 +++++++++---------- 6 files changed, 29 insertions(+), 29 deletions(-) diff --git a/Tranga/GlobalBase.cs b/Tranga/GlobalBase.cs index 063054e..36125fc 100644 --- a/Tranga/GlobalBase.cs +++ b/Tranga/GlobalBase.cs @@ -58,10 +58,10 @@ public abstract class GlobalBase File.WriteAllText(settings.notificationConnectorsFilePath, JsonConvert.SerializeObject(notificationConnectors)); } - protected void DeleteNotificationConnector(NotificationConnector.NotificationManagerType notificationManagerType) + protected void DeleteNotificationConnector(NotificationConnector.NotificationConnectorType notificationConnectorType) { - Log($"Removing {notificationManagerType}"); - notificationConnectors.RemoveWhere(nc => nc.notificationManagerType == notificationManagerType); + Log($"Removing {notificationConnectorType}"); + notificationConnectors.RemoveWhere(nc => nc.notificationConnectorType == notificationConnectorType); } protected void UpdateLibraries() diff --git a/Tranga/NotificationConnectors/Gotify.cs b/Tranga/NotificationConnectors/Gotify.cs index 306663f..deb8b57 100644 --- a/Tranga/NotificationConnectors/Gotify.cs +++ b/Tranga/NotificationConnectors/Gotify.cs @@ -11,7 +11,7 @@ public class Gotify : NotificationConnector private readonly HttpClient _client = new(); [JsonConstructor] - public Gotify(GlobalBase clone, string endpoint, string appToken) : base(clone, NotificationManagerType.Gotify) + public Gotify(GlobalBase clone, string endpoint, string appToken) : base(clone, NotificationConnectorType.Gotify) { this.endpoint = endpoint; this.appToken = appToken; diff --git a/Tranga/NotificationConnectors/LunaSea.cs b/Tranga/NotificationConnectors/LunaSea.cs index e6be280..41c220a 100644 --- a/Tranga/NotificationConnectors/LunaSea.cs +++ b/Tranga/NotificationConnectors/LunaSea.cs @@ -10,7 +10,7 @@ public class LunaSea : NotificationConnector private readonly HttpClient _client = new(); [JsonConstructor] - public LunaSea(GlobalBase clone, string id) : base(clone, NotificationManagerType.LunaSea) + public LunaSea(GlobalBase clone, string id) : base(clone, NotificationConnectorType.LunaSea) { this.id = id; } diff --git a/Tranga/NotificationConnectors/NotificationConnector.cs b/Tranga/NotificationConnectors/NotificationConnector.cs index 9b79919..7734371 100644 --- a/Tranga/NotificationConnectors/NotificationConnector.cs +++ b/Tranga/NotificationConnectors/NotificationConnector.cs @@ -2,14 +2,14 @@ public abstract class NotificationConnector : GlobalBase { - public readonly NotificationManagerType notificationManagerType; + public readonly NotificationConnectorType notificationConnectorType; - protected NotificationConnector(GlobalBase clone, NotificationManagerType notificationManagerType) : base(clone) + protected NotificationConnector(GlobalBase clone, NotificationConnectorType notificationConnectorType) : base(clone) { - this.notificationManagerType = notificationManagerType; + this.notificationConnectorType = notificationConnectorType; } - public enum NotificationManagerType : byte { Gotify = 0, LunaSea = 1 } + public enum NotificationConnectorType : byte { Gotify = 0, LunaSea = 1 } public abstract void SendNotification(string title, string notificationText); } \ No newline at end of file diff --git a/Tranga/NotificationConnectors/NotificationManagerJsonConverter.cs b/Tranga/NotificationConnectors/NotificationManagerJsonConverter.cs index 2b2d843..5214183 100644 --- a/Tranga/NotificationConnectors/NotificationManagerJsonConverter.cs +++ b/Tranga/NotificationConnectors/NotificationManagerJsonConverter.cs @@ -21,10 +21,10 @@ public class NotificationManagerJsonConverter : JsonConverter JsonSerializer serializer) { JObject jo = JObject.Load(reader); - if (jo["notificationManagerType"]!.Value() == (byte)NotificationConnector.NotificationManagerType.Gotify) + if (jo["notificationConnectorType"]!.Value() == (byte)NotificationConnector.NotificationConnectorType.Gotify) return new Gotify(this._clone, jo.GetValue("endpoint")!.Value()!, jo.GetValue("appToken")!.Value()!); - else if (jo["notificationManagerType"]!.Value() == - (byte)NotificationConnector.NotificationManagerType.LunaSea) + else if (jo["notificationConnectorType"]!.Value() == + (byte)NotificationConnector.NotificationConnectorType.LunaSea) return new LunaSea(this._clone, jo.GetValue("id")!.Value()!); throw new Exception(); diff --git a/Tranga/Server.cs b/Tranga/Server.cs index 0a293f8..df4f434 100644 --- a/Tranga/Server.cs +++ b/Tranga/Server.cs @@ -173,7 +173,7 @@ public class Server : GlobalBase break; case "NotificationConnectors/Types": SendResponse(HttpStatusCode.OK, response, - Enum.GetValues().Select(nc => new KeyValuePair((byte)nc, Enum.GetName(nc)))); + Enum.GetValues().Select(nc => new KeyValuePair((byte)nc, Enum.GetName(nc)))); break; case "LibraryConnectors": SendResponse(HttpStatusCode.OK, response, libraryConnectors); @@ -259,13 +259,13 @@ public class Server : GlobalBase break;*/ case "NotificationConnectors/Update": if (!requestVariables.TryGetValue("notificationConnector", out string? notificationConnectorStr) || - !Enum.TryParse(notificationConnectorStr, out NotificationConnector.NotificationManagerType notificationManagerType)) + !Enum.TryParse(notificationConnectorStr, out NotificationConnector.NotificationConnectorType notificationConnectorType)) { SendResponse(HttpStatusCode.BadRequest, response); break; } - if (notificationManagerType is NotificationConnector.NotificationManagerType.Gotify) + if (notificationConnectorType is NotificationConnector.NotificationConnectorType.Gotify) { if (!requestVariables.TryGetValue("gotifyUrl", out string? gotifyUrl) || !requestVariables.TryGetValue("gotifyAppToken", out string? gotifyAppToken)) @@ -278,7 +278,7 @@ public class Server : GlobalBase break; } - if (notificationManagerType is NotificationConnector.NotificationManagerType.LunaSea) + if (notificationConnectorType is NotificationConnector.NotificationConnectorType.LunaSea) { if (!requestVariables.TryGetValue("lunaseaWebhook", out string? lunaseaWebhook)) { @@ -290,16 +290,16 @@ public class Server : GlobalBase break; } break; - case "LibraryManagers/Update": - if (!requestVariables.TryGetValue("libraryManager", out string? libraryManagerStr) || - !Enum.TryParse(libraryManagerStr, - out LibraryConnector.LibraryType libraryManagerType)) + case "LibraryConnectors/Update": + if (!requestVariables.TryGetValue("libraryConnector", out string? libraryConnectorStr) || + !Enum.TryParse(libraryConnectorStr, + out LibraryConnector.LibraryType libraryConnectorType)) { SendResponse(HttpStatusCode.BadRequest, response); break; } - if (libraryManagerType is LibraryConnector.LibraryType.Kavita) + if (libraryConnectorType is LibraryConnector.LibraryType.Kavita) { if (!requestVariables.TryGetValue("kavitaUrl", out string? kavitaUrl) || !requestVariables.TryGetValue("kavitaUsername", out string? kavitaUsername) || @@ -313,7 +313,7 @@ public class Server : GlobalBase break; } - if (libraryManagerType is LibraryConnector.LibraryType.Komga) + if (libraryConnectorType is LibraryConnector.LibraryType.Komga) { if (!requestVariables.TryGetValue("komgaUrl", out string? komgaUrl) || !requestVariables.TryGetValue("komgaAuth", out string? komgaAuth)) @@ -394,23 +394,23 @@ public class Server : GlobalBase break; case "NotificationConnectors": if (!requestVariables.TryGetValue("notificationConnector", out string? notificationConnectorStr) || - !Enum.TryParse(notificationConnectorStr, out NotificationConnector.NotificationManagerType notificationManagerType)) + !Enum.TryParse(notificationConnectorStr, out NotificationConnector.NotificationConnectorType notificationConnectorType)) { SendResponse(HttpStatusCode.BadRequest, response); break; } - DeleteNotificationConnector(notificationManagerType); + DeleteNotificationConnector(notificationConnectorType); SendResponse(HttpStatusCode.Accepted, response); break; - case "LibraryManagers": - if (!requestVariables.TryGetValue("libraryManager", out string? libraryManagerStr) || - !Enum.TryParse(libraryManagerStr, - out LibraryConnector.LibraryType libraryManagerType)) + case "LibraryConnectors": + if (!requestVariables.TryGetValue("libraryConnectors", out string? libraryConnectorStr) || + !Enum.TryParse(libraryConnectorStr, + out LibraryConnector.LibraryType libraryConnectoryType)) { SendResponse(HttpStatusCode.BadRequest, response); break; } - DeleteLibraryConnector(libraryManagerType); + DeleteLibraryConnector(libraryConnectoryType); SendResponse(HttpStatusCode.Accepted, response); break; default: