feat: Add NTFY API token field for Token-based authentication to ntfy server
- Add the api_token field for NTFY notifications in both the dialog and service to save it to PB. NTFY schema to include api_token field.
This commit is contained in:
+35
-16
@@ -83,6 +83,7 @@ const emailSchema = baseSchema.extend({
|
|||||||
const ntfySchema = baseSchema.extend({
|
const ntfySchema = baseSchema.extend({
|
||||||
notification_type: z.literal("ntfy"),
|
notification_type: z.literal("ntfy"),
|
||||||
ntfy_endpoint: z.string().url("Must be a valid NTFY endpoint URL"),
|
ntfy_endpoint: z.string().url("Must be a valid NTFY endpoint URL"),
|
||||||
|
api_token: z.string().optional(),
|
||||||
});
|
});
|
||||||
|
|
||||||
const pushoverSchema = baseSchema.extend({
|
const pushoverSchema = baseSchema.extend({
|
||||||
@@ -595,22 +596,40 @@ export const NotificationChannelDialog = ({
|
|||||||
)}
|
)}
|
||||||
|
|
||||||
{notificationType === "ntfy" && (
|
{notificationType === "ntfy" && (
|
||||||
<FormField
|
<>
|
||||||
control={form.control}
|
<FormField
|
||||||
name="ntfy_endpoint"
|
control={form.control}
|
||||||
render={({ field }) => (
|
name="ntfy_endpoint"
|
||||||
<FormItem>
|
render={({ field }) => (
|
||||||
<FormLabel>NTFY Endpoint</FormLabel>
|
<FormItem>
|
||||||
<FormControl>
|
<FormLabel>NTFY Endpoint</FormLabel>
|
||||||
<Input placeholder="https://ntfy.sh/your-topic" {...field} />
|
<FormControl>
|
||||||
</FormControl>
|
<Input placeholder="https://ntfy.sh/your-topic" {...field} />
|
||||||
<FormDescription>
|
</FormControl>
|
||||||
The NTFY endpoint URL including your topic (e.g., https://ntfy.sh/checkcle)
|
<FormDescription>
|
||||||
</FormDescription>
|
The NTFY endpoint URL including your topic (e.g., https://ntfy.sh/checkcle)
|
||||||
<FormMessage />
|
</FormDescription>
|
||||||
</FormItem>
|
<FormMessage />
|
||||||
)}
|
</FormItem>
|
||||||
/>
|
)}
|
||||||
|
/>
|
||||||
|
<FormField
|
||||||
|
control={form.control}
|
||||||
|
name="api_token"
|
||||||
|
render={({ field }) => (
|
||||||
|
<FormItem>
|
||||||
|
<FormLabel>API Token (Optional)</FormLabel>
|
||||||
|
<FormControl>
|
||||||
|
<Input placeholder="Enter NTFY API token" {...field} type="password" />
|
||||||
|
</FormControl>
|
||||||
|
<FormDescription>
|
||||||
|
Optional API token for authentication with NTFY server
|
||||||
|
</FormDescription>
|
||||||
|
<FormMessage />
|
||||||
|
</FormItem>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
</>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{notificationType === "pushover" && (
|
{notificationType === "pushover" && (
|
||||||
|
|||||||
@@ -88,6 +88,7 @@ export const alertConfigService = {
|
|||||||
|
|
||||||
} else if (config.notification_type === "ntfy") {
|
} else if (config.notification_type === "ntfy") {
|
||||||
cleanConfig.ntfy_endpoint = config.ntfy_endpoint || "";
|
cleanConfig.ntfy_endpoint = config.ntfy_endpoint || "";
|
||||||
|
cleanConfig.api_token = config.api_token || "";
|
||||||
|
|
||||||
} else if (config.notification_type === "pushover") {
|
} else if (config.notification_type === "pushover") {
|
||||||
cleanConfig.api_token = config.api_token || "";
|
cleanConfig.api_token = config.api_token || "";
|
||||||
|
|||||||
Reference in New Issue
Block a user