Skip to content

Commit

Permalink
feat(notif): add Pushbullet channel tag (#2198)
Browse files Browse the repository at this point in the history
* feat(notif): add pushbullet channel tag to server notif settings

* feat(notif): suggested changes

* docs(notif): add pushbullet channel tag
  • Loading branch information
danshilm committed Jan 20, 2022
1 parent eb9ca2e commit f9200b7
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 7 deletions.
4 changes: 4 additions & 0 deletions docs/using-overseerr/notifications/pushbullet.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
3 changes: 3 additions & 0 deletions overseerr-api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1239,6 +1239,9 @@ components:
properties:
accessToken:
type: string
channelTag:
type: string
nullable: true
PushoverSettings:
type: object
properties:
Expand Down
20 changes: 13 additions & 7 deletions server/lib/notifications/agents/pushbullet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ interface PushbulletPayload {
type: string;
title: string;
body: string;
channel_tag?: string;
}

class PushbulletAgent
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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',
Expand Down
1 change: 1 addition & 0 deletions server/lib/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ export interface NotificationAgentTelegram extends NotificationAgentConfig {
export interface NotificationAgentPushbullet extends NotificationAgentConfig {
options: {
accessToken: string;
channelTag?: string;
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const messages = defineMessages({
accessTokenTip:
'Create a token from your <PushbulletSettingsLink>Account Settings</PushbulletSettingsLink>',
validationAccessTokenRequired: 'You must provide an access token',
channelTag: 'Channel Tag',
pushbulletSettingsSaved:
'Pushbullet notification settings saved successfully!',
pushbulletSettingsFailed: 'Pushbullet notification settings failed to save.',
Expand Down Expand Up @@ -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) => {
Expand All @@ -66,6 +68,7 @@ const NotificationsPushbullet: React.FC = () => {
types: values.types,
options: {
accessToken: values.accessToken,
channelTag: values.channelTag,
},
});
addToast(intl.formatMessage(messages.pushbulletSettingsSaved), {
Expand Down Expand Up @@ -110,6 +113,7 @@ const NotificationsPushbullet: React.FC = () => {
types: values.types,
options: {
accessToken: values.accessToken,
channelTag: values.channelTag,
},
});

Expand Down Expand Up @@ -181,6 +185,16 @@ const NotificationsPushbullet: React.FC = () => {
)}
</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
currentTypes={values.enabled ? values.types : 0}
onUpdate={(newTypes) => {
Expand Down
1 change: 1 addition & 0 deletions src/i18n/locale/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,7 @@
"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.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.",
Expand Down

0 comments on commit f9200b7

Please sign in to comment.