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
pull/2447/head
Danshil Kokil Mungur 3 years ago committed by GitHub
parent eb9ca2e86f
commit f9200b7977
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -11,3 +11,7 @@ User notifications are separate from system notifications, and the available not
### Access Token ### Access Token
[Create an access token](https://www.pushbullet.com/#settings) and set it here to grant Overseerr access to the Pushbullet API. [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.

@ -1239,6 +1239,9 @@ components:
properties: properties:
accessToken: accessToken:
type: string type: string
channelTag:
type: string
nullable: true
PushoverSettings: PushoverSettings:
type: object type: object
properties: properties:

@ -19,6 +19,7 @@ interface PushbulletPayload {
type: string; type: string;
title: string; title: string;
body: string; body: string;
channel_tag?: string;
} }
class PushbulletAgent class PushbulletAgent
@ -116,11 +117,15 @@ class PushbulletAgent
}); });
try { try {
await axios.post(endpoint, notificationPayload, { await axios.post(
headers: { endpoint,
'Access-Token': settings.options.accessToken, { ...notificationPayload, channel_tag: settings.options.channelTag },
}, {
}); headers: {
'Access-Token': settings.options.accessToken,
},
}
);
} catch (e) { } catch (e) {
logger.error('Error sending Pushbullet notification', { logger.error('Error sending Pushbullet notification', {
label: 'Notifications', label: 'Notifications',
@ -188,8 +193,9 @@ class PushbulletAgent
.map(async (user) => { .map(async (user) => {
if ( if (
user.settings?.pushbulletAccessToken && user.settings?.pushbulletAccessToken &&
user.settings.pushbulletAccessToken !== (settings.options.channelTag ||
settings.options.accessToken user.settings.pushbulletAccessToken !==
settings.options.accessToken)
) { ) {
logger.debug('Sending Pushbullet notification', { logger.debug('Sending Pushbullet notification', {
label: 'Notifications', label: 'Notifications',

@ -181,6 +181,7 @@ export interface NotificationAgentTelegram extends NotificationAgentConfig {
export interface NotificationAgentPushbullet extends NotificationAgentConfig { export interface NotificationAgentPushbullet extends NotificationAgentConfig {
options: { options: {
accessToken: string; accessToken: string;
channelTag?: string;
}; };
} }

@ -18,6 +18,7 @@ const messages = defineMessages({
accessTokenTip: accessTokenTip:
'Create a token from your <PushbulletSettingsLink>Account Settings</PushbulletSettingsLink>', 'Create a token from your <PushbulletSettingsLink>Account Settings</PushbulletSettingsLink>',
validationAccessTokenRequired: 'You must provide an access token', validationAccessTokenRequired: 'You must provide an access token',
channelTag: 'Channel Tag',
pushbulletSettingsSaved: pushbulletSettingsSaved:
'Pushbullet notification settings saved successfully!', 'Pushbullet notification settings saved successfully!',
pushbulletSettingsFailed: 'Pushbullet notification settings failed to save.', pushbulletSettingsFailed: 'Pushbullet notification settings failed to save.',
@ -57,6 +58,7 @@ const NotificationsPushbullet: React.FC = () => {
enabled: data?.enabled, enabled: data?.enabled,
types: data?.types, types: data?.types,
accessToken: data?.options.accessToken, accessToken: data?.options.accessToken,
channelTag: data.options.channelTag,
}} }}
validationSchema={NotificationsPushbulletSchema} validationSchema={NotificationsPushbulletSchema}
onSubmit={async (values) => { onSubmit={async (values) => {
@ -66,6 +68,7 @@ const NotificationsPushbullet: React.FC = () => {
types: values.types, types: values.types,
options: { options: {
accessToken: values.accessToken, accessToken: values.accessToken,
channelTag: values.channelTag,
}, },
}); });
addToast(intl.formatMessage(messages.pushbulletSettingsSaved), { addToast(intl.formatMessage(messages.pushbulletSettingsSaved), {
@ -110,6 +113,7 @@ const NotificationsPushbullet: React.FC = () => {
types: values.types, types: values.types,
options: { options: {
accessToken: values.accessToken, accessToken: values.accessToken,
channelTag: values.channelTag,
}, },
}); });
@ -181,6 +185,16 @@ const NotificationsPushbullet: React.FC = () => {
)} )}
</div> </div>
</div> </div>
<div className="form-row">
<label htmlFor="channelTag" className="text-label">
{intl.formatMessage(messages.channelTag)}
</label>
<div className="form-input">
<div className="form-input-field">
<Field id="channelTag" name="channelTag" type="text" />
</div>
</div>
</div>
<NotificationTypeSelector <NotificationTypeSelector
currentTypes={values.enabled ? values.types : 0} currentTypes={values.enabled ? values.types : 0}
onUpdate={(newTypes) => { onUpdate={(newTypes) => {

@ -401,6 +401,7 @@
"components.Settings.Notifications.NotificationsPushbullet.accessToken": "Access Token", "components.Settings.Notifications.NotificationsPushbullet.accessToken": "Access Token",
"components.Settings.Notifications.NotificationsPushbullet.accessTokenTip": "Create a token from your <PushbulletSettingsLink>Account Settings</PushbulletSettingsLink>", "components.Settings.Notifications.NotificationsPushbullet.accessTokenTip": "Create a token from your <PushbulletSettingsLink>Account Settings</PushbulletSettingsLink>",
"components.Settings.Notifications.NotificationsPushbullet.agentEnabled": "Enable Agent", "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.pushbulletSettingsFailed": "Pushbullet notification settings failed to save.",
"components.Settings.Notifications.NotificationsPushbullet.pushbulletSettingsSaved": "Pushbullet notification settings saved successfully!", "components.Settings.Notifications.NotificationsPushbullet.pushbulletSettingsSaved": "Pushbullet notification settings saved successfully!",
"components.Settings.Notifications.NotificationsPushbullet.toastPushbulletTestFailed": "Pushbullet test notification failed to send.", "components.Settings.Notifications.NotificationsPushbullet.toastPushbulletTestFailed": "Pushbullet test notification failed to send.",

Loading…
Cancel
Save