Compare commits
No commits in common. "db53e2156bde2a12f1d28503cccd25118b6e446f" and "ca95460218bcf2395cab86ebeed2e36851bd221e" have entirely different histories.
db53e2156b
...
ca95460218
2
.github/workflows/docker-image-master.yml
vendored
2
.github/workflows/docker-image-master.yml
vendored
@ -3,6 +3,8 @@ name: Docker Image CI
|
|||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [ "master" ]
|
branches: [ "master" ]
|
||||||
|
pull_request:
|
||||||
|
branches: [ "master" ]
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
114
Tranga/Server.cs
114
Tranga/Server.cs
@ -266,13 +266,11 @@ public class Server : GlobalBase
|
|||||||
private void HandlePost(HttpListenerRequest request, HttpListenerResponse response)
|
private void HandlePost(HttpListenerRequest request, HttpListenerResponse response)
|
||||||
{
|
{
|
||||||
Dictionary<string, string> requestVariables = GetRequestVariables(request.Url!.Query);
|
Dictionary<string, string> requestVariables = GetRequestVariables(request.Url!.Query);
|
||||||
string? connectorName, internalId, jobId, chapterNumStr, customFolderName, translatedLanguage, notificationConnectorStr, libraryConnectorStr;
|
string? connectorName, internalId, jobId, chapterNumStr, customFolderName, translatedLanguage;
|
||||||
MangaConnector? connector;
|
MangaConnector? connector;
|
||||||
Manga? tmpManga;
|
Manga? tmpManga;
|
||||||
Manga manga;
|
Manga manga;
|
||||||
Job? job;
|
Job? job;
|
||||||
NotificationConnector.NotificationConnectorType notificationConnectorType;
|
|
||||||
LibraryConnector.LibraryType libraryConnectorType;
|
|
||||||
string path = Regex.Match(request.Url!.LocalPath, @"[A-z0-9]+(\/[A-z0-9]+)*").Value;
|
string path = Regex.Match(request.Url!.LocalPath, @"[A-z0-9]+(\/[A-z0-9]+)*").Value;
|
||||||
switch (path)
|
switch (path)
|
||||||
{
|
{
|
||||||
@ -441,8 +439,8 @@ public class Server : GlobalBase
|
|||||||
SendResponse(HttpStatusCode.BadRequest, response);
|
SendResponse(HttpStatusCode.BadRequest, response);
|
||||||
break;
|
break;
|
||||||
case "NotificationConnectors/Update":
|
case "NotificationConnectors/Update":
|
||||||
if (!requestVariables.TryGetValue("notificationConnector", out notificationConnectorStr) ||
|
if (!requestVariables.TryGetValue("notificationConnector", out string? notificationConnectorStr) ||
|
||||||
!Enum.TryParse(notificationConnectorStr, out notificationConnectorType))
|
!Enum.TryParse(notificationConnectorStr, out NotificationConnector.NotificationConnectorType notificationConnectorType))
|
||||||
{
|
{
|
||||||
SendResponse(HttpStatusCode.BadRequest, response);
|
SendResponse(HttpStatusCode.BadRequest, response);
|
||||||
break;
|
break;
|
||||||
@ -483,64 +481,9 @@ public class Server : GlobalBase
|
|||||||
SendResponse(HttpStatusCode.BadRequest, response);
|
SendResponse(HttpStatusCode.BadRequest, response);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "NotificationConnectors/Test":
|
|
||||||
NotificationConnector notificationConnector;
|
|
||||||
if (!requestVariables.TryGetValue("notificationConnector", out notificationConnectorStr) ||
|
|
||||||
!Enum.TryParse(notificationConnectorStr, out notificationConnectorType))
|
|
||||||
{
|
|
||||||
SendResponse(HttpStatusCode.BadRequest, response);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (notificationConnectorType is NotificationConnector.NotificationConnectorType.Gotify)
|
|
||||||
{
|
|
||||||
if (!requestVariables.TryGetValue("gotifyUrl", out string? gotifyUrl) ||
|
|
||||||
!requestVariables.TryGetValue("gotifyAppToken", out string? gotifyAppToken))
|
|
||||||
{
|
|
||||||
SendResponse(HttpStatusCode.BadRequest, response);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
notificationConnector = new Gotify(this, gotifyUrl, gotifyAppToken);
|
|
||||||
}else if (notificationConnectorType is NotificationConnector.NotificationConnectorType.LunaSea)
|
|
||||||
{
|
|
||||||
if (!requestVariables.TryGetValue("lunaseaWebhook", out string? lunaseaWebhook))
|
|
||||||
{
|
|
||||||
SendResponse(HttpStatusCode.BadRequest, response);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
notificationConnector = new LunaSea(this, lunaseaWebhook);
|
|
||||||
}else if (notificationConnectorType is NotificationConnector.NotificationConnectorType.Ntfy)
|
|
||||||
{
|
|
||||||
if (!requestVariables.TryGetValue("ntfyUrl", out string? ntfyUrl) ||
|
|
||||||
!requestVariables.TryGetValue("ntfyAuth", out string? ntfyAuth))
|
|
||||||
{
|
|
||||||
SendResponse(HttpStatusCode.BadRequest, response);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
notificationConnector = new Ntfy(this, ntfyUrl, ntfyAuth);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
SendResponse(HttpStatusCode.BadRequest, response);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
notificationConnector.SendNotification("Tranga Test", "This is Test-Notification.");
|
|
||||||
SendResponse(HttpStatusCode.Accepted, response);
|
|
||||||
break;
|
|
||||||
case "NotificationConnectors/Reset":
|
|
||||||
if (!requestVariables.TryGetValue("notificationConnector", out notificationConnectorStr) ||
|
|
||||||
!Enum.TryParse(notificationConnectorStr, out notificationConnectorType))
|
|
||||||
{
|
|
||||||
SendResponse(HttpStatusCode.BadRequest, response);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
DeleteNotificationConnector(notificationConnectorType);
|
|
||||||
SendResponse(HttpStatusCode.Accepted, response);
|
|
||||||
break;
|
|
||||||
case "LibraryConnectors/Update":
|
case "LibraryConnectors/Update":
|
||||||
if (!requestVariables.TryGetValue("libraryConnector", out libraryConnectorStr) ||
|
if (!requestVariables.TryGetValue("libraryConnector", out string? libraryConnectorStr) ||
|
||||||
!Enum.TryParse(libraryConnectorStr, out libraryConnectorType))
|
!Enum.TryParse(libraryConnectorStr, out LibraryConnector.LibraryType libraryConnectorType))
|
||||||
{
|
{
|
||||||
SendResponse(HttpStatusCode.BadRequest, response);
|
SendResponse(HttpStatusCode.BadRequest, response);
|
||||||
break;
|
break;
|
||||||
@ -573,53 +516,6 @@ public class Server : GlobalBase
|
|||||||
SendResponse(HttpStatusCode.BadRequest, response);
|
SendResponse(HttpStatusCode.BadRequest, response);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "LibraryConnectors/Test":
|
|
||||||
LibraryConnector libraryConnector;
|
|
||||||
if (!requestVariables.TryGetValue("libraryConnector", out libraryConnectorStr) ||
|
|
||||||
!Enum.TryParse(libraryConnectorStr, out libraryConnectorType))
|
|
||||||
{
|
|
||||||
SendResponse(HttpStatusCode.BadRequest, response);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (libraryConnectorType is LibraryConnector.LibraryType.Kavita)
|
|
||||||
{
|
|
||||||
if (!requestVariables.TryGetValue("kavitaUrl", out string? kavitaUrl) ||
|
|
||||||
!requestVariables.TryGetValue("kavitaUsername", out string? kavitaUsername) ||
|
|
||||||
!requestVariables.TryGetValue("kavitaPassword", out string? kavitaPassword))
|
|
||||||
{
|
|
||||||
SendResponse(HttpStatusCode.BadRequest, response);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
libraryConnector = new Kavita(this, kavitaUrl, kavitaUsername, kavitaPassword);
|
|
||||||
}else if (libraryConnectorType is LibraryConnector.LibraryType.Komga)
|
|
||||||
{
|
|
||||||
if (!requestVariables.TryGetValue("komgaUrl", out string? komgaUrl) ||
|
|
||||||
!requestVariables.TryGetValue("komgaAuth", out string? komgaAuth))
|
|
||||||
{
|
|
||||||
SendResponse(HttpStatusCode.BadRequest, response);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
libraryConnector = new Komga(this, komgaUrl, komgaAuth);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
SendResponse(HttpStatusCode.BadRequest, response);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
libraryConnector.UpdateLibrary();
|
|
||||||
SendResponse(HttpStatusCode.Accepted, response);
|
|
||||||
break;
|
|
||||||
case "LibraryConnectors/Reset":
|
|
||||||
if (!requestVariables.TryGetValue("libraryConnector", out libraryConnectorStr) ||
|
|
||||||
!Enum.TryParse(libraryConnectorStr, out libraryConnectorType))
|
|
||||||
{
|
|
||||||
SendResponse(HttpStatusCode.BadRequest, response);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
DeleteLibraryConnector(libraryConnectorType);
|
|
||||||
SendResponse(HttpStatusCode.Accepted, response);
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
SendResponse(HttpStatusCode.BadRequest, response);
|
SendResponse(HttpStatusCode.BadRequest, response);
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user