mirror of
https://github.com/seerr-team/seerr.git
synced 2025-12-23 23:58:07 -05:00
feat(notifications): improve discord notifications (#1102)
* feat: improve discord notifications Added a field in the general notification settings to allow a role to be mentioned in the webhook message via discord notification agent * feat: add discord role id notification - locales
This commit is contained in:
@@ -75,6 +75,7 @@
|
||||
"types": 0,
|
||||
"options": {
|
||||
"webhookUrl": "",
|
||||
"webhookRoleId": "",
|
||||
"enableMentions": true
|
||||
}
|
||||
},
|
||||
|
||||
@@ -18,6 +18,10 @@ Users can optionally opt-in to being mentioned in Discord notifications by confi
|
||||
|
||||
You can find the webhook URL in the Discord application, at **Server Settings → Integrations → Webhooks**.
|
||||
|
||||
### Notification Role ID (optional)
|
||||
|
||||
If a role ID is specified, it will be included in the webhook message. See [Discord role ID](https://support.discord.com/hc/en-us/articles/206346498-Where-can-I-find-my-User-Server-Message-ID).
|
||||
|
||||
### Bot Username (optional)
|
||||
|
||||
If you would like to override the name you configured for your bot in Discord, you may set this value to whatever you like!
|
||||
|
||||
@@ -1273,6 +1273,8 @@ components:
|
||||
type: string
|
||||
webhookUrl:
|
||||
type: string
|
||||
webhookRoleId:
|
||||
type: string
|
||||
enableMentions:
|
||||
type: boolean
|
||||
SlackSettings:
|
||||
|
||||
@@ -291,6 +291,10 @@ class DiscordAgent
|
||||
}
|
||||
}
|
||||
|
||||
if (settings.options.webhookRoleId) {
|
||||
userMentions.push(`<@&${settings.options.webhookRoleId}>`);
|
||||
}
|
||||
|
||||
const response = await fetch(settings.options.webhookUrl, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
|
||||
@@ -170,6 +170,7 @@ export interface NotificationAgentDiscord extends NotificationAgentConfig {
|
||||
botUsername?: string;
|
||||
botAvatarUrl?: string;
|
||||
webhookUrl: string;
|
||||
webhookRoleId?: string;
|
||||
enableMentions: boolean;
|
||||
};
|
||||
}
|
||||
@@ -394,6 +395,7 @@ class Settings {
|
||||
types: 0,
|
||||
options: {
|
||||
webhookUrl: '',
|
||||
webhookRoleId: '',
|
||||
enableMentions: true,
|
||||
},
|
||||
},
|
||||
|
||||
@@ -19,12 +19,16 @@ const messages = defineMessages('components.Settings.Notifications', {
|
||||
webhookUrl: 'Webhook URL',
|
||||
webhookUrlTip:
|
||||
'Create a <DiscordWebhookLink>webhook integration</DiscordWebhookLink> in your server',
|
||||
webhookRoleId: 'Notification Role ID',
|
||||
webhookRoleIdTip:
|
||||
'The role ID to mention in the webhook message. Leave empty to disable mentions',
|
||||
discordsettingssaved: 'Discord notification settings saved successfully!',
|
||||
discordsettingsfailed: 'Discord notification settings failed to save.',
|
||||
toastDiscordTestSending: 'Sending Discord test notification…',
|
||||
toastDiscordTestSuccess: 'Discord test notification sent!',
|
||||
toastDiscordTestFailed: 'Discord test notification failed to send.',
|
||||
validationUrl: 'You must provide a valid URL',
|
||||
validationWebhookRoleId: 'You must provide a valid Discord Role ID',
|
||||
validationTypes: 'You must select at least one notification type',
|
||||
enableMentions: 'Enable Mentions',
|
||||
});
|
||||
@@ -53,6 +57,12 @@ const NotificationsDiscord = () => {
|
||||
otherwise: Yup.string().nullable(),
|
||||
})
|
||||
.url(intl.formatMessage(messages.validationUrl)),
|
||||
webhookRoleId: Yup.string()
|
||||
.nullable()
|
||||
.matches(
|
||||
/^\d{17,19}$/,
|
||||
intl.formatMessage(messages.validationWebhookRoleId)
|
||||
),
|
||||
});
|
||||
|
||||
if (!data && !error) {
|
||||
@@ -67,6 +77,7 @@ const NotificationsDiscord = () => {
|
||||
botUsername: data?.options.botUsername,
|
||||
botAvatarUrl: data?.options.botAvatarUrl,
|
||||
webhookUrl: data.options.webhookUrl,
|
||||
webhookRoleId: data?.options.webhookRoleId,
|
||||
enableMentions: data?.options.enableMentions,
|
||||
}}
|
||||
validationSchema={NotificationsDiscordSchema}
|
||||
@@ -84,6 +95,7 @@ const NotificationsDiscord = () => {
|
||||
botUsername: values.botUsername,
|
||||
botAvatarUrl: values.botAvatarUrl,
|
||||
webhookUrl: values.webhookUrl,
|
||||
webhookRoleId: values.webhookRoleId,
|
||||
enableMentions: values.enableMentions,
|
||||
},
|
||||
}),
|
||||
@@ -141,6 +153,7 @@ const NotificationsDiscord = () => {
|
||||
botUsername: values.botUsername,
|
||||
botAvatarUrl: values.botAvatarUrl,
|
||||
webhookUrl: values.webhookUrl,
|
||||
webhookRoleId: values.webhookRoleId,
|
||||
enableMentions: values.enableMentions,
|
||||
},
|
||||
}),
|
||||
@@ -254,6 +267,21 @@ const NotificationsDiscord = () => {
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
<div className="form-row">
|
||||
<label htmlFor="webhookRoleId" className="text-label">
|
||||
{intl.formatMessage(messages.webhookRoleId)}
|
||||
</label>
|
||||
<div className="form-input-area">
|
||||
<div className="form-input-field">
|
||||
<Field id="webhookRoleId" name="webhookRoleId" type="text" />
|
||||
</div>
|
||||
{errors.webhookRoleId &&
|
||||
touched.webhookRoleId &&
|
||||
typeof errors.webhookRoleId === 'string' && (
|
||||
<div className="error">{errors.webhookRoleId}</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
<div className="form-row">
|
||||
<label htmlFor="enableMentions" className="checkbox-label">
|
||||
{intl.formatMessage(messages.enableMentions)}
|
||||
|
||||
@@ -727,6 +727,9 @@
|
||||
"components.Settings.Notifications.validationSmtpPortRequired": "You must provide a valid port number",
|
||||
"components.Settings.Notifications.validationTypes": "You must select at least one notification type",
|
||||
"components.Settings.Notifications.validationUrl": "You must provide a valid URL",
|
||||
"components.Settings.Notifications.validationWebhookRoleId": "You must provide a valid Discord Role ID",
|
||||
"components.Settings.Notifications.webhookRoleId": "Notification Role ID",
|
||||
"components.Settings.Notifications.webhookRoleIdTip": "The role ID to mention in the webhook message. Leave empty to disable mentions",
|
||||
"components.Settings.Notifications.webhookUrl": "Webhook URL",
|
||||
"components.Settings.Notifications.webhookUrlTip": "Create a <DiscordWebhookLink>webhook integration</DiscordWebhookLink> in your server",
|
||||
"components.Settings.RadarrModal.add": "Add Server",
|
||||
@@ -1094,7 +1097,7 @@
|
||||
"components.Setup.finishing": "Finishing…",
|
||||
"components.Setup.servertype": "Choose Server Type",
|
||||
"components.Setup.setup": "Setup",
|
||||
"components.Setup.signin": "Sign in to your account",
|
||||
"components.Setup.signin": "Sign In",
|
||||
"components.Setup.signinMessage": "Get started by signing in",
|
||||
"components.Setup.signinWithEmby": "Enter your Emby details",
|
||||
"components.Setup.signinWithJellyfin": "Enter your Jellyfin details",
|
||||
|
||||
Reference in New Issue
Block a user