mirror of
https://github.com/sct/overseerr.git
synced 2025-09-17 17:24:35 +02:00
feat(notif): add settings for Discord bot username & avatar URL (#1113)
This commit is contained in:
@@ -1102,6 +1102,10 @@ components:
|
||||
options:
|
||||
type: object
|
||||
properties:
|
||||
botUsername:
|
||||
type: string
|
||||
botAvatarUrl:
|
||||
type: string
|
||||
webhookUrl:
|
||||
type: string
|
||||
SlackSettings:
|
||||
@@ -1146,10 +1150,14 @@ components:
|
||||
options:
|
||||
type: object
|
||||
properties:
|
||||
botUsername:
|
||||
type: string
|
||||
botAPI:
|
||||
type: string
|
||||
chatId:
|
||||
type: string
|
||||
sendSilently:
|
||||
type: boolean
|
||||
PushbulletSettings:
|
||||
type: object
|
||||
properties:
|
||||
|
@@ -71,7 +71,7 @@ interface DiscordRichEmbed {
|
||||
|
||||
interface DiscordWebhookPayload {
|
||||
embeds: DiscordRichEmbed[];
|
||||
username: string;
|
||||
username?: string;
|
||||
avatar_url?: string;
|
||||
tts: boolean;
|
||||
content?: string;
|
||||
@@ -203,8 +203,11 @@ class DiscordAgent
|
||||
): Promise<boolean> {
|
||||
logger.debug('Sending discord notification', { label: 'Notifications' });
|
||||
try {
|
||||
const settings = getSettings();
|
||||
const webhookUrl = this.getSettings().options.webhookUrl;
|
||||
const {
|
||||
botUsername,
|
||||
botAvatarUrl,
|
||||
webhookUrl,
|
||||
} = this.getSettings().options;
|
||||
|
||||
if (!webhookUrl) {
|
||||
return false;
|
||||
@@ -222,7 +225,8 @@ class DiscordAgent
|
||||
}
|
||||
|
||||
await axios.post(webhookUrl, {
|
||||
username: settings.main.applicationTitle,
|
||||
username: botUsername,
|
||||
avatar_url: botAvatarUrl,
|
||||
embeds: [this.buildEmbed(type, payload)],
|
||||
content,
|
||||
allowed_mentions: {
|
||||
|
@@ -95,6 +95,8 @@ export interface NotificationAgentConfig {
|
||||
}
|
||||
export interface NotificationAgentDiscord extends NotificationAgentConfig {
|
||||
options: {
|
||||
botUsername?: string;
|
||||
botAvatarUrl?: string;
|
||||
webhookUrl: string;
|
||||
};
|
||||
}
|
||||
@@ -120,7 +122,7 @@ export interface NotificationAgentEmail extends NotificationAgentConfig {
|
||||
|
||||
export interface NotificationAgentTelegram extends NotificationAgentConfig {
|
||||
options: {
|
||||
botUsername: string;
|
||||
botUsername?: string;
|
||||
botAPI: string;
|
||||
chatId: string;
|
||||
sendSilently: boolean;
|
||||
@@ -229,6 +231,8 @@ class Settings {
|
||||
enabled: false,
|
||||
types: 0,
|
||||
options: {
|
||||
botUsername: '',
|
||||
botAvatarUrl: '',
|
||||
webhookUrl: '',
|
||||
},
|
||||
},
|
||||
|
@@ -13,6 +13,8 @@ const messages = defineMessages({
|
||||
save: 'Save Changes',
|
||||
saving: 'Saving…',
|
||||
agentenabled: 'Enable Agent',
|
||||
botUsername: 'Bot Username',
|
||||
botAvatarUrl: 'Bot Avatar URL',
|
||||
webhookUrl: 'Webhook URL',
|
||||
webhookUrlPlaceholder: 'Server Settings → Integrations → Webhooks',
|
||||
discordsettingssaved: 'Discord notification settings saved successfully!',
|
||||
@@ -20,7 +22,7 @@ const messages = defineMessages({
|
||||
testsent: 'Test notification sent!',
|
||||
test: 'Test',
|
||||
notificationtypes: 'Notification Types',
|
||||
validationWebhookUrl: 'You must provide a valid URL',
|
||||
validationUrl: 'You must provide a valid URL',
|
||||
});
|
||||
|
||||
const NotificationsDiscord: React.FC = () => {
|
||||
@@ -31,9 +33,12 @@ const NotificationsDiscord: React.FC = () => {
|
||||
);
|
||||
|
||||
const NotificationsDiscordSchema = Yup.object().shape({
|
||||
botAvatarUrl: Yup.string()
|
||||
.nullable()
|
||||
.url(intl.formatMessage(messages.validationUrl)),
|
||||
webhookUrl: Yup.string()
|
||||
.required(intl.formatMessage(messages.validationWebhookUrl))
|
||||
.url(intl.formatMessage(messages.validationWebhookUrl)),
|
||||
.required(intl.formatMessage(messages.validationUrl))
|
||||
.url(intl.formatMessage(messages.validationUrl)),
|
||||
});
|
||||
|
||||
if (!data && !error) {
|
||||
@@ -45,6 +50,8 @@ const NotificationsDiscord: React.FC = () => {
|
||||
initialValues={{
|
||||
enabled: data.enabled,
|
||||
types: data.types,
|
||||
botUsername: data?.options.botUsername,
|
||||
botAvatarUrl: data?.options.botAvatarUrl,
|
||||
webhookUrl: data.options.webhookUrl,
|
||||
}}
|
||||
validationSchema={NotificationsDiscordSchema}
|
||||
@@ -54,6 +61,8 @@ const NotificationsDiscord: React.FC = () => {
|
||||
enabled: values.enabled,
|
||||
types: values.types,
|
||||
options: {
|
||||
botUsername: values.botUsername,
|
||||
botAvatarUrl: values.botAvatarUrl,
|
||||
webhookUrl: values.webhookUrl,
|
||||
},
|
||||
});
|
||||
@@ -77,6 +86,8 @@ const NotificationsDiscord: React.FC = () => {
|
||||
enabled: true,
|
||||
types: values.types,
|
||||
options: {
|
||||
botUsername: values.botUsername,
|
||||
botAvatarUrl: values.botAvatarUrl,
|
||||
webhookUrl: values.webhookUrl,
|
||||
},
|
||||
});
|
||||
@@ -97,6 +108,42 @@ const NotificationsDiscord: React.FC = () => {
|
||||
<Field type="checkbox" id="enabled" name="enabled" />
|
||||
</div>
|
||||
</div>
|
||||
<div className="form-row">
|
||||
<label htmlFor="botUsername" className="text-label">
|
||||
{intl.formatMessage(messages.botUsername)}
|
||||
</label>
|
||||
<div className="form-input">
|
||||
<div className="flex max-w-lg rounded-md shadow-sm">
|
||||
<Field
|
||||
id="botUsername"
|
||||
name="botUsername"
|
||||
type="text"
|
||||
placeholder={intl.formatMessage(messages.botUsername)}
|
||||
/>
|
||||
</div>
|
||||
{errors.botUsername && touched.botUsername && (
|
||||
<div className="error">{errors.botUsername}</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
<div className="form-row">
|
||||
<label htmlFor="botAvatarUrl" className="text-label">
|
||||
{intl.formatMessage(messages.botAvatarUrl)}
|
||||
</label>
|
||||
<div className="form-input">
|
||||
<div className="flex max-w-lg rounded-md shadow-sm">
|
||||
<Field
|
||||
id="botAvatarUrl"
|
||||
name="botAvatarUrl"
|
||||
type="text"
|
||||
placeholder={intl.formatMessage(messages.botAvatarUrl)}
|
||||
/>
|
||||
</div>
|
||||
{errors.botAvatarUrl && touched.botAvatarUrl && (
|
||||
<div className="error">{errors.botAvatarUrl}</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
<div className="form-row">
|
||||
<label htmlFor="name" className="text-label">
|
||||
{intl.formatMessage(messages.webhookUrl)}
|
||||
|
@@ -311,6 +311,7 @@
|
||||
"components.Settings.Notifications.authPass": "SMTP Password",
|
||||
"components.Settings.Notifications.authUser": "SMTP Username",
|
||||
"components.Settings.Notifications.botAPI": "Bot Authentication Token",
|
||||
"components.Settings.Notifications.botAvatarUrl": "Bot Avatar URL",
|
||||
"components.Settings.Notifications.botUsername": "Bot Username",
|
||||
"components.Settings.Notifications.chatId": "Chat ID",
|
||||
"components.Settings.Notifications.discordsettingsfailed": "Discord notification settings failed to save.",
|
||||
@@ -341,7 +342,7 @@
|
||||
"components.Settings.Notifications.validationEmail": "You must provide a valid email address",
|
||||
"components.Settings.Notifications.validationSmtpHostRequired": "You must provide an SMTP host",
|
||||
"components.Settings.Notifications.validationSmtpPortRequired": "You must provide an SMTP port",
|
||||
"components.Settings.Notifications.validationWebhookUrl": "You must provide a valid URL",
|
||||
"components.Settings.Notifications.validationUrl": "You must provide a valid URL",
|
||||
"components.Settings.Notifications.webhookUrl": "Webhook URL",
|
||||
"components.Settings.Notifications.webhookUrlPlaceholder": "Server Settings → Integrations → Webhooks",
|
||||
"components.Settings.RadarrModal.add": "Add Server",
|
||||
|
Reference in New Issue
Block a user