mirror of
https://github.com/C9Glax/tranga.git
synced 2025-06-13 14:57:53 +02:00
Arbitrary Webhook for NotificationConnectors
Backend only deals in REST Webhooks The API has custom Endpoints for Ntfy, Gotify, Lunasea that create pre-formatted Webhooks #297 #259
This commit is contained in:
13
API/APIEndpointRecords/CoverFormatRequestRecord.cs
Normal file
13
API/APIEndpointRecords/CoverFormatRequestRecord.cs
Normal file
@ -0,0 +1,13 @@
|
||||
using SixLabors.ImageSharp;
|
||||
|
||||
namespace API.APIEndpointRecords;
|
||||
|
||||
public record CoverFormatRequestRecord(Size size)
|
||||
{
|
||||
public bool Validate()
|
||||
{
|
||||
if (size.Height <= 0 || size.Width <= 0 || size.Height > 65535 || size.Width > 65535) //JPEG max size
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
}
|
16
API/APIEndpointRecords/GotifyRecord.cs
Normal file
16
API/APIEndpointRecords/GotifyRecord.cs
Normal file
@ -0,0 +1,16 @@
|
||||
namespace API.APIEndpointRecords;
|
||||
|
||||
public record GotifyRecord(string endpoint, string appToken, int priority)
|
||||
{
|
||||
public bool Validate()
|
||||
{
|
||||
if (endpoint == string.Empty)
|
||||
return false;
|
||||
if (appToken == string.Empty)
|
||||
return false;
|
||||
if (priority < 0 || priority > 10)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
16
API/APIEndpointRecords/LunaseaRecord.cs
Normal file
16
API/APIEndpointRecords/LunaseaRecord.cs
Normal file
@ -0,0 +1,16 @@
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace API.APIEndpointRecords;
|
||||
|
||||
public record LunaseaRecord(string id)
|
||||
{
|
||||
private static Regex validateRex = new(@"(?:device|user)\/[0-9a-zA-Z\-]+");
|
||||
public bool Validate()
|
||||
{
|
||||
if (id == string.Empty)
|
||||
return false;
|
||||
if (!validateRex.IsMatch(id))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
}
|
3
API/APIEndpointRecords/ModifyJobRecord.cs
Normal file
3
API/APIEndpointRecords/ModifyJobRecord.cs
Normal file
@ -0,0 +1,3 @@
|
||||
namespace API.APIEndpointRecords;
|
||||
|
||||
public record ModifyJobRecord(ulong? RecurrenceMs, bool? Enabled);
|
17
API/APIEndpointRecords/NtfyRecord.cs
Normal file
17
API/APIEndpointRecords/NtfyRecord.cs
Normal file
@ -0,0 +1,17 @@
|
||||
namespace API.APIEndpointRecords;
|
||||
|
||||
public record NtfyRecord(string endpoint, string username, string password, string topic, int priority)
|
||||
{
|
||||
public bool Validate()
|
||||
{
|
||||
if (endpoint == string.Empty)
|
||||
return false;
|
||||
if (username == string.Empty)
|
||||
return false;
|
||||
if (password == string.Empty)
|
||||
return false;
|
||||
if (priority < 1 || priority > 5)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user