Compare commits

...

3 Commits

Author SHA1 Message Date
fallenbagel
b92a26bfcb docs(ntfy.sh): add priority documentation 2026-01-16 12:57:54 +08:00
fallenbagel
0753d7f48e chore(i18n): extract translations 2026-01-16 12:55:49 +08:00
fallenbagel
6f9988085b feat(notifications): add priority setting for ntfy agent
Added priority option to the notification agent ntfy.

fix #2060
2026-01-16 12:55:31 +08:00
5 changed files with 38 additions and 1 deletions

View File

@@ -24,6 +24,10 @@ Set this to the username and password for your ntfy.sh server.
Set this to the token for your ntfy.sh server. Set this to the token for your ntfy.sh server.
### Priority (optional)
Set the priority level for notifications. Options range from Minimum (1) to Urgent (5), with Default (3) being the standard level. Higher priority notifications may bypass Do Not Disturb settings on some devices.
:::info :::info
Please refer to the [ntfy.sh API documentation](https://docs.ntfy.sh/) for more details on configuring these notifications. Please refer to the [ntfy.sh API documentation](https://docs.ntfy.sh/) for more details on configuring these notifications.
::: :::

View File

@@ -27,7 +27,7 @@ class NtfyAgent
const { embedPoster } = settings.notifications.agents.ntfy; const { embedPoster } = settings.notifications.agents.ntfy;
const topic = this.getSettings().options.topic; const topic = this.getSettings().options.topic;
const priority = 3; const priority = this.getSettings().options.priority ?? 3;
const title = payload.event const title = payload.event
? `${payload.event} - ${payload.subject}` ? `${payload.event} - ${payload.subject}`

View File

@@ -296,6 +296,7 @@ export interface NotificationAgentNtfy extends NotificationAgentConfig {
password?: string; password?: string;
authMethodToken?: boolean; authMethodToken?: boolean;
token?: string; token?: string;
priority?: number;
}; };
} }
@@ -529,6 +530,7 @@ class Settings {
options: { options: {
url: '', url: '',
topic: '', topic: '',
priority: 3,
}, },
}, },
}, },

View File

