Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Create activity when user unshares a file themselves
Signed-off-by: Joas Schilling <[email protected]>
  • Loading branch information
nickvergessen committed Nov 23, 2018
commit f4b32780dfb068f5a19aa117ade1ae0e11b8ea1f
1 change: 1 addition & 0 deletions lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,5 +110,6 @@ public function registerFilesActivity() {

$eventDispatcher = $this->getContainer()->getServer()->getEventDispatcher();
$eventDispatcher->addListener('OCP\Share::preUnshare', [FilesHooksStatic::class, 'unShare']);
$eventDispatcher->addListener('OCP\Share::postUnshareFromSelf', [FilesHooksStatic::class, 'unShare']);
}
}
21 changes: 21 additions & 0 deletions lib/FilesHooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -788,6 +788,11 @@ public function unShare(IShare $share) {
* @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());

Expand All @@ -805,6 +810,22 @@ protected function unshareFromUser(IShare $share) {
);
}

/**
* 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
*
Expand Down