Merge pull request #5670 from nextcloud/backport-5669-fix-remote-share-activity-emails

[stable12] Fix remote share activity emails
This commit is contained in:
Morris Jobke 2017-07-11 12:21:30 +02:00 committed by GitHub
commit ad7e6cfc9c
2 changed files with 14 additions and 8 deletions

View File

@ -318,14 +318,15 @@ class RequestHandlerController extends OCSController {
}
protected function executeAcceptShare(Share\IShare $share) {
list($file, $link) = $this->getFile($this->getCorrectUid($share), $share->getNode()->getId());
$fileId = (int) $share->getNode()->getId();
list($file, $link) = $this->getFile($this->getCorrectUid($share), $fileId);
$event = \OC::$server->getActivityManager()->generateEvent();
$event->setApp('files_sharing')
->setType('remote_share')
->setAffectedUser($this->getCorrectUid($share))
->setSubject(RemoteShares::SUBJECT_REMOTE_SHARE_ACCEPTED, [$share->getSharedWith(), $file])
->setObject('files', (int)$share->getNode()->getId(), $file)
->setSubject(RemoteShares::SUBJECT_REMOTE_SHARE_ACCEPTED, [$share->getSharedWith(), [$fileId => $file]])
->setObject('files', $fileId, $file)
->setLink($link);
\OC::$server->getActivityManager()->publish($event);
}
@ -373,14 +374,15 @@ class RequestHandlerController extends OCSController {
*/
protected function executeDeclineShare(Share\IShare $share) {
$this->federatedShareProvider->removeShareFromTable($share);
list($file, $link) = $this->getFile($this->getCorrectUid($share), $share->getNode()->getId());
$fileId = (int) $share->getNode()->getId();
list($file, $link) = $this->getFile($this->getCorrectUid($share), $fileId);
$event = \OC::$server->getActivityManager()->generateEvent();
$event->setApp('files_sharing')
->setType('remote_share')
->setAffectedUser($this->getCorrectUid($share))
->setSubject(RemoteShares::SUBJECT_REMOTE_SHARE_DECLINED, [$share->getSharedWith(), $file])
->setObject('files', (int)$share->getNode()->getId(), $file)
->setSubject(RemoteShares::SUBJECT_REMOTE_SHARE_DECLINED, [$share->getSharedWith(), [$fileId => $file]])
->setObject('files', $fileId, $file)
->setLink($link);
\OC::$server->getActivityManager()->publish($event);
@ -449,7 +451,7 @@ class RequestHandlerController extends OCSController {
$event = \OC::$server->getActivityManager()->generateEvent();
$event->setApp('files_sharing')
->setType('remote_share')
->setSubject(RemoteShares::SUBJECT_REMOTE_SHARE_UNSHARED, [$owner, $path])
->setSubject(RemoteShares::SUBJECT_REMOTE_SHARE_UNSHARED, [$owner->getId(), $path])
->setAffectedUser($user)
->setObject('remote_share', (int)$share['id'], $path);
\OC::$server->getActivityManager()->publish($event);

View File

@ -131,8 +131,12 @@ class RemoteShares extends Base {
];
case self::SUBJECT_REMOTE_SHARE_ACCEPTED:
case self::SUBJECT_REMOTE_SHARE_DECLINED:
$fileParameter = $parameters[1];
if (!is_array($fileParameter)) {
$fileParameter = [$event->getObjectId() => $event->getObjectName()];
}
return [
'file' => $this->getFile([$event->getObjectId() => $event->getObjectName()]),
'file' => $this->getFile($fileParameter),
'user' => $this->getFederatedUser($parameters[0]),
];
}