Skip to content

Commit

Permalink
Update ExternalSharesController.php
Browse files Browse the repository at this point in the history
decline share finished
  • Loading branch information
shokri-navid authored Feb 3, 2023
1 parent 353925d commit 7091790
Showing 1 changed file with 23 additions and 10 deletions.
33 changes: 23 additions & 10 deletions apps/files_sharing/lib/Controllers/ExternalSharesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,13 @@ public function index() {
* @param int $id
* @return JSONResponse
*/
public function create($id) {
$shareInfo = $this->externalManager->getShare($id);
public function create($id, $share_type) {
$manager = $this->getRelatedManager($share_type);
$shareInfo = $manager->getShare($id);

if ($shareInfo !== false) {
$mountPoint = $this->externalManager->getShareRecipientMountPoint($shareInfo);
$fileId = $this->externalManager->getShareFileId($shareInfo, $mountPoint);
$mountPoint = $manager->getShareRecipientMountPoint($shareInfo);
$fileId = $manager->getShareFileId($shareInfo, $mountPoint);

$event = new GenericEvent(
null,
Expand All @@ -109,8 +111,8 @@ public function create($id) {
'shareRecipient' => $shareInfo['user'],
]
);
$this->dispatcher->dispatch('remoteshare.accepted', $event);
$this->externalManager->acceptShare($id);
$this->dispatcher->dispatch($event, 'remoteshare.accepted', $event);
$manager->acceptShare($id);
}
return new JSONResponse();
}
Expand All @@ -122,8 +124,9 @@ public function create($id) {
* @param integer $id
* @return JSONResponse
*/
public function destroy($id) {
$shareInfo = $this->externalManager->getShare($id);
public function destroy($id, $share_type) {
$manager = $this->getRelatedManager($share_type);
$shareInfo = $manager->getShare($id);
if ($shareInfo !== false) {
$event = new GenericEvent(
null,
Expand All @@ -134,11 +137,21 @@ public function destroy($id) {
'remoteUrl' => $shareInfo['remote']
]
);
$this->dispatcher->dispatch('remoteshare.declined', $event);
$this->externalManager->declineShare($id);
$this->dispatcher->dispatch($event, 'remoteshare.declined');
$manager->declineShare($id);
}
return new JSONResponse();
}

private function getRelatedManager($share_type){
if($share_type === "group" && $this->groupExternalManager !== null) {
$manager = $this->groupExternalManager;
} else {
$manager = $this->externalManager;
}
return $manager;

}

/**
* Test whether the specified remote is accessible
Expand Down

0 comments on commit 7091790

Please sign in to comment.