diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Controller/DocumentController.php | 10 | ||||
-rw-r--r-- | lib/Events/BeforeFederationRedirectEvent.php | 46 |
2 files changed, 56 insertions, 0 deletions
diff --git a/lib/Controller/DocumentController.php b/lib/Controller/DocumentController.php index d021f536..aa98c239 100644 --- a/lib/Controller/DocumentController.php +++ b/lib/Controller/DocumentController.php @@ -11,6 +11,7 @@ namespace OCA\Richdocuments\Controller; +use OCA\Richdocuments\Events\BeforeFederationRedirectEvent; use OCA\Richdocuments\Service\FederationService; use OCA\Richdocuments\TokenManager; use \OCP\AppFramework\Controller; @@ -198,6 +199,15 @@ class DocumentController extends Controller { '&richdocuments_open=' . $item->getName() . '&richdocuments_fileId=' . $fileId . '&richdocuments_remote_access=' . $remote; + + $event = new BeforeFederationRedirectEvent( + $item, $relative, $remote + ); + $eventDispatcher = \OC::$server->getEventDispatcher(); + $eventDispatcher->dispatch(BeforeFederationRedirectEvent::class, $event); + if ($event->getRedirectUrl()) { + $url = $event->getRedirectUrl(); + } return new RedirectResponse($url); } $this->logger->warning('Failed to connect to remote collabora instance for ' . $fileId); diff --git a/lib/Events/BeforeFederationRedirectEvent.php b/lib/Events/BeforeFederationRedirectEvent.php new file mode 100644 index 00000000..40bb8b02 --- /dev/null +++ b/lib/Events/BeforeFederationRedirectEvent.php @@ -0,0 +1,46 @@ +<?php + +namespace OCA\Richdocuments\Events; + + +use OCP\Files\Node; +use Symfony\Component\EventDispatcher\Event; + +class BeforeFederationRedirectEvent extends Event { + + /** @var Node */ + private $node; + /** @var string */ + private $relativePath; + /** @var string|null */ + private $redirectUrl = null; + /** @var string */ + private $remote; + + public function __construct($node, $relativePath, $remote) { + $this->node = $node; + $this->relativePath = $relativePath; + $this->remote = $remote; + } + + public function getRelativePath() { + return $this->relativePath; + } + + public function getNode() { + return $this->node; + } + + public function getRemote() { + return $this->remote; + } + + public function setRedirectUrl($redirectUrl) { + $this->redirectUrl = $redirectUrl; + } + + public function getRedirectUrl() { + return $this->redirectUrl; + } + +}
\ No newline at end of file |