@@ -27,6 +27,7 @@ const messages = defineMessages(
password: 'Password', password: 'Password',
tokenAuth: 'Token authentication', tokenAuth: 'Token authentication',
token: 'Token', token: 'Token',
priority: 'Priority',
ntfysettingssaved: 'Ntfy notification settings saved successfully!', ntfysettingssaved: 'Ntfy notification settings saved successfully!',
ntfysettingsfailed: 'Ntfy notification settings failed to save.', ntfysettingsfailed: 'Ntfy notification settings failed to save.',
toastNtfyTestSending: 'Sending ntfy test notification…', toastNtfyTestSending: 'Sending ntfy test notification…',
@@ -34,6 +35,7 @@ const messages = defineMessages(
toastNtfyTestFailed: 'Ntfy test notification failed to send.', toastNtfyTestFailed: 'Ntfy test notification failed to send.',
validationNtfyUrl: 'You must provide a valid URL', validationNtfyUrl: 'You must provide a valid URL',
validationNtfyTopic: 'You must provide a topic', validationNtfyTopic: 'You must provide a topic',
validationPriorityRequired: 'You must provide a priority between 1 and 5',
validationTypes: 'You must select at least one notification type', validationTypes: 'You must select at least one notification type',
} }
); );
@@ -71,6 +73,14 @@ const NotificationsNtfy = () => {
otherwise: Yup.string().nullable(), otherwise: Yup.string().nullable(),
}) })
.defined(intl.formatMessage(messages.validationNtfyTopic)), .defined(intl.formatMessage(messages.validationNtfyTopic)),
priority: Yup.number().when('enabled', {
is: true,
then: Yup.number()
.min(1)
.max(5)
.required(intl.formatMessage(messages.validationPriorityRequired)),
otherwise: Yup.number().nullable(),
}),
}); });
if (!data && !error) { if (!data && !error) {
@@ -90,6 +100,7 @@ const NotificationsNtfy = () => {
password: data?.options.password, password: data?.options.password,
authMethodToken: data?.options.authMethodToken, authMethodToken: data?.options.authMethodToken,
token: data?.options.token, token: data?.options.token,
priority: data?.options.priority,
}} }}
validationSchema={NotificationsNtfySchema} validationSchema={NotificationsNtfySchema}
onSubmit={async (values) => { onSubmit={async (values) => {
@@ -106,6 +117,7 @@ const NotificationsNtfy = () => {
password: values.password, password: values.password,
authMethodToken: values.authMethodToken, authMethodToken: values.authMethodToken,
token: values.token, token: values.token,
priority: values.priority,
}, },
}); });
@@ -157,6 +169,7 @@ const NotificationsNtfy = () => {
password: values.password, password: values.password,
authMethodToken: values.authMethodToken, authMethodToken: values.authMethodToken,
token: values.token, token: values.token,
priority: values.priority,
}, },
}); });
@@ -313,6 +326,22 @@ const NotificationsNtfy = () => {
</div> </div>
</div> </div>
)} )}
<div className="form-row">
<label htmlFor="priority" className="text-label">
{intl.formatMessage(messages.priority)}
</label>
<div className="form-input-area">
<div className="form-input-field">
<Field as="select" id="priority" name="priority">
<option value={1}>Minimum</option>
<option value={2}>Low</option>
<option value={3}>Default</option>
<option value={4}>High</option>
<option value={5}>Urgent</option>
</Field>
</div>
</div>
</div>
<NotificationTypeSelector <NotificationTypeSelector
currentTypes={values.enabled ? values.types || 0 : 0} currentTypes={values.enabled ? values.types || 0 : 0}
onUpdate={(newTypes) => { onUpdate={(newTypes) => {

View File

@@ -629,6 +629,7 @@
"components.Settings.Notifications.NotificationsNtfy.ntfysettingsfailed": "Ntfy notification settings failed to save.", "components.Settings.Notifications.NotificationsNtfy.ntfysettingsfailed": "Ntfy notification settings failed to save.",
"components.Settings.Notifications.NotificationsNtfy.ntfysettingssaved": "Ntfy notification settings saved successfully!", "components.Settings.Notifications.NotificationsNtfy.ntfysettingssaved": "Ntfy notification settings saved successfully!",
"components.Settings.Notifications.NotificationsNtfy.password": "Password", "components.Settings.Notifications.NotificationsNtfy.password": "Password",
"components.Settings.Notifications.NotificationsNtfy.priority": "Priority",
"components.Settings.Notifications.NotificationsNtfy.toastNtfyTestFailed": "Ntfy test notification failed to send.", "components.Settings.Notifications.NotificationsNtfy.toastNtfyTestFailed": "Ntfy test notification failed to send.",
"components.Settings.Notifications.NotificationsNtfy.toastNtfyTestSending": "Sending ntfy test notification…", "components.Settings.Notifications.NotificationsNtfy.toastNtfyTestSending": "Sending ntfy test notification…",
"components.Settings.Notifications.NotificationsNtfy.toastNtfyTestSuccess": "Ntfy test notification sent!", "components.Settings.Notifications.NotificationsNtfy.toastNtfyTestSuccess": "Ntfy test notification sent!",
@@ -640,6 +641,7 @@
"components.Settings.Notifications.NotificationsNtfy.usernamePasswordAuth": "Username + Password authentication", "components.Settings.Notifications.NotificationsNtfy.usernamePasswordAuth": "Username + Password authentication",
"components.Settings.Notifications.NotificationsNtfy.validationNtfyTopic": "You must provide a topic", "components.Settings.Notifications.NotificationsNtfy.validationNtfyTopic": "You must provide a topic",
"components.Settings.Notifications.NotificationsNtfy.validationNtfyUrl": "You must provide a valid URL", "components.Settings.Notifications.NotificationsNtfy.validationNtfyUrl": "You must provide a valid URL",
"components.Settings.Notifications.NotificationsNtfy.validationPriorityRequired": "You must provide a priority between 1 and 5",
"components.Settings.Notifications.NotificationsNtfy.validationTypes": "You must select at least one notification type", "components.Settings.Notifications.NotificationsNtfy.validationTypes": "You must select at least one notification type",
"components.Settings.Notifications.NotificationsPushbullet.accessToken": "Access Token", "components.Settings.Notifications.NotificationsPushbullet.accessToken": "Access Token",
"components.Settings.Notifications.NotificationsPushbullet.accessTokenTip": "Create a token from your <PushbulletSettingsLink>Account Settings</PushbulletSettingsLink>", "components.Settings.Notifications.NotificationsPushbullet.accessTokenTip": "Create a token from your <PushbulletSettingsLink>Account Settings</PushbulletSettingsLink>",