mirror of
https://github.com/sct/overseerr.git
synced 2025-09-17 17:24:35 +02:00
feat(discord): add 'Enable Mentions' setting (#1779)
This commit is contained in:
@@ -1138,6 +1138,8 @@ components:
|
||||
type: string
|
||||
webhookUrl:
|
||||
type: string
|
||||
enableMentions:
|
||||
type: boolean
|
||||
SlackSettings:
|
||||
type: object
|
||||
properties:
|
||||
|
@@ -258,6 +258,7 @@ class DiscordAgent
|
||||
const userMentions: string[] = [];
|
||||
|
||||
try {
|
||||
if (settings.options.enableMentions) {
|
||||
if (payload.notifyUser) {
|
||||
if (
|
||||
payload.notifyUser.settings?.hasNotificationType(
|
||||
@@ -288,6 +289,7 @@ class DiscordAgent
|
||||
.map((user) => `<@${user.settings?.discordId}>`)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
await axios.post(settings.options.webhookUrl, {
|
||||
username: settings.options.botUsername
|
||||
|
@@ -125,6 +125,7 @@ export interface NotificationAgentDiscord extends NotificationAgentConfig {
|
||||
botUsername?: string;
|
||||
botAvatarUrl?: string;
|
||||
webhookUrl: string;
|
||||
enableMentions: boolean;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -304,6 +305,7 @@ class Settings {
|
||||
types: 0,
|
||||
options: {
|
||||
webhookUrl: '',
|
||||
enableMentions: true,
|
||||
},
|
||||
},
|
||||
lunasea: {
|
||||
|
@@ -252,9 +252,11 @@ userSettingsRoutes.get<{ id: string }, UserSettingsNotificationsResponse>(
|
||||
return res.status(200).json({
|
||||
emailEnabled: settings?.email.enabled,
|
||||
pgpKey: user.settings?.pgpKey,
|
||||
discordEnabled: settings?.discord.enabled,
|
||||
discordEnabledTypes: settings?.discord.enabled
|
||||
? settings?.discord.types
|
||||
discordEnabled:
|
||||
settings?.discord.enabled && settings.discord.options.enableMentions,
|
||||
discordEnabledTypes:
|
||||
settings?.discord.enabled && settings.discord.options.enableMentions
|
||||
? settings.discord.types
|
||||
: 0,
|
||||
discordId: user.settings?.discordId,
|
||||
pushbulletAccessToken: user.settings?.pushbulletAccessToken,
|
||||
|
@@ -26,6 +26,7 @@ const messages = defineMessages({
|
||||
toastDiscordTestFailed: 'Discord test notification failed to send.',
|
||||
validationUrl: 'You must provide a valid URL',
|
||||
validationTypes: 'You must select at least one notification type',
|
||||
enableMentions: 'Enable Mentions',
|
||||
});
|
||||
|
||||
const NotificationsDiscord: React.FC = () => {
|
||||
@@ -64,6 +65,7 @@ const NotificationsDiscord: React.FC = () => {
|
||||
botUsername: data?.options.botUsername,
|
||||
botAvatarUrl: data?.options.botAvatarUrl,
|
||||
webhookUrl: data.options.webhookUrl,
|
||||
enableMentions: data?.options.enableMentions,
|
||||
}}
|
||||
validationSchema={NotificationsDiscordSchema}
|
||||
onSubmit={async (values) => {
|
||||
@@ -75,6 +77,7 @@ const NotificationsDiscord: React.FC = () => {
|
||||
botUsername: values.botUsername,
|
||||
botAvatarUrl: values.botAvatarUrl,
|
||||
webhookUrl: values.webhookUrl,
|
||||
enableMentions: values.enableMentions,
|
||||
},
|
||||
});
|
||||
|
||||
@@ -122,6 +125,7 @@ const NotificationsDiscord: React.FC = () => {
|
||||
botUsername: values.botUsername,
|
||||
botAvatarUrl: values.botAvatarUrl,
|
||||
webhookUrl: values.webhookUrl,
|
||||
enableMentions: values.enableMentions,
|
||||
},
|
||||
});
|
||||
|
||||
@@ -227,6 +231,18 @@ const NotificationsDiscord: React.FC = () => {
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
<div className="form-row">
|
||||
<label htmlFor="enableMentions" className="checkbox-label">
|
||||
{intl.formatMessage(messages.enableMentions)}
|
||||
</label>
|
||||
<div className="form-input">
|
||||
<Field
|
||||
type="checkbox"
|
||||
id="enableMentions"
|
||||
name="enableMentions"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<NotificationTypeSelector
|
||||
currentTypes={values.enabled ? values.types : 0}
|
||||
onUpdate={(newTypes) => {
|
||||
|
@@ -448,6 +448,7 @@
|
||||
"components.Settings.Notifications.emailsender": "Sender Address",
|
||||
"components.Settings.Notifications.emailsettingsfailed": "Email notification settings failed to save.",
|
||||
"components.Settings.Notifications.emailsettingssaved": "Email notification settings saved successfully!",
|
||||
"components.Settings.Notifications.enableMentions": "Enable Mentions",
|
||||
"components.Settings.Notifications.encryption": "Encryption Method",
|
||||
"components.Settings.Notifications.encryptionDefault": "Use STARTTLS if available",
|
||||
"components.Settings.Notifications.encryptionImplicitTls": "Use Implicit TLS",
|
||||
|
Reference in New Issue
Block a user