diff --git a/Tranga-API/Program.cs b/Tranga-API/Program.cs index 80d1307..d862432 100644 --- a/Tranga-API/Program.cs +++ b/Tranga-API/Program.cs @@ -244,7 +244,7 @@ app.MapGet("/Settings/Get", () => taskManager.settings); app.MapPost("/Settings/Update", (string? downloadLocation, string? komgaUrl, string? komgaAuth, string? kavitaUrl, string? kavitaUsername, - string? kavitaPassword, string? gotifyUrl, string? gotifyAppToken) => + string? kavitaPassword, string? gotifyUrl, string? gotifyAppToken, string? lunaseaWebhook) => { if (downloadLocation is not null && downloadLocation.Length > 0) taskManager.settings.UpdateSettings(TrangaSettings.UpdateField.DownloadLocation, logger, downloadLocation); @@ -256,6 +256,8 @@ app.MapPost("/Settings/Update", kavitaPassword); if (gotifyUrl is not null && gotifyAppToken is not null && gotifyUrl.Length > 5 && gotifyAppToken.Length > 0) taskManager.settings.UpdateSettings(TrangaSettings.UpdateField.Gotify, logger, gotifyUrl, gotifyAppToken); + if(lunaseaWebhook is not null && lunaseaWebhook.Length > 5) + taskManager.settings.UpdateSettings(TrangaSettings.UpdateField.LunaSea, logger, lunaseaWebhook); }); app.Run(); \ No newline at end of file diff --git a/Tranga/TrangaSettings.cs b/Tranga/TrangaSettings.cs index 02de48d..8273eb4 100644 --- a/Tranga/TrangaSettings.cs +++ b/Tranga/TrangaSettings.cs @@ -70,8 +70,14 @@ public class TrangaSettings notificationManagers.RemoveWhere(nm => nm.GetType() == typeof(Gotify)); notificationManagers.Add(new Gotify(values[0], values[1], logger)); break; + case UpdateField.LunaSea: + if(values.Length != 1) + return; + notificationManagers.RemoveWhere(nm => nm.GetType() == typeof(LunaSea)); + notificationManagers.Add(new LunaSea(values[0], logger)); + break; } } - public enum UpdateField { DownloadLocation, Komga, Kavita, Gotify} + public enum UpdateField { DownloadLocation, Komga, Kavita, Gotify, LunaSea} } \ No newline at end of file diff --git a/Website/apiConnector.js b/Website/apiConnector.js index ebeb640..e859229 100644 --- a/Website/apiConnector.js +++ b/Website/apiConnector.js @@ -150,6 +150,12 @@ function UpdateGotify(gotifyUrl, gotifyAppToken){ PostData(uri); } +function UpdateLunaSea(lunaseaWebhook){ + var uri = apiUri + "/Settings/Update?" + uri += `&lunaseaWebhook=${lunaseaWebhook}`; + PostData(uri); +} + function DeleteTask(taskType, connectorName, publicationId){ var uri = apiUri + `/Tasks/Delete?taskType=${taskType}&connectorName=${connectorName}&publicationId=${publicationId}`; DeleteData(uri); diff --git a/Website/index.html b/Website/index.html index 5b3db59..8182f64 100644 --- a/Website/index.html +++ b/Website/index.html @@ -139,6 +139,11 @@ +
+ LunaSea +
Configured: ✅❌
+ +
diff --git a/Website/interaction.js b/Website/interaction.js index 6aec710..34128cc 100644 --- a/Website/interaction.js +++ b/Website/interaction.js @@ -35,10 +35,12 @@ const settingKavitaUser = document.querySelector("#kavitaUsername"); const settingKavitaPass = document.querySelector("#kavitaPassword"); const settingGotifyUrl = document.querySelector("#gotifyUrl"); const settingGotifyAppToken = document.querySelector("#gotifyAppToken"); +const settingLunaseaWebhook = document.querySelector("#lunaseaWebhook"); const libraryUpdateTime = document.querySelector("#libraryUpdateTime"); const settingKomgaConfigured = document.querySelector("#komgaConfigured"); const settingKavitaConfigured = document.querySelector("#kavitaConfigured"); const settingGotifyConfigured = document.querySelector("#gotifyConfigured"); +const settingLunaseaConfigured = document.querySelector("#lunaseaConfigured"); const settingApiUri = document.querySelector("#settingApiUri"); const tagTasksRunning = document.querySelector("#tasksRunningTag"); const tagTasksQueued = document.querySelector("#tasksQueuedTag"); @@ -295,6 +297,8 @@ function GetSettingsClick(){ settingGotifyUrl.value = ""; settingGotifyAppToken.value = ""; settingGotifyConfigured.innerText = "❌"; + settingLunaseaWebhook.value = ""; + settingLunaseaConfigured.innerText = "❌"; settingApiUri.placeholder = apiUri; @@ -317,7 +321,9 @@ function GetSettingsClick(){ json.notificationManagers.forEach(nm => { if(nm.notificationManagerType == 0){ settingGotifyConfigured.innerText = "✅"; - } + } else if(nm.notificationManagerType == 1){ + settingLunaseaConfigured.innerText = "✅"; + } }); }); @@ -342,6 +348,10 @@ function UpdateLibrarySettings(){ UpdateGotify(settingGotifyUrl.value, settingGotifyAppToken.value); } + if(settingLunaseaWebhook.value != ""){ + UpdateLunaSea(settingLunaseaWebhook.value); + } + CreateUpdateLibraryTask(libraryUpdateTime.value); setTimeout(() => GetSettingsClick(), 200); }