]> git.mxchange.org Git - friendica.git/blobdiff - src/Module/Friendica.php
Merge pull request #13488 from MrPetovan/bug/frio-search-result-padding
[friendica.git] / src / Module / Friendica.php
index 3029893097e246fdd734217b068a8c17236fc164..e2a9d5ee65d3e777f9ae5d1e15f72cab150f550b 100644 (file)
@@ -26,9 +26,10 @@ use Friendica\BaseModule;
 use Friendica\Core\Addon;
 use Friendica\Core\Config\Capability\IManageConfigValues;
 use Friendica\Core\Hook;
-use Friendica\Core\KeyValueStorage\Capabilities\IManageKeyValuePairs;
+use Friendica\Core\KeyValueStorage\Capability\IManageKeyValuePairs;
 use Friendica\Core\L10n;
 use Friendica\Core\Renderer;
+use Friendica\Core\Session\Capability\IHandleUserSessions;
 use Friendica\Core\System;
 use Friendica\Database\PostUpdate;
 use Friendica\Model\User;
@@ -47,13 +48,16 @@ class Friendica extends BaseModule
        private $config;
        /** @var IManageKeyValuePairs */
        private $keyValue;
+       /** @var IHandleUserSessions */
+       private $session;
 
-       public function __construct(IManageKeyValuePairs $keyValue, IManageConfigValues $config, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, array $server, array $parameters = [])
+       public function __construct(IHandleUserSessions $session, IManageKeyValuePairs $keyValue, IManageConfigValues $config, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, array $server, array $parameters = [])
        {
                parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
 
                $this->config = $config;
                $this->keyValue = $keyValue;
+               $this->session = $session;
        }
 
        protected function content(array $request = []): string
@@ -90,7 +94,7 @@ class Friendica extends BaseModule
 
                $blockList = $this->config->get('system', 'blocklist') ?? [];
 
-               if (!empty($blockList)) {
+               if (!empty($blockList) && ($this->config->get('blocklist', 'public') || $this->session->isAuthenticated())) {
                        $blocked = [
                                'title'    => $this->t('On this server the following remote servers are blocked.'),
                                'header'   => [
@@ -138,9 +142,9 @@ class Friendica extends BaseModule
                                $data = ActivityPub\Transmitter::getProfile(0);
                                header('Access-Control-Allow-Origin: *');
                                header('Cache-Control: max-age=23200, stale-while-revalidate=23200');
-                               System::jsonExit($data, 'application/activity+json');
+                               $this->jsonExit($data, 'application/activity+json');
                        } catch (HTTPException\NotFoundException $e) {
-                               System::jsonError(404, ['error' => 'Record not found']);
+                               $this->jsonError(404, ['error' => 'Record not found']);
                        }
                }
 
@@ -150,7 +154,7 @@ class Friendica extends BaseModule
                        Register::OPEN    => 'REGISTER_OPEN'
                ];
 
-               $register_policy_int = intval($this->config->get('config', 'register_policy'));
+               $register_policy_int = $this->config->get('config', 'register_policy');
                if ($register_policy_int !== Register::CLOSED && $this->config->get('config', 'invitation_only')) {
                        $register_policy = 'REGISTER_INVITATION';
                } else {
@@ -196,6 +200,6 @@ class Friendica extends BaseModule
                        'no_scrape_url'    => $this->baseUrl . '/noscrape',
                ];
 
-               System::jsonExit($data);
+               $this->jsonExit($data);
        }
 }