From f9200b7977208f9b8267ce3a74bd8a86d6f28f7b Mon Sep 17 00:00:00 2001 From: Danshil Kokil Mungur Date: Thu, 20 Jan 2022 15:38:24 +0400 Subject: [PATCH] feat(notif): add Pushbullet channel tag (#2198) * feat(notif): add pushbullet channel tag to server notif settings * feat(notif): suggested changes * docs(notif): add pushbullet channel tag --- .../notifications/pushbullet.md | 4 ++++ overseerr-api.yml | 3 +++ server/lib/notifications/agents/pushbullet.ts | 20 ++++++++++++------- server/lib/settings.ts | 1 + .../NotificationsPushbullet/index.tsx | 14 +++++++++++++ src/i18n/locale/en.json | 1 + 6 files changed, 36 insertions(+), 7 deletions(-) diff --git a/docs/using-overseerr/notifications/pushbullet.md b/docs/using-overseerr/notifications/pushbullet.md index 6c6ba853..6e9be9c2 100644 --- a/docs/using-overseerr/notifications/pushbullet.md +++ b/docs/using-overseerr/notifications/pushbullet.md @@ -11,3 +11,7 @@ User notifications are separate from system notifications, and the available not ### Access Token [Create an access token](https://www.pushbullet.com/#settings) and set it here to grant Overseerr access to the Pushbullet API. + +### Channel Tag (optional) + +Optionally, [create a channel](https://www.pushbullet.com/my-channel) to allow other users to follow the notification feed using the specified channel tag. diff --git a/overseerr-api.yml b/overseerr-api.yml index 7a87e8b8..8fc3fa1a 100644 --- a/overseerr-api.yml +++ b/overseerr-api.yml @@ -1239,6 +1239,9 @@ components: properties: accessToken: type: string + channelTag: + type: string + nullable: true PushoverSettings: type: object properties: diff --git a/server/lib/notifications/agents/pushbullet.ts b/server/lib/notifications/agents/pushbullet.ts index 092722c9..b7bc1919 100644 --- a/server/lib/notifications/agents/pushbullet.ts +++ b/server/lib/notifications/agents/pushbullet.ts @@ -19,6 +19,7 @@ interface PushbulletPayload { type: string; title: string; body: string; + channel_tag?: string; } class PushbulletAgent @@ -116,11 +117,15 @@ class PushbulletAgent }); try { - await axios.post(endpoint, notificationPayload, { - headers: { - 'Access-Token': settings.options.accessToken, - }, - }); + await axios.post( + endpoint, + { ...notificationPayload, channel_tag: settings.options.channelTag }, + { + headers: { + 'Access-Token': settings.options.accessToken, + }, + } + ); } catch (e) { logger.error('Error sending Pushbullet notification', { label: 'Notifications', @@ -188,8 +193,9 @@ class PushbulletAgent .map(async (user) => { if ( user.settings?.pushbulletAccessToken && - user.settings.pushbulletAccessToken !== - settings.options.accessToken + (settings.options.channelTag || + user.settings.pushbulletAccessToken !== + settings.options.accessToken) ) { logger.debug('Sending Pushbullet notification', { label: 'Notifications', diff --git a/server/lib/settings.ts b/server/lib/settings.ts index 4c3b715c..7a4f5f93 100644 --- a/server/lib/settings.ts +++ b/server/lib/settings.ts @@ -181,6 +181,7 @@ export interface NotificationAgentTelegram extends NotificationAgentConfig { export interface NotificationAgentPushbullet extends NotificationAgentConfig { options: { accessToken: string; + channelTag?: string; }; } diff --git a/src/components/Settings/Notifications/NotificationsPushbullet/index.tsx b/src/components/Settings/Notifications/NotificationsPushbullet/index.tsx index 8ad30dc3..a4489375 100644 --- a/src/components/Settings/Notifications/NotificationsPushbullet/index.tsx +++ b/src/components/Settings/Notifications/NotificationsPushbullet/index.tsx @@ -18,6 +18,7 @@ const messages = defineMessages({ accessTokenTip: 'Create a token from your Account Settings', validationAccessTokenRequired: 'You must provide an access token', + channelTag: 'Channel Tag', pushbulletSettingsSaved: 'Pushbullet notification settings saved successfully!', pushbulletSettingsFailed: 'Pushbullet notification settings failed to save.', @@ -57,6 +58,7 @@ const NotificationsPushbullet: React.FC = () => { enabled: data?.enabled, types: data?.types, accessToken: data?.options.accessToken, + channelTag: data.options.channelTag, }} validationSchema={NotificationsPushbulletSchema} onSubmit={async (values) => { @@ -66,6 +68,7 @@ const NotificationsPushbullet: React.FC = () => { types: values.types, options: { accessToken: values.accessToken, + channelTag: values.channelTag, }, }); addToast(intl.formatMessage(messages.pushbulletSettingsSaved), { @@ -110,6 +113,7 @@ const NotificationsPushbullet: React.FC = () => { types: values.types, options: { accessToken: values.accessToken, + channelTag: values.channelTag, }, }); @@ -181,6 +185,16 @@ const NotificationsPushbullet: React.FC = () => { )} +
+ +
+
+ +
+
+
{ diff --git a/src/i18n/locale/en.json b/src/i18n/locale/en.json index a17fdc4f..72a8c9c1 100644 --- a/src/i18n/locale/en.json +++ b/src/i18n/locale/en.json @@ -401,6 +401,7 @@ "components.Settings.Notifications.NotificationsPushbullet.accessToken": "Access Token", "components.Settings.Notifications.NotificationsPushbullet.accessTokenTip": "Create a token from your Account Settings", "components.Settings.Notifications.NotificationsPushbullet.agentEnabled": "Enable Agent", + "components.Settings.Notifications.NotificationsPushbullet.channelTag": "Channel Tag", "components.Settings.Notifications.NotificationsPushbullet.pushbulletSettingsFailed": "Pushbullet notification settings failed to save.", "components.Settings.Notifications.NotificationsPushbullet.pushbulletSettingsSaved": "Pushbullet notification settings saved successfully!", "components.Settings.Notifications.NotificationsPushbullet.toastPushbulletTestFailed": "Pushbullet test notification failed to send.",