From a616219e3f8c2724e0e28bf3623420da28eeea17 Mon Sep 17 00:00:00 2001 From: Maxence Lange Date: Mon, 1 Mar 2021 11:37:56 -0100 Subject: [PATCH] frontal_local_id Signed-off-by: Maxence Lange --- lib/GlobalScale/FileShare.php | 2 ++ lib/GlobalScale/MemberAdd.php | 3 +++ lib/Service/ConfigService.php | 27 +++++++++++++++++++++++++++ 3 files changed, 32 insertions(+) diff --git a/lib/GlobalScale/FileShare.php b/lib/GlobalScale/FileShare.php index 07571f8df..2e9e9b125 100644 --- a/lib/GlobalScale/FileShare.php +++ b/lib/GlobalScale/FileShare.php @@ -242,6 +242,8 @@ private function sharedByMail( ['token' => $sharesToken->getToken()] ); + $link = $this->configService->patchFrontalLink($link); + $lang = $this->configService->getCoreValueForUser($share->getSharedBy(), 'lang', ''); if ($lang !== '') { $this->l10n = OC::$server->getL10N(Application::APP_NAME, $lang); diff --git a/lib/GlobalScale/MemberAdd.php b/lib/GlobalScale/MemberAdd.php index 64e8b2306..14f79cc39 100644 --- a/lib/GlobalScale/MemberAdd.php +++ b/lib/GlobalScale/MemberAdd.php @@ -308,6 +308,9 @@ private function getMailLinkFromShare(array $share, Member $member, string $pass 'files_sharing.sharecontroller.showShare', ['token' => $sharesToken->getToken()] ); + + $link = $this->configService->patchFrontalLink($link); + $author = $share['uid_initiator']; $filename = basename($share['file_target']); diff --git a/lib/Service/ConfigService.php b/lib/Service/ConfigService.php index 4a80e095d..631f74d77 100644 --- a/lib/Service/ConfigService.php +++ b/lib/Service/ConfigService.php @@ -66,6 +66,9 @@ class ConfigService { const FORCE_NC_BASE = 'force_nc_base'; const TEST_NC_BASE = 'test_nc_base'; + const FRONTAL_CLOUD_ID = 'frontal_cloud_id'; + const FRONTAL_CLOUD_SCHEME = 'frontal_cloud_scheme'; + const GS_ENABLED = 'enabled'; const GS_MODE = 'mode'; const GS_KEY = 'key'; @@ -93,6 +96,8 @@ class ConfigService { self::LOCAL_CLOUD_ID => '', self::FORCE_NC_BASE => '', self::TEST_NC_BASE => '', + self::FRONTAL_CLOUD_ID => '', + self::FRONTAL_CLOUD_SCHEME => 'https', self::CIRCLES_ACTIVITY_ON_CREATION => '1', self::CIRCLES_SKIP_INVITATION_STEP => '0', self::CIRCLES_SEARCH_FROM_COLLABORATOR => '0' @@ -684,5 +689,27 @@ private function cleanLinkToRoute(string $ncBase, string $routeName, array $args return rtrim($ncBase, '/') . $link; } + + public function patchFrontalLink(string $link) { + $frontal = $this->getAppValue(ConfigService::FRONTAL_CLOUD_ID); + if ($frontal === '') { + return $link; + } + + $parsed = parse_url($link); + if (!is_array($parsed) || !array_key_exists('host', $parsed)) { + return $link; + } + + if (array_key_exists('port', $parsed)) { + $host = $parsed['host'] . ':' . $parsed['port']; + } else { + $host = $parsed['host']; + } + + return str_replace($host, $frontal, $link); + } + + }