From 1640980e2bbc56500d0c5a7b3abd4a702a7a6b01 Mon Sep 17 00:00:00 2001 From: Qstick Date: Sat, 19 Nov 2022 12:07:08 -0600 Subject: [PATCH] New: OnGrab Notifications --- frontend/src/Search/Table/SearchIndexRow.js | 18 ++++- frontend/src/Search/Table/SearchIndexTable.js | 5 +- .../Search/Table/SearchIndexTableConnector.js | 5 +- .../Notifications/Notification.js | 46 +---------- .../Notifications/NotificationEventItems.js | 28 +++++++ .../Store/Actions/Settings/notifications.js | 3 - frontend/src/Store/Actions/releaseActions.js | 29 +++++++ frontend/src/Utilities/createAjaxRequest.js | 6 ++ src/NzbDrone.Common/Http/UserAgentParser.cs | 5 -- .../NotificationBaseFixture.cs | 8 +- .../029_add_on_grab_to_notifications.cs | 15 ++++ src/NzbDrone.Core/Datastore/TableMapping.cs | 1 + src/NzbDrone.Core/Download/DownloadService.cs | 67 +++++++++++++--- src/NzbDrone.Core/History/HistoryService.cs | 2 +- .../Indexers/Events/IndexerDownloadEvent.cs | 19 ++++- src/NzbDrone.Core/Localization/Core/en.json | 4 +- .../Notifications/Apprise/Apprise.cs | 5 ++ .../Notifications/Boxcar/Boxcar.cs | 6 ++ .../Notifications/Discord/Discord.cs | 59 ++++++++++++++ .../Notifications/Discord/DiscordFieldType.cs | 31 ++------ .../Notifications/Discord/DiscordSettings.cs | 4 - .../Notifications/Email/Email.cs | 5 ++ .../Notifications/Gotify/Gotify.cs | 5 ++ .../Notifications/GrabMessage.cs | 25 ++++++ .../Notifications/INotification.cs | 2 + src/NzbDrone.Core/Notifications/Join/Join.cs | 5 ++ .../Notifications/Notifiarr/Notifiarr.cs | 6 ++ .../Notifications/NotificationBase.cs | 7 ++ .../Notifications/NotificationDefinition.cs | 5 +- .../Notifications/NotificationFactory.cs | 7 ++ .../Notifications/NotificationService.cs | 77 ++++++++++++++++++- src/NzbDrone.Core/Notifications/Ntfy/Ntfy.cs | 5 ++ .../Notifications/Prowl/Prowl.cs | 5 ++ .../Notifications/PushBullet/PushBullet.cs | 5 ++ .../Notifications/Pushover/Pushover.cs | 5 ++ .../Notifications/SendGrid/SendGrid.cs | 5 ++ .../Notifications/Simplepush/Simplepush.cs | 5 ++ .../Notifications/Telegram/Telegram.cs | 5 ++ .../Notifications/Twitter/Twitter.cs | 6 ++ .../Notifications/Webhook/Webhook.cs | 5 ++ .../Notifications/Webhook/WebhookBase.cs | 16 ++++ .../Webhook/WebhookGrabPayload.cs | 15 ++++ .../Notifications/Webhook/WebhookRelease.cs | 22 ++++++ .../Indexers/NewznabController.cs | 4 +- .../Notifications/NotificationResource.cs | 9 +++ src/Prowlarr.Api.V1/Search/ReleaseResource.cs | 16 ++++ .../Search/SearchController.cs | 4 +- .../Extensions/RequestExtensions.cs | 12 ++- 48 files changed, 543 insertions(+), 111 deletions(-) create mode 100644 src/NzbDrone.Core/Datastore/Migration/029_add_on_grab_to_notifications.cs create mode 100644 src/NzbDrone.Core/Notifications/GrabMessage.cs create mode 100644 src/NzbDrone.Core/Notifications/Webhook/WebhookGrabPayload.cs create mode 100644 src/NzbDrone.Core/Notifications/Webhook/WebhookRelease.cs diff --git a/frontend/src/Search/Table/SearchIndexRow.js b/frontend/src/Search/Table/SearchIndexRow.js index a54876c8f..2645c02eb 100644 --- a/frontend/src/Search/Table/SearchIndexRow.js +++ b/frontend/src/Search/Table/SearchIndexRow.js @@ -71,6 +71,19 @@ class SearchIndexRow extends Component { }); }; + onSavePress = () => { + const { + downloadUrl, + fileName, + onSavePress + } = this.props; + + onSavePress({ + downloadUrl, + fileName + }); + }; + // // Render @@ -85,7 +98,6 @@ class SearchIndexRow extends Component { publishDate, title, infoUrl, - downloadUrl, indexer, size, files, @@ -300,7 +312,7 @@ class SearchIndexRow extends Component { className={styles.downloadLink} name={icons.SAVE} title={translate('Save')} - to={downloadUrl} + onPress={this.onSavePress} /> ); @@ -323,6 +335,7 @@ SearchIndexRow.propTypes = { ageMinutes: PropTypes.number.isRequired, publishDate: PropTypes.string.isRequired, title: PropTypes.string.isRequired, + fileName: PropTypes.string.isRequired, infoUrl: PropTypes.string.isRequired, downloadUrl: PropTypes.string.isRequired, indexerId: PropTypes.number.isRequired, @@ -335,6 +348,7 @@ SearchIndexRow.propTypes = { indexerFlags: PropTypes.arrayOf(PropTypes.string).isRequired, columns: PropTypes.arrayOf(PropTypes.object).isRequired, onGrabPress: PropTypes.func.isRequired, + onSavePress: PropTypes.func.isRequired, isGrabbing: PropTypes.bool.isRequired, isGrabbed: PropTypes.bool.isRequired, grabError: PropTypes.string, diff --git a/frontend/src/Search/Table/SearchIndexTable.js b/frontend/src/Search/Table/SearchIndexTable.js index 7f1f44118..844628062 100644 --- a/frontend/src/Search/Table/SearchIndexTable.js +++ b/frontend/src/Search/Table/SearchIndexTable.js @@ -51,7 +51,8 @@ class SearchIndexTable extends Component { timeFormat, selectedState, onSelectedChange, - onGrabPress + onGrabPress, + onSavePress } = this.props; const release = items[rowIndex]; @@ -71,6 +72,7 @@ class SearchIndexTable extends Component { longDateFormat={longDateFormat} timeFormat={timeFormat} onGrabPress={onGrabPress} + onSavePress={onSavePress} /> ); @@ -134,6 +136,7 @@ SearchIndexTable.propTypes = { timeFormat: PropTypes.string.isRequired, onSortPress: PropTypes.func.isRequired, onGrabPress: PropTypes.func.isRequired, + onSavePress: PropTypes.func.isRequired, allSelected: PropTypes.bool.isRequired, allUnselected: PropTypes.bool.isRequired, selectedState: PropTypes.object.isRequired, diff --git a/frontend/src/Search/Table/SearchIndexTableConnector.js b/frontend/src/Search/Table/SearchIndexTableConnector.js index e73b9ab9a..13ab84c7d 100644 --- a/frontend/src/Search/Table/SearchIndexTableConnector.js +++ b/frontend/src/Search/Table/SearchIndexTableConnector.js @@ -1,6 +1,6 @@ import { connect } from 'react-redux'; import { createSelector } from 'reselect'; -import { grabRelease, setReleasesSort } from 'Store/Actions/releaseActions'; +import { grabRelease, saveRelease, setReleasesSort } from 'Store/Actions/releaseActions'; import createUISettingsSelector from 'Store/Selectors/createUISettingsSelector'; import SearchIndexTable from './SearchIndexTable'; @@ -25,6 +25,9 @@ function createMapDispatchToProps(dispatch, props) { }, onGrabPress(payload) { dispatch(grabRelease(payload)); + }, + onSavePress(payload) { + dispatch(saveRelease(payload)); } }; } diff --git a/frontend/src/Settings/Notifications/Notifications/Notification.js b/frontend/src/Settings/Notifications/Notifications/Notification.js index e4a2847d9..1331a7c8b 100644 --- a/frontend/src/Settings/Notifications/Notifications/Notification.js +++ b/frontend/src/Settings/Notifications/Notifications/Notification.js @@ -56,17 +56,9 @@ class Notification extends Component { id, name, onGrab, - onDownload, - onUpgrade, - onRename, - onDelete, onHealthIssue, onApplicationUpdate, supportsOnGrab, - supportsOnDownload, - supportsOnUpgrade, - supportsOnRename, - supportsOnDelete, supportsOnHealthIssue, supportsOnApplicationUpdate } = this.props; @@ -88,34 +80,6 @@ class Notification extends Component { } - { - supportsOnDelete && onDelete && - - } - - { - supportsOnDownload && onDownload && - - } - - { - supportsOnUpgrade && onDownload && onUpgrade && - - } - - { - supportsOnRename && onRename && - - } - { supportsOnHealthIssue && onHealthIssue &&