diff options
author | Pauli Järvinen <pauli.jarvinen@gmail.com> | 2017-07-16 17:26:11 +0300 |
---|---|---|
committer | Pauli Järvinen <pauli.jarvinen@gmail.com> | 2017-07-20 14:45:46 +0300 |
commit | 7c4a15f2155748a73718bb7482bbcd524ab0e6fc (patch) | |
tree | 9c236b80df77912f1860b61a298f3f5a99bc3774 /lib | |
parent | 8dce97a3e17a42ce734d5ca10899a08b96721f18 (diff) | |
download | nextcloud-server-7c4a15f2155748a73718bb7482bbcd524ab0e6fc.tar.gz nextcloud-server-7c4a15f2155748a73718bb7482bbcd524ab0e6fc.zip |
Emit hook postUnshareFromSelf when the recipient of a share unshares it
- This kind of hook signal used to be emitted in the old Share library but it was missing from Share 2.0
Signed-off-by: Pauli Järvinen <pauli.jarvinen@gmail.com>
Diffstat (limited to 'lib')
-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 798ea937038..b90cc12fc85 100644 --- a/lib/private/Share20/Manager.php +++ b/lib/private/Share20/Manager.php @@ -873,6 +873,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); } /** |