diff --git a/cypress/config/settings.cypress.json b/cypress/config/settings.cypress.json index 702ee1487..c466b2bf7 100644 --- a/cypress/config/settings.cypress.json +++ b/cypress/config/settings.cypress.json @@ -138,7 +138,8 @@ "types": 0, "options": { "url": "", - "token": "" + "token": "", + "priority": 0 } } } diff --git a/server/lib/notifications/agents/gotify.ts b/server/lib/notifications/agents/gotify.ts index 31561847b..2f4bddf15 100644 --- a/server/lib/notifications/agents/gotify.ts +++ b/server/lib/notifications/agents/gotify.ts @@ -30,7 +30,12 @@ class GotifyAgent public shouldSend(): boolean { const settings = this.getSettings(); - if (settings.enabled && settings.options.url && settings.options.token) { + if ( + settings.enabled && + settings.options.url && + settings.options.token && + settings.options.priority + ) { return true; } @@ -42,7 +47,8 @@ class GotifyAgent payload: NotificationPayload ): GotifyPayload { const { applicationUrl, applicationTitle } = getSettings().main; - let priority = 0; + const settings = this.getSettings(); + const priority = settings.options.priority ?? 1; const title = payload.event ? `${payload.event} - ${payload.subject}` @@ -86,10 +92,6 @@ class GotifyAgent message += `\n**Issue Status:** ${ payload.issue.status === IssueStatus.OPEN ? 'Open' : 'Resolved' } `; - - if (type == Notification.ISSUE_CREATED) { - priority = 1; - } } for (const extra of payload.extra ?? []) { diff --git a/server/lib/settings/index.ts b/server/lib/settings/index.ts index d85f71379..3630c42eb 100644 --- a/server/lib/settings/index.ts +++ b/server/lib/settings/index.ts @@ -254,6 +254,7 @@ export interface NotificationAgentGotify extends NotificationAgentConfig { options: { url: string; token: string; + priority: number; }; } @@ -463,6 +464,7 @@ class Settings { options: { url: '', token: '', + priority: 0, }, }, }, diff --git a/src/components/Settings/Notifications/NotificationsGotify/index.tsx b/src/components/Settings/Notifications/NotificationsGotify/index.tsx index e6c4ebee5..a24be1a2a 100644 --- a/src/components/Settings/Notifications/NotificationsGotify/index.tsx +++ b/src/components/Settings/Notifications/NotificationsGotify/index.tsx @@ -17,9 +17,11 @@ const messages = defineMessages( agentenabled: 'Enable Agent', url: 'Server URL', token: 'Application Token', + priority: 'Priority', validationUrlRequired: 'You must provide a valid URL', validationUrlTrailingSlash: 'URL must not end in a trailing slash', validationTokenRequired: 'You must provide an application token', + validationPriorityRequired: 'You must set a priority number', gotifysettingssaved: 'Gotify notification settings saved successfully!', gotifysettingsfailed: 'Gotify notification settings failed to save.', toastGotifyTestSending: 'Sending Gotify test notification…', @@ -65,6 +67,15 @@ const NotificationsGotify = () => { .required(intl.formatMessage(messages.validationTokenRequired)), otherwise: Yup.string().nullable(), }), + priority: Yup.string().when('enabled', { + is: true, + then: Yup.string() + .nullable() + .min(0) + .max(9) + .required(intl.formatMessage(messages.validationPriorityRequired)), + otherwise: Yup.string().nullable(), + }), }); if (!data && !error) { @@ -78,6 +89,7 @@ const NotificationsGotify = () => { types: data?.types, url: data?.options.url, token: data?.options.token, + priority: data?.options.priority, }} validationSchema={NotificationsGotifySchema} onSubmit={async (values) => { @@ -93,6 +105,7 @@ const NotificationsGotify = () => { options: { url: values.url, token: values.token, + priority: Number(values.priority), }, }), }); @@ -147,6 +160,7 @@ const NotificationsGotify = () => { options: { url: values.url, token: values.token, + priority: Number(values.priority), }, }), } @@ -216,6 +230,30 @@ const NotificationsGotify = () => { )} +
+ +
+ + {errors.priority && + touched.priority && + typeof errors.priority === 'string' && ( +
{errors.priority}
+ )} +
+
{ diff --git a/src/i18n/locale/en.json b/src/i18n/locale/en.json index 121f6882e..d4269b969 100644 --- a/src/i18n/locale/en.json +++ b/src/i18n/locale/en.json @@ -598,11 +598,13 @@ "components.Settings.Notifications.NotificationsGotify.agentenabled": "Enable Agent", "components.Settings.Notifications.NotificationsGotify.gotifysettingsfailed": "Gotify notification settings failed to save.", "components.Settings.Notifications.NotificationsGotify.gotifysettingssaved": "Gotify notification settings saved successfully!", + "components.Settings.Notifications.NotificationsGotify.priority": "Priority", "components.Settings.Notifications.NotificationsGotify.toastGotifyTestFailed": "Gotify test notification failed to send.", "components.Settings.Notifications.NotificationsGotify.toastGotifyTestSending": "Sending Gotify test notification…", "components.Settings.Notifications.NotificationsGotify.toastGotifyTestSuccess": "Gotify test notification sent!", "components.Settings.Notifications.NotificationsGotify.token": "Application Token", "components.Settings.Notifications.NotificationsGotify.url": "Server URL", + "components.Settings.Notifications.NotificationsGotify.validationPriorityRequired": "You must set a priority number", "components.Settings.Notifications.NotificationsGotify.validationTokenRequired": "You must provide an application token", "components.Settings.Notifications.NotificationsGotify.validationTypes": "You must select at least one notification type", "components.Settings.Notifications.NotificationsGotify.validationUrlRequired": "You must provide a valid URL",