Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/richdocuments.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJulius Härtl <jus@bitgrid.net>2020-08-21 16:48:15 +0300
committerJulius Härtl <jus@bitgrid.net>2020-10-13 15:36:52 +0300
commiteff8898bd86fc306775fe0e68c66c9a8f82cda0a (patch)
tree34706ec348bc0044a2950898b446d1d3c61aef1d /lib
parentcc164ab38817c0897ecb62634e3d8eb287757196 (diff)
Dispatch event to allow change of the redirect url
Signed-off-by: Julius Härtl <jus@bitgrid.net>
Diffstat (limited to 'lib')
-rw-r--r--lib/Controller/DocumentController.php10
-rw-r--r--lib/Events/BeforeFederationRedirectEvent.php46
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