2
0

NTFY use Username and Password

https://github.com/C9Glax/tranga/issues/187
This commit is contained in:
Glax 2024-06-15 21:26:23 +02:00
parent ee6de661c8
commit fd20b9febf
2 changed files with 12 additions and 7 deletions

View File

@ -63,9 +63,11 @@ public partial class Server
case NotificationConnector.NotificationConnectorType.Ntfy:
if(!requestParameters.TryGetValue("url", out url))
return new ValueTuple<HttpStatusCode, object?>(HttpStatusCode.NotAcceptable, "Parameter 'url' missing.");
if(!requestParameters.TryGetValue("auth", out string? auth))
return new ValueTuple<HttpStatusCode, object?>(HttpStatusCode.NotAcceptable, "Parameter 'auth' missing.");
Ntfy ntfy = new(this, url, auth);
if(!requestParameters.TryGetValue("username", out string? username))
return new ValueTuple<HttpStatusCode, object?>(HttpStatusCode.NotAcceptable, "Parameter 'username' missing.");
if(!requestParameters.TryGetValue("password", out string? password))
return new ValueTuple<HttpStatusCode, object?>(HttpStatusCode.NotAcceptable, "Parameter 'password' missing.");
Ntfy ntfy = new(this, url, username, password, null);
this.notificationConnectors.RemoveWhere(nc =>
nc.notificationConnectorType == NotificationConnector.NotificationConnectorType.Ntfy);
this.notificationConnectors.Add(ntfy);
@ -103,9 +105,11 @@ public partial class Server
case NotificationConnector.NotificationConnectorType.Ntfy:
if(!requestParameters.TryGetValue("url", out url))
return new ValueTuple<HttpStatusCode, object?>(HttpStatusCode.NotAcceptable, "Parameter 'url' missing.");
if(!requestParameters.TryGetValue("auth", out string? auth))
return new ValueTuple<HttpStatusCode, object?>(HttpStatusCode.NotAcceptable, "Parameter 'auth' missing.");
Ntfy ntfy = new(this, url, auth);
if(!requestParameters.TryGetValue("username", out string? username))
return new ValueTuple<HttpStatusCode, object?>(HttpStatusCode.NotAcceptable, "Parameter 'username' missing.");
if(!requestParameters.TryGetValue("password", out string? password))
return new ValueTuple<HttpStatusCode, object?>(HttpStatusCode.NotAcceptable, "Parameter 'password' missing.");
Ntfy ntfy = new(this, url, username, password, null);
ntfy.SendNotification("Tranga Test", "It was successful :3");
return new ValueTuple<HttpStatusCode, object?>(HttpStatusCode.OK, ntfy);
default:

View File

@ -950,7 +950,8 @@ Creates a Notification-Connector of the specified Type.
| Parameter | Value |
|-----------|--------------------------|
| url | URL of the Ntfy Instance |
| auth | Auth-String |
| username | Username |
| password | Password |
</details>
<details>