diff options
author | Morris Jobke <hey@morrisjobke.de> | 2018-11-30 12:11:28 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-11-30 12:11:28 +0300 |
commit | b36fe13094a29f22be799e0cbc2ca2ce07c7c219 (patch) | |
tree | b47ba8ff76282cec639da54bac282ebceb6d6fe5 | |
parent | 8dbdd683b90f6f197176f4d9245b7d0b387c4fff (diff) | |
parent | f666b59ef998b53fae1c0fd243a9af19ea5a8621 (diff) |
Merge pull request #323 from nextcloud/backport/321/stable15v15.0.0RC2
[stable15] Create activity when user unshares a file themselves
-rw-r--r-- | lib/AppInfo/Application.php | 1 | ||||
-rwxr-xr-x | lib/FilesHooks.php | 21 |
2 files changed, 22 insertions, 0 deletions
diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php index 6e0e20a4..c5274f27 100644 --- a/lib/AppInfo/Application.php +++ b/lib/AppInfo/Application.php @@ -110,5 +110,6 @@ class Application extends App { $eventDispatcher = $this->getContainer()->getServer()->getEventDispatcher(); $eventDispatcher->addListener('OCP\Share::preUnshare', [FilesHooksStatic::class, 'unShare']); + $eventDispatcher->addListener('OCP\Share::postUnshareFromSelf', [FilesHooksStatic::class, 'unShare']); } } diff --git a/lib/FilesHooks.php b/lib/FilesHooks.php index 80ed4d93..44d4ea5e 100755 --- a/lib/FilesHooks.php +++ b/lib/FilesHooks.php @@ -788,6 +788,11 @@ class FilesHooks { * @throws \OCP\Files\NotFoundException */ protected function unshareFromUser(IShare $share) { + if ($share->getSharedWith() === $this->currentUser->getUID()) { + $this->selfUnshareFromUser($share); + return; + } + // User performing the share $this->shareNotificationForSharer('unshared_user_self', $share->getSharedWith(), $share->getNodeId(), $share->getNodeType()); @@ -806,6 +811,22 @@ class FilesHooks { } /** + * Unharing a file or folder from a user + * + * @param IShare $share + * @throws \OCP\Files\NotFoundException + */ + protected function selfUnshareFromUser(IShare $share) { + // User performing the share + $this->shareNotificationForSharer('self_unshared', $share->getSharedWith(), $share->getNodeId(), $share->getNodeType()); + + // Owner + if ($this->currentUser->getUID() !== null) { + $this->shareNotificationForOriginalOwners($this->currentUser->getUID(), 'self_unshared_by', $share->getSharedWith(), $share->getNodeId(), $share->getNodeType()); + } + } + + /** * Unsharing a file or folder from a group * * @param IShare $share |