diff options
author | Morris Jobke <hey@morrisjobke.de> | 2017-07-21 09:32:49 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-07-21 09:32:49 +0200 |
commit | b1954bed97ee37f80e5f0b3bc785c631462aeac7 (patch) | |
tree | 47e2604b8969cc4d6f70a89367d6b2428c149bc9 /lib/private/Share20 | |
parent | 8ef75f78a5101b05d7a9abba3575c55c7c3ab989 (diff) | |
parent | 7c4a15f2155748a73718bb7482bbcd524ab0e6fc (diff) | |
download | nextcloud-server-b1954bed97ee37f80e5f0b3bc785c631462aeac7.tar.gz nextcloud-server-b1954bed97ee37f80e5f0b3bc785c631462aeac7.zip |
Merge pull request #5797 from paulijar/share20-postUnshareFromSelf
Dispatch event postUnshareFromSelf when the recipient of a share unshares it
Diffstat (limited to 'lib/private/Share20')
-rw-r--r-- | lib/private/Share20/LegacyHooks.php | 15 | ||||
-rw-r--r-- | lib/private/Share20/Manager.php | 2 |
2 files changed, 17 insertions, 0 deletions
diff --git a/lib/private/Share20/LegacyHooks.php b/lib/private/Share20/LegacyHooks.php index 09acf6c50e7..e7fbe7336b8 100644 --- a/lib/private/Share20/LegacyHooks.php +++ b/lib/private/Share20/LegacyHooks.php @@ -40,6 +40,7 @@ class LegacyHooks { $this->eventDispatcher->addListener('OCP\Share::preUnshare', [$this, 'preUnshare']); $this->eventDispatcher->addListener('OCP\Share::postUnshare', [$this, 'postUnshare']); + $this->eventDispatcher->addListener('OCP\Share::postUnshareFromSelf', [$this, 'postUnshareFromSelf']); } /** @@ -74,6 +75,20 @@ class LegacyHooks { \OC_Hook::emit('OCP\Share', 'post_unshare', $formatted); } + /** + * @param GenericEvent $e + */ + public function postUnshareFromSelf(GenericEvent $e) { + /** @var IShare $share */ + $share = $e->getSubject(); + + $formatted = $this->formatHookParams($share); + $formatted['itemTarget'] = $formatted['fileTarget']; + $formatted['unsharedItems'] = [$formatted]; + + \OC_Hook::emit('OCP\Share', 'post_unshareFromSelf', $formatted); + } + private function formatHookParams(IShare $share) { // Prepare hook $shareType = $share->getShareType(); diff --git a/lib/private/Share20/Manager.php b/lib/private/Share20/Manager.php index f64ae5d39ee..ca9d8e2843f 100644 --- a/lib/private/Share20/Manager.php +++ b/lib/private/Share20/Manager.php @@ -871,6 +871,8 @@ class Manager implements IManager { $provider = $this->factory->getProvider($providerId); $provider->deleteFromSelf($share, $recipientId); + $event = new GenericEvent($share); + $this->eventDispatcher->dispatch('OCP\Share::postUnshareFromSelf', $event); } /** |