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