Skip to content

Commit

Permalink
Merge pull request #35135 from owncloud/fix-fed-not-release-10.2.0
Browse files Browse the repository at this point in the history
[10.2.0] Backport of dont show notification if federated share auto…
  • Loading branch information
Vincent Petry authored May 2, 2019
2 parents c515df5 + dabfab2 commit b4ca957
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 21 deletions.
33 changes: 18 additions & 15 deletions apps/federatedfilesharing/lib/FedShareManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,9 @@ public function createShare(Address $ownerAddress,
$token
) {
$owner = $ownerAddress->getUserId();
$remote = $ownerAddress->getOrigin();
$shareId = $this->federatedShareProvider->addShare(
$ownerAddress->getOrigin(), $token, $name, $owner, $shareWith, $remoteId
$remote, $token, $name, $owner, $shareWith, $remoteId
);

$this->eventDispatcher->dispatch(
Expand Down Expand Up @@ -163,20 +164,22 @@ public function createShare(Address $ownerAddress,
$sharedByAddress->getCloudId(),
\trim($name, '/')
];
$notification = $this->createNotification($shareWith);
$notification->setDateTime(new \DateTime())
->setObject('remote_share', $shareId)
->setSubject('remote_share', $params)
->setMessage('remote_share', $params);
$declineAction = $notification->createAction();
$declineAction->setLabel('decline')
->setLink($link, 'DELETE');
$notification->addAction($declineAction);
$acceptAction = $notification->createAction();
$acceptAction->setLabel('accept')
->setLink($link, 'POST');
$notification->addAction($acceptAction);
$this->notificationManager->notify($notification);
if (!$this->federatedShareProvider->getAccepted($remote, $shareWith)) {
$notification = $this->createNotification($shareWith);
$notification->setDateTime(new \DateTime())
->setObject('remote_share', $shareId)
->setSubject('remote_share', $params)
->setMessage('remote_share', $params);
$declineAction = $notification->createAction();
$declineAction->setLabel('decline')
->setLink($link, 'DELETE');
$notification->addAction($declineAction);
$acceptAction = $notification->createAction();
$acceptAction->setLabel('accept')
->setLink($link, 'POST');
$notification->addAction($acceptAction);
$this->notificationManager->notify($notification);
}
}

/**
Expand Down
2 changes: 1 addition & 1 deletion apps/federatedfilesharing/lib/FederatedShareProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -1053,7 +1053,7 @@ public function addShare($remote, $token, $name, $owner, $shareWith, $remoteId)
*
* @return bool
*/
protected function getAccepted($remote, $shareWith) {
public function getAccepted($remote, $shareWith) {
$event = $this->eventDispatcher->dispatch(
'remoteshare.received',
new GenericEvent('', ['remote' => $remote])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -916,11 +916,7 @@ public function testGetAccepted($autoAddServers, $globalAutoAccept, $userAutoAcc
->with('remoteshare.received', $this->anything())
->willReturn($event);

$shouldAutoAccept = $this->invokePrivate(
$this->provider,
'getAccepted',
['remote', '[email protected]']
);
$shouldAutoAccept = $this->provider->getAccepted('remote', '[email protected]');

$this->assertEquals($expected, $shouldAutoAccept);
}
Expand Down

0 comments on commit b4ca957

Please sign in to comment.