Skip to content

Commit

Permalink
frontal_local_id
Browse files Browse the repository at this point in the history
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
  • Loading branch information
ArtificialOwl committed Mar 1, 2021
1 parent 7f0d272 commit a616219
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/GlobalScale/FileShare.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 3 additions & 0 deletions lib/GlobalScale/MemberAdd.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']);

Expand Down
27 changes: 27 additions & 0 deletions lib/Service/ConfigService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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'
Expand Down Expand Up @@ -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);
}


}

0 comments on commit a616219

Please sign in to comment.