NTFY use Username and Password
https://github.com/C9Glax/tranga/issues/187
This commit is contained in:
parent
ee6de661c8
commit
fd20b9febf
@ -63,9 +63,11 @@ public partial class Server
|
|||||||
case NotificationConnector.NotificationConnectorType.Ntfy:
|
case NotificationConnector.NotificationConnectorType.Ntfy:
|
||||||
if(!requestParameters.TryGetValue("url", out url))
|
if(!requestParameters.TryGetValue("url", out url))
|
||||||
return new ValueTuple<HttpStatusCode, object?>(HttpStatusCode.NotAcceptable, "Parameter 'url' missing.");
|
return new ValueTuple<HttpStatusCode, object?>(HttpStatusCode.NotAcceptable, "Parameter 'url' missing.");
|
||||||
if(!requestParameters.TryGetValue("auth", out string? auth))
|
if(!requestParameters.TryGetValue("username", out string? username))
|
||||||
return new ValueTuple<HttpStatusCode, object?>(HttpStatusCode.NotAcceptable, "Parameter 'auth' missing.");
|
return new ValueTuple<HttpStatusCode, object?>(HttpStatusCode.NotAcceptable, "Parameter 'username' missing.");
|
||||||
Ntfy ntfy = new(this, url, auth);
|
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 =>
|
this.notificationConnectors.RemoveWhere(nc =>
|
||||||
nc.notificationConnectorType == NotificationConnector.NotificationConnectorType.Ntfy);
|
nc.notificationConnectorType == NotificationConnector.NotificationConnectorType.Ntfy);
|
||||||
this.notificationConnectors.Add(ntfy);
|
this.notificationConnectors.Add(ntfy);
|
||||||
@ -103,9 +105,11 @@ public partial class Server
|
|||||||
case NotificationConnector.NotificationConnectorType.Ntfy:
|
case NotificationConnector.NotificationConnectorType.Ntfy:
|
||||||
if(!requestParameters.TryGetValue("url", out url))
|
if(!requestParameters.TryGetValue("url", out url))
|
||||||
return new ValueTuple<HttpStatusCode, object?>(HttpStatusCode.NotAcceptable, "Parameter 'url' missing.");
|
return new ValueTuple<HttpStatusCode, object?>(HttpStatusCode.NotAcceptable, "Parameter 'url' missing.");
|
||||||
if(!requestParameters.TryGetValue("auth", out string? auth))
|
if(!requestParameters.TryGetValue("username", out string? username))
|
||||||
return new ValueTuple<HttpStatusCode, object?>(HttpStatusCode.NotAcceptable, "Parameter 'auth' missing.");
|
return new ValueTuple<HttpStatusCode, object?>(HttpStatusCode.NotAcceptable, "Parameter 'username' missing.");
|
||||||
Ntfy ntfy = new(this, url, auth);
|
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");
|
ntfy.SendNotification("Tranga Test", "It was successful :3");
|
||||||
return new ValueTuple<HttpStatusCode, object?>(HttpStatusCode.OK, ntfy);
|
return new ValueTuple<HttpStatusCode, object?>(HttpStatusCode.OK, ntfy);
|
||||||
default:
|
default:
|
||||||
|
@ -950,7 +950,8 @@ Creates a Notification-Connector of the specified Type.
|
|||||||
| Parameter | Value |
|
| Parameter | Value |
|
||||||
|-----------|--------------------------|
|
|-----------|--------------------------|
|
||||||
| url | URL of the Ntfy Instance |
|
| url | URL of the Ntfy Instance |
|
||||||
| auth | Auth-String |
|
| username | Username |
|
||||||
|
| password | Password |
|
||||||
</details>
|
</details>
|
||||||
|
|
||||||
<details>
|
<details>
|
||||||
|
Loading…
Reference in New Issue
Block a user