diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php index a66ee926..0c3c7dee 100644 --- a/lib/AppInfo/Application.php +++ b/lib/AppInfo/Application.php @@ -301,6 +301,7 @@ public function registerHooksAndEvents() { $eventDispatcher->addListener('OCA\Files::loadAdditionalScripts', ['OCA\Activity\FilesHooksStatic', 'onLoadFilesAppScripts']); $eventDispatcher->addListener('remoteshare.accepted', ['OCA\Activity\Hooks', 'onRemoteShareAccepted']); + $eventDispatcher->addListener('share.afterreject', ['OCA\Activity\FilesHooksStatic', 'unShare']); Util::connectHook('OC_User', 'post_deleteUser', 'OCA\Activity\Hooks', 'deleteUser'); @@ -320,5 +321,6 @@ public function registerFilesActivity() { Util::connectHook('\OCA\Files_Trashbin\Trashbin', 'post_restore', 'OCA\Activity\FilesHooksStatic', 'fileRestore'); Util::connectHook('OCP\Share', 'post_shared', 'OCA\Activity\FilesHooksStatic', 'share'); Util::connectHook('OCP\Share', 'pre_unshare', 'OCA\Activity\FilesHooksStatic', 'unShare'); + } } diff --git a/lib/FilesHooks.php b/lib/FilesHooks.php index 55d58c9a..cb812d5b 100755 --- a/lib/FilesHooks.php +++ b/lib/FilesHooks.php @@ -206,6 +206,17 @@ protected function addNotificationsForFileAction($filePath, $activityType, $subj return; } + // skip notifications for rejected shares + $this->view->chroot('/' . $this->currentUser . '/files'); + $mount = $this->view->getMount($filePath); + $storage = $mount->getStorage(); + if ($storage->instanceOfStorage('OC\Files\Storage\Shared')) { + $rejectedShare = $storage->getShare(); + if ($rejectedShare->getState() === Share::STATE_REJECTED) { + return; + } + } + list($filePath, $uidOwner, $fileId) = $this->getSourcePathAndOwner($filePath); if (!$fileId) { // no owner, possibly deleted or unknown