$target = \OC\Files\Filesystem::normalizePath($target);
$share->setTarget($target);
+ //Get sharewith for hooks
+ $sharedWith = null;
+ if ($share->getShareType() === \OCP\Share::SHARE_TYPE_USER) {
+ $sharedWith = $share->getSharedWith()->getUID();
+ } else if ($share->getShareType() === \OCP\Share::SHARE_TYPE_GROUP) {
+ $sharedWith = $share->getSharedWith()->getGID();
+ } else {
+ $sharedWith = $share->getSharedWith();
+ }
+
// Pre share hook
$run = true;
$error = '';
'fileSource' => $share->getPath()->getId(),
'expiration' => $share->getExpirationDate(),
'token' => $share->getToken(),
+ 'itemTarget' => $share->getTarget(),
+ 'shareWith' => $sharedWith,
'run' => &$run,
- 'error' => &$error
+ 'error' => &$error,
];
\OC_Hook::emit('OCP\Share', 'pre_shared', $preHookData);
'expiration' => $share->getExpirationDate(),
'token' => $share->getToken(),
'id' => $share->getId(),
+ 'shareWith' => $sharedWith,
+ 'itemTarget' => $share->getTarget(),
+ 'fileTarget' => $share->getTarget(),
];
+
\OC_Hook::emit('OCP\Share', 'post_shared', $postHookData);
return $share;
$share->expects($this->once())
->method('setTarget')
->with('/target');
+ $share->method('getTarget')
+ ->willReturn('/target');
$share->expects($this->once())
->method('setExpirationDate')
->with($date);
'token' => 'token',
'run' => true,
'error' => '',
+ 'itemTarget' => '/target',
+ 'shareWith' => null,
];
$hookListnerExpectsPost = [
'expiration' => $date,
'token' => 'token',
'id' => 42,
+ 'itemTarget' => '/target',
+ 'fileTarget' => '/target',
+ 'shareWith' => null,
];
$share->method('getId')->willReturn(42);