diff --git a/include/api.php b/include/api.php index 9ed7d7421..b291b6e00 100644 --- a/include/api.php +++ b/include/api.php @@ -391,6 +391,7 @@ function save_media_to_database($mediatype, $media, $type, $album, $allow_cid, $ return prepare_photo_data($type, false, $resource_id, $uid); } else { throw new InternalServerErrorException("image upload failed"); + DI::page()->exit(DI::apiResponse()); } } diff --git a/index.php b/index.php index 0afd2c7d3..95a1306b3 100644 --- a/index.php +++ b/index.php @@ -41,11 +41,9 @@ $a = \Friendica\DI::app(); \Friendica\DI::mode()->setExecutor(\Friendica\App\Mode::INDEX); $a->runFrontend( - $dice->create(\Friendica\App\ModuleController::class), $dice->create(\Friendica\App\Router::class), $dice->create(\Friendica\Core\PConfig\Capability\IManagePersonalConfigValues::class), $dice->create(\Friendica\Security\Authentication::class), $dice->create(\Friendica\App\Page::class), - $dice, $start_time ); diff --git a/mod/settings.php b/mod/settings.php index 080bcdeb9..1643b19fc 100644 --- a/mod/settings.php +++ b/mod/settings.php @@ -47,7 +47,7 @@ function settings_init(App $a) return; } - BaseSettings::content(); + BaseSettings::createAside(); } function settings_post(App $a) @@ -408,7 +408,7 @@ function settings_content(App $a) if (!empty($_SESSION['submanage'])) { notice(DI::l10n()->t('Permission denied.')); - return; + return ''; } if ((DI::args()->getArgc() > 1) && (DI::args()->getArgv()[1] === 'oauth')) { @@ -417,7 +417,7 @@ function settings_content(App $a) DBA::delete('application-token', ['application-id' => DI::args()->getArgv()[3], 'uid' => local_user()]); DI::baseUrl()->redirect('settings/oauth/', true); - return; + return ''; } $applications = DBA::selectToArray('application-view', ['id', 'uid', 'name', 'website', 'scopes', 'created_at'], ['uid' => local_user()]); @@ -577,7 +577,7 @@ function settings_content(App $a) $profile = DBA::selectFirst('profile', [], ['uid' => local_user()]); if (!DBA::isResult($profile)) { notice(DI::l10n()->t('Unable to find your profile. Please contact your admin.')); - return; + return ''; } $user = User::getById($a->getLoggedInUserId()); diff --git a/src/App.php b/src/App.php index f4534c015..c80518c19 100644 --- a/src/App.php +++ b/src/App.php @@ -21,11 +21,10 @@ namespace Friendica; -use Dice\Dice; use Exception; use Friendica\App\Arguments; use Friendica\App\BaseURL; -use Friendica\App\ModuleController; +use Friendica\Capabilities\ICanCreateResponses; use Friendica\Core\Config\Factory\Config; use Friendica\Module\Maintenance; use Friendica\Security\Authentication; @@ -44,6 +43,7 @@ use Friendica\Util\DateTimeFormat; use Friendica\Util\HTTPSignature; use Friendica\Util\Profiler; use Friendica\Util\Strings; +use GuzzleHttp\Psr7\Response; use Psr\Log\LoggerInterface; /** @@ -118,11 +118,6 @@ class App */ private $args; - /** - * @var Core\System The system methods - */ - private $system; - /** * @var IManagePersonalConfigValues */ @@ -328,10 +323,9 @@ class App * @param Profiler $profiler The profiler of this application * @param L10n $l10n The translator instance * @param App\Arguments $args The Friendica Arguments of the call - * @param Core\System $system The system methods * @param IManagePersonalConfigValues $pConfig Personal configuration */ - public function __construct(Database $database, IManageConfigValues $config, App\Mode $mode, BaseURL $baseURL, LoggerInterface $logger, Profiler $profiler, L10n $l10n, Arguments $args, Core\System $system, IManagePersonalConfigValues $pConfig) + public function __construct(Database $database, IManageConfigValues $config, App\Mode $mode, BaseURL $baseURL, LoggerInterface $logger, Profiler $profiler, L10n $l10n, Arguments $args, IManagePersonalConfigValues $pConfig) { $this->database = $database; $this->config = $config; @@ -341,7 +335,6 @@ class App $this->logger = $logger; $this->l10n = $l10n; $this->args = $args; - $this->system = $system; $this->pConfig = $pConfig; $this->load(); @@ -567,7 +560,6 @@ class App * * This probably should change to limit the size of this monster method. * - * @param App\ModuleController $module The determined module * @param App\Router $router * @param IManagePersonalConfigValues $pconfig * @param Authentication $auth The Authentication backend of the node @@ -576,12 +568,12 @@ class App * @throws HTTPException\InternalServerErrorException * @throws \ImagickException */ - public function runFrontend(App\ModuleController $module, App\Router $router, IManagePersonalConfigValues $pconfig, Authentication $auth, App\Page $page, Dice $dice, float $start_time) + public function runFrontend(App\Router $router, IManagePersonalConfigValues $pconfig, Authentication $auth, App\Page $page, float $start_time) { $this->profiler->set($start_time, 'start'); $this->profiler->set(microtime(true), 'classinit'); - $moduleName = $module->getName(); + $moduleName = $this->args->getModuleName(); try { // Missing DB connection: ERROR @@ -611,7 +603,7 @@ class App // Only continue when the given profile link seems valid // Valid profile links contain a path with "/profile/" and no query parameters if ((parse_url($_GET['zrl'], PHP_URL_QUERY) == "") && - strstr(parse_url($_GET['zrl'], PHP_URL_PATH), "/profile/")) { + strstr(parse_url($_GET['zrl'], PHP_URL_PATH), "/profile/")) { if (Core\Session::get('visitor_home') != $_GET["zrl"]) { Core\Session::set('my_url', $_GET['zrl']); Core\Session::set('authenticated', 0); @@ -703,20 +695,23 @@ class App $page['page_title'] = $moduleName; if (!$this->mode->isInstall() && !$this->mode->has(App\Mode::MAINTENANCEDISABLED)) { - $module = new ModuleController('maintenance', new Maintenance($this->l10n)); + $module = $router->getModule(Maintenance::class); } else { // determine the module class and save it to the module instance // @todo there's an implicit dependency due SESSION::start(), so it has to be called here (yet) - $module = $module->determineClass($this->args, $router, $this->config, $dice); + $module = $router->getModule(); } // Let the module run it's internal process (init, get, post, ...) - $module->run($this->l10n, $this->baseURL, $this->logger, $this->profiler, $_SERVER, $_POST); + $response = $module->run($_POST, $_REQUEST); + if ($response->getHeaderLine(ICanCreateResponses::X_HEADER) === ICanCreateResponses::TYPE_HTML) { + $page->run($this, $this->baseURL, $this->args, $this->mode, $response, $this->l10n, $this->profiler, $this->config, $pconfig); + } else { + $page->exit($response); + } } catch (HTTPException $e) { (new ModuleHTTPException())->rawContent($e); } - - $page->run($this, $this->baseURL, $this->mode, $module, $this->l10n, $this->profiler, $this->config, $pconfig); } /** diff --git a/src/App/Arguments.php b/src/App/Arguments.php index ae6c64a4f..19f8e9212 100644 --- a/src/App/Arguments.php +++ b/src/App/Arguments.php @@ -30,6 +30,8 @@ namespace Friendica\App; */ class Arguments { + const DEFAULT_MODULE = 'home'; + /** * @var string The complete query string */ @@ -38,6 +40,10 @@ class Arguments * @var string The current Friendica command */ private $command; + /** + * @var string The name of the current module + */ + private $moduleName; /** * @var array The arguments of the current execution */ @@ -47,10 +53,11 @@ class Arguments */ private $argc; - public function __construct(string $queryString = '', string $command = '', array $argv = [], int $argc = 0) + public function __construct(string $queryString = '', string $command = '', string $moduleName = '', array $argv = [], int $argc = 0) { $this->queryString = $queryString; $this->command = $command; + $this->moduleName = $moduleName; $this->argv = $argv; $this->argc = $argc; } @@ -71,6 +78,14 @@ class Arguments return $this->command; } + /** + * @return string The module name based on the arguments + */ + public function getModuleName(): string + { + return $this->moduleName; + } + /** * @return array All arguments of this call */ @@ -172,6 +187,18 @@ class Arguments $queryString = $command . ($queryParameters ? '?' . http_build_query($queryParameters) : ''); - return new Arguments($queryString, $command, $argv, $argc); + if ($argc > 0) { + $module = str_replace('.', '_', $argv[0]); + $module = str_replace('-', '_', $module); + } else { + $module = self::DEFAULT_MODULE; + } + + // Compatibility with the Firefox App + if (($module == "users") && ($command == "users/sign_in")) { + $module = "login"; + } + + return new Arguments($queryString, $command, $module, $argv, $argc); } } diff --git a/src/App/Mode.php b/src/App/Mode.php index 4a1213ae1..79cbb0f93 100644 --- a/src/App/Mode.php +++ b/src/App/Mode.php @@ -46,6 +46,38 @@ class Mode const BACKEND_CONTENT_TYPES = ['application/jrd+json', 'text/xml', 'application/rss+xml', 'application/atom+xml', 'application/activity+json']; + /** + * A list of modules, which are backend methods + * + * @var array + */ + const BACKEND_MODULES = [ + '_well_known', + 'api', + 'dfrn_notify', + 'feed', + 'fetch', + 'followers', + 'following', + 'hcard', + 'hostxrd', + 'inbox', + 'manifest', + 'nodeinfo', + 'noscrape', + 'objects', + 'outbox', + 'poco', + 'post', + 'pubsub', + 'pubsubhubbub', + 'receive', + 'rsd_xml', + 'salmon', + 'statistics_json', + 'xrd', + ]; + /*** * @var int The mode of this Application * @@ -140,13 +172,13 @@ class Mode * Checks if the site is called via a backend process * * @param bool $isBackend True, if the call is from a backend script (daemon, worker, ...) - * @param ModuleController $module The pre-loaded module (just name, not class!) * @param array $server The $_SERVER variable + * @param Arguments $args The Friendica App arguments * @param MobileDetect $mobileDetect The mobile detection library * * @return Mode returns the determined mode */ - public function determineRunMode(bool $isBackend, ModuleController $module, array $server, MobileDetect $mobileDetect) + public function determineRunMode(bool $isBackend, array $server, Arguments $args, MobileDetect $mobileDetect) { foreach (self::BACKEND_CONTENT_TYPES as $type) { if (strpos(strtolower($server['HTTP_ACCEPT'] ?? ''), $type) !== false) { @@ -154,7 +186,7 @@ class Mode } } - $isBackend = $isBackend || $module->isBackend(); + $isBackend = $isBackend || in_array($args->getModuleName(), static::BACKEND_MODULES); $isMobile = $mobileDetect->isMobile(); $isTablet = $mobileDetect->isTablet(); $isAjax = strtolower($server['HTTP_X_REQUESTED_WITH'] ?? '') == 'xmlhttprequest'; diff --git a/src/App/ModuleController.php b/src/App/ModuleController.php deleted file mode 100644 index ae2723639..000000000 --- a/src/App/ModuleController.php +++ /dev/null @@ -1,321 +0,0 @@ -. - * - */ - -namespace Friendica\App; - -use Dice\Dice; -use Friendica\App; -use Friendica\Capabilities\ICanHandleRequests; -use Friendica\Core; -use Friendica\Core\Config\Capability\IManageConfigValues; -use Friendica\LegacyModule; -use Friendica\Module\Home; -use Friendica\Module\HTTPException\MethodNotAllowed; -use Friendica\Module\HTTPException\PageNotFound; -use Friendica\Network\HTTPException\MethodNotAllowedException; -use Friendica\Network\HTTPException\NoContentException; -use Friendica\Network\HTTPException\NotFoundException; -use Friendica\Util\Profiler; -use Psr\Log\LoggerInterface; - -/** - * Holds the common context of the current, loaded module - */ -class ModuleController -{ - const DEFAULT = 'home'; - const DEFAULT_CLASS = Home::class; - /** - * A list of modules, which are backend methods - * - * @var array - */ - const BACKEND_MODULES = [ - '_well_known', - 'api', - 'dfrn_notify', - 'feed', - 'fetch', - 'followers', - 'following', - 'hcard', - 'hostxrd', - 'inbox', - 'manifest', - 'nodeinfo', - 'noscrape', - 'objects', - 'outbox', - 'poco', - 'post', - 'pubsub', - 'pubsubhubbub', - 'receive', - 'rsd_xml', - 'salmon', - 'statistics_json', - 'xrd', - ]; - - /** - * @var string The module name - */ - private $moduleName; - - /** - * @var ?ICanHandleRequests The module object - */ - private $module; - - /** - * @var bool true, if the module is a backend module - */ - private $isBackend; - - /** - * @var bool true, if the loaded addon is private, so we have to print out not allowed - */ - private $printNotAllowedAddon; - - /** - * @return string - */ - public function getName() - { - return $this->moduleName; - } - - /** - * @return ?ICanHandleRequests The base module object - */ - public function getModule(): ?ICanHandleRequests - { - return $this->module; - } - - /** - * @return bool True, if the current module is a backend module - * @see ModuleController::BACKEND_MODULES for a list - */ - public function isBackend() - { - return $this->isBackend; - } - - public function __construct(string $moduleName = self::DEFAULT, ?ICanHandleRequests $module = null, bool $isBackend = false, bool $printNotAllowedAddon = false) - { - $this->moduleName = $moduleName; - $this->module = $module; - $this->isBackend = $isBackend; - $this->printNotAllowedAddon = $printNotAllowedAddon; - } - - /** - * Determines the current module based on the App arguments and the server variable - * - * @param Arguments $args The Friendica arguments - * - * @return ModuleController The module with the determined module - */ - public function determineName(Arguments $args) - { - if ($args->getArgc() > 0) { - $module = str_replace('.', '_', $args->get(0)); - $module = str_replace('-', '_', $module); - } else { - $module = self::DEFAULT; - } - - // Compatibility with the Firefox App - if (($module == "users") && ($args->getCommand() == "users/sign_in")) { - $module = "login"; - } - - $isBackend = in_array($module, ModuleController::BACKEND_MODULES); - - return new ModuleController($module, null, $isBackend, $this->printNotAllowedAddon); - } - - /** - * Determine the class of the current module - * - * @param Arguments $args The Friendica execution arguments - * @param Router $router The Friendica routing instance - * @param IManageConfigValues $config The Friendica Configuration - * @param Dice $dice The Dependency Injection container - * - * @return ModuleController The determined module of this call - * - * @throws \Exception - */ - public function determineClass(Arguments $args, Router $router, IManageConfigValues $config, Dice $dice) - { - $printNotAllowedAddon = false; - - $module_class = null; - $module_parameters = []; - /** - * ROUTING - * - * From the request URL, routing consists of obtaining the name of a BaseModule-extending class of which the - * post() and/or content() static methods can be respectively called to produce a data change or an output. - **/ - try { - $module_class = $router->getModuleClass($args->getCommand()); - $module_parameters[] = $router->getModuleParameters(); - } catch (MethodNotAllowedException $e) { - $module_class = MethodNotAllowed::class; - } catch (NotFoundException $e) { - // Then we try addon-provided modules that we wrap in the LegacyModule class - if (Core\Addon::isEnabled($this->moduleName) && file_exists("addon/{$this->moduleName}/{$this->moduleName}.php")) { - //Check if module is an app and if public access to apps is allowed or not - $privateapps = $config->get('config', 'private_addons', false); - if ((!local_user()) && Core\Hook::isAddonApp($this->moduleName) && $privateapps) { - $printNotAllowedAddon = true; - } else { - include_once "addon/{$this->moduleName}/{$this->moduleName}.php"; - if (function_exists($this->moduleName . '_module')) { - $module_parameters[] = "addon/{$this->moduleName}/{$this->moduleName}.php"; - $module_class = LegacyModule::class; - } - } - } - - /* Finally, we look for a 'standard' program module in the 'mod' directory - * We emulate a Module class through the LegacyModule class - */ - if (!$module_class && file_exists("mod/{$this->moduleName}.php")) { - $module_parameters[] = "mod/{$this->moduleName}.php"; - $module_class = LegacyModule::class; - } - - $module_class = $module_class ?: PageNotFound::class; - } - - /** @var ICanHandleRequests $module */ - $module = $dice->create($module_class, $module_parameters); - - return new ModuleController($this->moduleName, $module, $this->isBackend, $printNotAllowedAddon); - } - - /** - * Run the determined module class and calls all hooks applied to - * - * @param \Friendica\Core\L10n $l10n The L10n instance - * @param App\BaseURL $baseUrl The Friendica Base URL - * @param LoggerInterface $logger The Friendica logger - * @param array $server The $_SERVER variable - * @param array $post The $_POST variables - * - * @throws \Friendica\Network\HTTPException\InternalServerErrorException - */ - public function run(Core\L10n $l10n, App\BaseURL $baseUrl, LoggerInterface $logger, Profiler $profiler, array $server, array $post) - { - if ($this->printNotAllowedAddon) { - notice($l10n->t("You must be logged in to use addons. ")); - } - - /* The URL provided does not resolve to a valid module. - * - * On Dreamhost sites, quite often things go wrong for no apparent reason and they send us to '/internal_error.html'. - * We don't like doing this, but as it occasionally accounts for 10-20% or more of all site traffic - - * we are going to trap this and redirect back to the requested page. As long as you don't have a critical error on your page - * this will often succeed and eventually do the right thing. - * - * Otherwise we are going to emit a 404 not found. - */ - if ($this->module === PageNotFound::class) { - $queryString = $server['QUERY_STRING']; - // Stupid browser tried to pre-fetch our Javascript img template. Don't log the event or return anything - just quietly exit. - if (!empty($queryString) && preg_match('/{[0-9]}/', $queryString) !== 0) { - exit(); - } - - if (!empty($queryString) && ($queryString === 'q=internal_error.html') && isset($dreamhost_error_hack)) { - $logger->info('index.php: dreamhost_error_hack invoked.', ['Original URI' => $server['REQUEST_URI']]); - $baseUrl->redirect($server['REQUEST_URI']); - } - - $logger->debug('index.php: page not found.', ['request_uri' => $server['REQUEST_URI'], 'address' => $server['REMOTE_ADDR'], 'query' => $server['QUERY_STRING']]); - } - - // @see https://github.com/tootsuite/mastodon/blob/c3aef491d66aec743a3a53e934a494f653745b61/config/initializers/cors.rb - if (substr($_REQUEST['pagename'] ?? '', 0, 12) == '.well-known/') { - header('Access-Control-Allow-Origin: *'); - header('Access-Control-Allow-Headers: *'); - header('Access-Control-Allow-Methods: ' . Router::GET); - header('Access-Control-Allow-Credentials: false'); - } elseif (substr($_REQUEST['pagename'] ?? '', 0, 8) == 'profile/') { - header('Access-Control-Allow-Origin: *'); - header('Access-Control-Allow-Headers: *'); - header('Access-Control-Allow-Methods: ' . Router::GET); - header('Access-Control-Allow-Credentials: false'); - } elseif (substr($_REQUEST['pagename'] ?? '', 0, 4) == 'api/') { - header('Access-Control-Allow-Origin: *'); - header('Access-Control-Allow-Headers: *'); - header('Access-Control-Allow-Methods: ' . implode(',', Router::ALLOWED_METHODS)); - header('Access-Control-Allow-Credentials: false'); - header('Access-Control-Expose-Headers: Link'); - } elseif (substr($_REQUEST['pagename'] ?? '', 0, 11) == 'oauth/token') { - header('Access-Control-Allow-Origin: *'); - header('Access-Control-Allow-Headers: *'); - header('Access-Control-Allow-Methods: ' . Router::POST); - header('Access-Control-Allow-Credentials: false'); - } - - // @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/OPTIONS - // @todo Check allowed methods per requested path - if ($server['REQUEST_METHOD'] === Router::OPTIONS) { - header('Allow: ' . implode(',', Router::ALLOWED_METHODS)); - throw new NoContentException(); - } - - $placeholder = ''; - - $profiler->set(microtime(true), 'ready'); - $timestamp = microtime(true); - - Core\Hook::callAll($this->moduleName . '_mod_init', $placeholder); - - $profiler->set(microtime(true) - $timestamp, 'init'); - - if ($server['REQUEST_METHOD'] === Router::DELETE) { - $this->module->delete(); - } - - if ($server['REQUEST_METHOD'] === Router::PATCH) { - $this->module->patch(); - } - - if ($server['REQUEST_METHOD'] === Router::POST) { - Core\Hook::callAll($this->moduleName . '_mod_post', $post); - $this->module->post(); - } - - if ($server['REQUEST_METHOD'] === Router::PUT) { - $this->module->put(); - } - - // "rawContent" is especially meant for technical endpoints. - // This endpoint doesn't need any theme initialization or other comparable stuff. - $this->module->rawContent(); - } -} diff --git a/src/App/Page.php b/src/App/Page.php index c1a0e4aa5..479abfed9 100644 --- a/src/App/Page.php +++ b/src/App/Page.php @@ -32,11 +32,11 @@ use Friendica\Core\Hook; use Friendica\Core\L10n; use Friendica\Core\Renderer; use Friendica\Core\Theme; -use Friendica\Module\Special\HTTPException as ModuleHTTPException; use Friendica\Network\HTTPException; use Friendica\Util\Network; use Friendica\Util\Strings; use Friendica\Util\Profiler; +use Psr\Http\Message\ResponseInterface; /** * Contains the page specific environment variables for the current Page @@ -191,14 +191,14 @@ class Page implements ArrayAccess * - head.tpl template * * @param App $app The Friendica App instance - * @param ModuleController $module The loaded Friendica module + * @param Arguments $args The Friendica App Arguments * @param L10n $l10n The l10n language instance * @param IManageConfigValues $config The Friendica configuration * @param IManagePersonalConfigValues $pConfig The Friendica personal configuration (for user) * * @throws HTTPException\InternalServerErrorException */ - private function initHead(App $app, ModuleController $module, L10n $l10n, IManageConfigValues $config, IManagePersonalConfigValues $pConfig) + private function initHead(App $app, Arguments $args, L10n $l10n, IManageConfigValues $config, IManagePersonalConfigValues $pConfig) { $interval = ((local_user()) ? $pConfig->get(local_user(), 'system', 'update_interval') : 40000); @@ -212,8 +212,8 @@ class Page implements ArrayAccess } // Default title: current module called - if (empty($this->page['title']) && $module->getName()) { - $this->page['title'] = ucfirst($module->getName()); + if (empty($this->page['title']) && $args->getModuleName()) { + $this->page['title'] = ucfirst($args->getModuleName()); } // Prepend the sitename to the page title @@ -268,9 +268,9 @@ class Page implements ArrayAccess if (!empty($_SERVER["HTTPS"]) && ($_SERVER["HTTPS"] == "on")) { $pageURL .= "s"; } - + $pageURL .= "://"; - + if ($_SERVER["SERVER_PORT"] != "80" && $_SERVER["SERVER_PORT"] != "443") { $pageURL .= $_SERVER["SERVER_NAME"] . ":" . $_SERVER["SERVER_PORT"] . $_SERVER["REQUEST_URI"]; } else { @@ -337,32 +337,19 @@ class Page implements ArrayAccess * - module content * - hooks for content * - * @param ModuleController $module The module - * @param Mode $mode The Friendica execution mode + * @param ResponseInterface $response The Module response class + * @param Mode $mode The Friendica execution mode * * @throws HTTPException\InternalServerErrorException */ - private function initContent(ModuleController $module, Mode $mode) + private function initContent(ResponseInterface $response, Mode $mode) { - $content = ''; - - try { - $moduleClass = $module->getModule(); - - $arr = ['content' => $content]; - Hook::callAll($moduleClass->getClassName() . '_mod_content', $arr); - $content = $arr['content']; - $content .= $module->getModule()->content(); - } catch (HTTPException $e) { - $content = (new ModuleHTTPException())->content($e); - } - // initialise content region if ($mode->isNormal()) { Hook::callAll('page_content_top', $this->page['content']); } - $this->page['content'] .= $content; + $this->page['content'] .= (string)$response->getBody(); } /** @@ -384,22 +371,47 @@ class Page implements ArrayAccess $this->footerScripts[] = trim($url, '/'); } + /** + * Directly exit with the current response (include setting all headers) + * + * @param ResponseInterface $response + */ + public function exit(ResponseInterface $response) + { + foreach ($response->getHeaders() as $key => $header) { + if (is_array($header)) { + $header_str = implode(',', $header); + } else { + $header_str = $header; + } + + if (empty($key)) { + header($header_str); + } else { + header("$key: $header_str"); + } + } + + echo $response->getBody(); + } + /** * Executes the creation of the current page and prints it to the screen * - * @param App $app The Friendica App - * @param BaseURL $baseURL The Friendica Base URL - * @param Mode $mode The current node mode - * @param ModuleController $module The loaded Friendica module - * @param L10n $l10n The l10n language class - * @param IManageConfigValues $config The Configuration of this node - * @param IManagePersonalConfigValues $pconfig The personal/user configuration + * @param App $app The Friendica App + * @param BaseURL $baseURL The Friendica Base URL + * @param Arguments $args The Friendica App arguments + * @param Mode $mode The current node mode + * @param ResponseInterface $response The Response of the module class, including type, content & headers + * @param L10n $l10n The l10n language class + * @param IManageConfigValues $config The Configuration of this node + * @param IManagePersonalConfigValues $pconfig The personal/user configuration * - * @throws HTTPException\InternalServerErrorException + * @throws HTTPException\InternalServerErrorException|HTTPException\ServiceUnavailableException */ - public function run(App $app, BaseURL $baseURL, Mode $mode, ModuleController $module, L10n $l10n, Profiler $profiler, IManageConfigValues $config, IManagePersonalConfigValues $pconfig) + public function run(App $app, BaseURL $baseURL, Arguments $args, Mode $mode, ResponseInterface $response, L10n $l10n, Profiler $profiler, IManageConfigValues $config, IManagePersonalConfigValues $pconfig) { - $moduleName = $module->getName(); + $moduleName = $args->getModuleName(); /* Create the page content. * Calls all hooks which are including content operations @@ -407,7 +419,7 @@ class Page implements ArrayAccess * Sets the $Page->page['content'] variable */ $timestamp = microtime(true); - $this->initContent($module, $mode); + $this->initContent($response, $mode); $profiler->set(microtime(true) - $timestamp, 'content'); // Load current theme info after module has been initialized as theme could have been set in module @@ -429,7 +441,7 @@ class Page implements ArrayAccess * all the module functions have executed so that all * theme choices made by the modules can take effect. */ - $this->initHead($app, $module, $l10n, $config, $pconfig); + $this->initHead($app, $args, $l10n, $config, $pconfig); /* Build the page ending -- this is stuff that goes right before * the closing tag @@ -446,6 +458,20 @@ class Page implements ArrayAccess $this->page['nav'] = Nav::build($app); } + foreach ($response->getHeaders() as $key => $header) { + if (is_array($header)) { + $header_str = implode(',', $header); + } else { + $header_str = $header; + } + + if (empty($key)) { + header($header_str); + } else { + header("$key: $header_str"); + } + } + // Build the page - now that we have all the components if (isset($_GET["mode"]) && (($_GET["mode"] == "raw") || ($_GET["mode"] == "minimal"))) { $doc = new DOMDocument(); diff --git a/src/App/Router.php b/src/App/Router.php index 181f5368d..b13334ae0 100644 --- a/src/App/Router.php +++ b/src/App/Router.php @@ -21,17 +21,26 @@ namespace Friendica\App; - +use Dice\Dice; use FastRoute\DataGenerator\GroupCountBased; use FastRoute\Dispatcher; use FastRoute\RouteCollector; use FastRoute\RouteParser\Std; +use Friendica\Capabilities\ICanHandleRequests; +use Friendica\Core\Addon; use Friendica\Core\Cache\Enum\Duration; use Friendica\Core\Cache\Capability\ICanCache; +use Friendica\Core\Config\Capability\IManageConfigValues; use Friendica\Core\Hook; use Friendica\Core\L10n; use Friendica\Core\Lock\Capability\ICanLock; +use Friendica\LegacyModule; +use Friendica\Module\HTTPException\MethodNotAllowed; +use Friendica\Module\HTTPException\PageNotFound; use Friendica\Network\HTTPException; +use Friendica\Network\HTTPException\MethodNotAllowedException; +use Friendica\Network\HTTPException\NoContentException; +use Friendica\Network\HTTPException\NotFoundException; /** * Wrapper for FastRoute\Router @@ -83,24 +92,52 @@ class Router /** @var ICanLock */ private $lock; + /** @var Arguments */ + private $args; + + /** @var IManageConfigValues */ + private $config; + + /** @var Dice */ + private $dice; + /** @var string */ private $baseRoutesFilepath; + /** @var array */ + private $server; + /** * @param array $server The $_SERVER variable * @param string $baseRoutesFilepath The path to a base routes file to leverage cache, can be empty * @param L10n $l10n * @param ICanCache $cache + * @param ICanLock $lock + * @param IManageConfigValues $config + * @param Arguments $args + * @param Dice $dice * @param RouteCollector|null $routeCollector */ - public function __construct(array $server, string $baseRoutesFilepath, L10n $l10n, ICanCache $cache, ICanLock $lock, RouteCollector $routeCollector = null) + public function __construct(array $server, string $baseRoutesFilepath, L10n $l10n, ICanCache $cache, ICanLock $lock, IManageConfigValues $config, Arguments $args, Dice $dice, RouteCollector $routeCollector = null) { $this->baseRoutesFilepath = $baseRoutesFilepath; $this->l10n = $l10n; $this->cache = $cache; $this->lock = $lock; + $this->args = $args; + $this->config = $config; + $this->dice = $dice; + $this->server = $server; + + $httpMethod = $this->server['REQUEST_METHOD'] ?? self::GET; + + // @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/OPTIONS + // @todo Check allowed methods per requested path + if ($httpMethod === static::OPTIONS) { + header('Allow: ' . implode(',', Router::ALLOWED_METHODS)); + throw new NoContentException(); + } - $httpMethod = $server['REQUEST_METHOD'] ?? self::GET; $this->httpMethod = in_array($httpMethod, self::ALLOWED_METHODS) ? $httpMethod : self::GET; $this->routeCollector = isset($routeCollector) ? @@ -216,21 +253,19 @@ class Router /** * Returns the relevant module class name for the given page URI or NULL if no route rule matched. * - * @param string $cmd The path component of the request URL without the query string - * * @return string A Friendica\BaseModule-extending class name if a route rule matched * * @throws HTTPException\InternalServerErrorException * @throws HTTPException\MethodNotAllowedException If a rule matched but the method didn't * @throws HTTPException\NotFoundException If no rule matched */ - public function getModuleClass($cmd) + private function getModuleClass() { + $cmd = $this->args->getCommand(); $cmd = '/' . ltrim($cmd, '/'); $dispatcher = new Dispatcher\GroupCountBased($this->getCachedDispatchData()); - $moduleClass = null; $this->parameters = []; $routeInfo = $dispatcher->dispatch($this->httpMethod, $cmd); @@ -246,14 +281,50 @@ class Router return $moduleClass; } - /** - * Returns the module parameters. - * - * @return array parameters - */ - public function getModuleParameters() + public function getModule(?string $module_class = null): ICanHandleRequests { - return $this->parameters; + $module_parameters = [$this->server]; + /** + * ROUTING + * + * From the request URL, routing consists of obtaining the name of a BaseModule-extending class of which the + * post() and/or content() static methods can be respectively called to produce a data change or an output. + **/ + try { + $module_class = $module_class ?? $this->getModuleClass(); + $module_parameters[] = $this->parameters; + } catch (MethodNotAllowedException $e) { + $module_class = MethodNotAllowed::class; + } catch (NotFoundException $e) { + $moduleName = $this->args->getModuleName(); + // Then we try addon-provided modules that we wrap in the LegacyModule class + if (Addon::isEnabled($moduleName) && file_exists("addon/{$moduleName}/{$moduleName}.php")) { + //Check if module is an app and if public access to apps is allowed or not + $privateapps = $this->config->get('config', 'private_addons', false); + if ((!local_user()) && Hook::isAddonApp($moduleName) && $privateapps) { + throw new MethodNotAllowedException($this->l10n->t("You must be logged in to use addons. ")); + } else { + include_once "addon/{$moduleName}/{$moduleName}.php"; + if (function_exists($moduleName . '_module')) { + $module_parameters[] = "addon/{$moduleName}/{$moduleName}.php"; + $module_class = LegacyModule::class; + } + } + } + + /* Finally, we look for a 'standard' program module in the 'mod' directory + * We emulate a Module class through the LegacyModule class + */ + if (!$module_class && file_exists("mod/{$moduleName}.php")) { + $module_parameters[] = "mod/{$moduleName}.php"; + $module_class = LegacyModule::class; + } + + $module_class = $module_class ?: PageNotFound::class; + } + + /** @var ICanHandleRequests $module */ + return $this->dice->create($module_class, $module_parameters); } /** diff --git a/src/BaseModule.php b/src/BaseModule.php index 48677e64f..86dd5e7c0 100644 --- a/src/BaseModule.php +++ b/src/BaseModule.php @@ -21,10 +21,19 @@ namespace Friendica; +use Friendica\App\Router; use Friendica\Capabilities\ICanHandleRequests; +use Friendica\Capabilities\ICanCreateResponses; +use Friendica\Core\Hook; use Friendica\Core\L10n; use Friendica\Core\Logger; use Friendica\Model\User; +use Friendica\Module\Response; +use Friendica\Module\Special\HTTPException as ModuleHTTPException; +use Friendica\Network\HTTPException; +use Friendica\Util\Profiler; +use Psr\Http\Message\ResponseInterface; +use Psr\Log\LoggerInterface; /** * All modules in Friendica should extend BaseModule, although not all modules @@ -39,14 +48,31 @@ abstract class BaseModule implements ICanHandleRequests { /** @var array */ protected $parameters = []; - /** @var L10n */ protected $l10n; + /** @var App\BaseURL */ + protected $baseUrl; + /** @var App\Arguments */ + protected $args; + /** @var LoggerInterface */ + protected $logger; + /** @var Profiler */ + protected $profiler; + /** @var array */ + protected $server; + /** @var ICanCreateResponses */ + protected $response; - public function __construct(L10n $l10n, array $parameters = []) + public function __construct(L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, array $server, array $parameters = []) { $this->parameters = $parameters; $this->l10n = $l10n; + $this->baseUrl = $baseUrl; + $this->args = $args; + $this->logger = $logger; + $this->profiler = $profiler; + $this->server = $server; + $this->response = $response; } /** @@ -70,55 +96,149 @@ abstract class BaseModule implements ICanHandleRequests } /** - * {@inheritDoc} + * Module GET method to display raw content from technical endpoints + * + * Extend this method if the module is supposed to return communication data, + * e.g. from protocol implementations. + * + * @param string[] $request The $_REQUEST content */ - public function rawContent() + protected function rawContent(array $request = []) { // echo ''; // exit; } /** - * {@inheritDoc} + * Module GET method to display any content + * + * Extend this method if the module is supposed to return any display + * through a GET request. It can be an HTML page through templating or a + * XML feed or a JSON output. + * + * @param string[] $request The $_REQUEST content */ - public function content(): string + protected function content(array $request = []): string { return ''; } /** - * {@inheritDoc} + * Module DELETE method to process submitted data + * + * Extend this method if the module is supposed to process DELETE requests. + * Doesn't display any content */ - public function delete() + protected function delete() + { + } + + /** + * Module PATCH method to process submitted data + * + * Extend this method if the module is supposed to process PATCH requests. + * Doesn't display any content + */ + protected function patch() + { + } + + /** + * Module POST method to process submitted data + * + * Extend this method if the module is supposed to process POST requests. + * Doesn't display any content + * + * @param string[] $request The $_REQUEST content + * @param string[] $post The $_POST content + * + */ + protected function post(array $request = [], array $post = []) + { + // $this->baseUrl->redirect('module'); + } + + /** + * Module PUT method to process submitted data + * + * Extend this method if the module is supposed to process PUT requests. + * Doesn't display any content + */ + protected function put() { } /** * {@inheritDoc} */ - public function patch() + public function run(array $post = [], array $request = []): ResponseInterface { - } + // @see https://github.com/tootsuite/mastodon/blob/c3aef491d66aec743a3a53e934a494f653745b61/config/initializers/cors.rb + if (substr($request['pagename'] ?? '', 0, 12) == '.well-known/') { + $this->response->setHeader('*', 'Access-Control-Allow-Origin'); + $this->response->setHeader('*', 'Access-Control-Allow-Headers'); + $this->response->setHeader(Router::GET, 'Access-Control-Allow-Methods'); + $this->response->setHeader('false', 'Access-Control-Allow-Credentials'); + } elseif (substr($request['pagename'] ?? '', 0, 8) == 'profile/') { + $this->response->setHeader('*', 'Access-Control-Allow-Origin'); + $this->response->setHeader('*', 'Access-Control-Allow-Headers'); + $this->response->setHeader(Router::GET, 'Access-Control-Allow-Methods'); + $this->response->setHeader('false', 'Access-Control-Allow-Credentials'); + } elseif (substr($request['pagename'] ?? '', 0, 4) == 'api/') { + $this->response->setHeader('*', 'Access-Control-Allow-Origin'); + $this->response->setHeader('*', 'Access-Control-Allow-Headers'); + $this->response->setHeader(implode(',', Router::ALLOWED_METHODS), 'Access-Control-Allow-Methods'); + $this->response->setHeader('false', 'Access-Control-Allow-Credentials'); + $this->response->setHeader('Link', 'Access-Control-Expose-Headers'); + } elseif (substr($request['pagename'] ?? '', 0, 11) == 'oauth/token') { + $this->response->setHeader('*', 'Access-Control-Allow-Origin'); + $this->response->setHeader('*', 'Access-Control-Allow-Headers'); + $this->response->setHeader(Router::POST, 'Access-Control-Allow-Methods'); + $this->response->setHeader('false', 'Access-Control-Allow-Credentials'); + } - /** - * {@inheritDoc} - */ - public function post() - { - // DI::baseurl()->redirect('module'); - } + $placeholder = ''; - /** - * {@inheritDoc} - */ - public function put() - { - } + $this->profiler->set(microtime(true), 'ready'); + $timestamp = microtime(true); - /** Gets the name of the current class */ - public function getClassName(): string - { - return static::class; + Core\Hook::callAll($this->args->getModuleName() . '_mod_init', $placeholder); + + $this->profiler->set(microtime(true) - $timestamp, 'init'); + + switch ($this->server['REQUEST_METHOD'] ?? Router::GET) { + case Router::DELETE: + $this->delete(); + break; + case Router::PATCH: + $this->patch(); + break; + case Router::POST: + Core\Hook::callAll($this->args->getModuleName() . '_mod_post', $post); + $this->post($request, $post); + break; + case Router::PUT: + $this->put(); + break; + } + + $timestamp = microtime(true); + // "rawContent" is especially meant for technical endpoints. + // This endpoint doesn't need any theme initialization or other comparable stuff. + $this->rawContent($request); + + try { + $arr = ['content' => '']; + Hook::callAll(static::class . '_mod_content', $arr); + $this->response->addContent($arr['content']); + $this->response->addContent($this->content($_REQUEST)); + } catch (HTTPException $e) { + $this->response->addContent((new ModuleHTTPException())->content($e)); + } finally { + $this->profiler->set(microtime(true) - $timestamp, 'content'); + } + + return $this->response->generate(); } /* @@ -134,9 +254,9 @@ abstract class BaseModule implements ICanHandleRequests */ public static function getFormSecurityToken($typename = '') { - $user = User::getById(DI::app()->getLoggedInUserId(), ['guid', 'prvkey']); + $user = User::getById(DI::app()->getLoggedInUserId(), ['guid', 'prvkey']); $timestamp = time(); - $sec_hash = hash('whirlpool', ($user['guid'] ?? '') . ($user['prvkey'] ?? '') . session_id() . $timestamp . $typename); + $sec_hash = hash('whirlpool', ($user['guid'] ?? '') . ($user['prvkey'] ?? '') . session_id() . $timestamp . $typename); return $timestamp . '.' . $sec_hash; } diff --git a/src/Capabilities/ICanCreateResponses.php b/src/Capabilities/ICanCreateResponses.php new file mode 100644 index 000000000..0cd5348c5 --- /dev/null +++ b/src/Capabilities/ICanCreateResponses.php @@ -0,0 +1,61 @@ +t('Logout'), '', DI::l10n()->t('End this session')]; } else { - $nav['login'] = ['login', DI::l10n()->t('Login'), (DI::module()->getName() == 'login' ? 'selected' : ''), DI::l10n()->t('Sign in')]; + $nav['login'] = ['login', DI::l10n()->t('Login'), (DI::args()->getModuleName() == 'login' ? 'selected' : ''), DI::l10n()->t('Sign in')]; } if ($a->isLoggedIn()) { @@ -208,7 +208,7 @@ class Nav $homelink = Session::get('visitor_home', ''); } - if ((DI::module()->getName() != 'home') && (! (local_user()))) { + if ((DI::args()->getModuleName() != 'home') && (! (local_user()))) { $nav['home'] = [$homelink, DI::l10n()->t('Home'), '', DI::l10n()->t('Home Page')]; } diff --git a/src/Core/ACL.php b/src/Core/ACL.php index 347e8278f..2a9c02e81 100644 --- a/src/Core/ACL.php +++ b/src/Core/ACL.php @@ -80,7 +80,7 @@ class ACL $arr = ['contact' => $contacts, 'entry' => $o]; - Hook::callAll(DI::module()->getName() . '_pre_recipient', $arr); + Hook::callAll(DI::args()->getModuleName() . '_pre_recipient', $arr); $tpl = Renderer::getMarkupTemplate('acl/message_recipient.tpl'); $o = Renderer::replaceMacros($tpl, [ @@ -88,7 +88,7 @@ class ACL '$selected' => $selected, ]); - Hook::callAll(DI::module()->getName() . '_post_recipient', $o); + Hook::callAll(DI::args()->getModuleName() . '_post_recipient', $o); return $o; } diff --git a/src/DI.php b/src/DI.php index b40222237..190b46a05 100644 --- a/src/DI.php +++ b/src/DI.php @@ -98,14 +98,6 @@ abstract class DI return self::$dice->create(App\Mode::class); } - /** - * @return App\ModuleController - */ - public static function module() - { - return self::$dice->create(App\ModuleController::class); - } - /** * @return App\Page */ diff --git a/src/LegacyModule.php b/src/LegacyModule.php index d307d84ac..f0dfe0e01 100644 --- a/src/LegacyModule.php +++ b/src/LegacyModule.php @@ -22,6 +22,9 @@ namespace Friendica; use Friendica\Core\L10n; +use Friendica\Module\Response; +use Friendica\Util\Profiler; +use Psr\Log\LoggerInterface; /** * This mock module enable class encapsulation of legacy global function modules. @@ -39,9 +42,9 @@ class LegacyModule extends BaseModule */ private $moduleName = ''; - public function __construct(L10n $l10n, string $file_path = '', array $parameters = []) + public function __construct(L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, array $server, string $file_path = '', array $parameters = []) { - parent::__construct($l10n, $parameters); + parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters); $this->setModuleFile($file_path); @@ -65,13 +68,15 @@ class LegacyModule extends BaseModule require_once $file_path; } - public function content(): string + public function content(array $request = []): string { return $this->runModuleFunction('content'); } - public function post() + public function post(array $request = [], array $post = []) { + parent::post($post); + $this->runModuleFunction('post'); } @@ -88,7 +93,7 @@ class LegacyModule extends BaseModule if (\function_exists($function_name)) { $a = DI::app(); - return $function_name($a); + return $function_name($a) ?? ''; } return ''; diff --git a/src/Module/AccountManagementControlDocument.php b/src/Module/AccountManagementControlDocument.php index 8de9e80af..9a96ad68f 100644 --- a/src/Module/AccountManagementControlDocument.php +++ b/src/Module/AccountManagementControlDocument.php @@ -30,7 +30,7 @@ use Friendica\BaseModule; */ class AccountManagementControlDocument extends BaseModule { - public function rawContent() + protected function rawContent(array $request = []) { $output = [ 'version' => 1, diff --git a/src/Module/Acctlink.php b/src/Module/Acctlink.php index 81b2c2391..5e37e614e 100644 --- a/src/Module/Acctlink.php +++ b/src/Module/Acctlink.php @@ -31,7 +31,7 @@ use Friendica\Network\HTTPException\NotFoundException; */ class Acctlink extends BaseModule { - public function rawContent() + protected function rawContent(array $request = []) { $addr = trim($_GET['addr'] ?? ''); if (!$addr) { diff --git a/src/Module/ActivityPub/Followers.php b/src/Module/ActivityPub/Followers.php index d25e4693c..5dd3a274a 100644 --- a/src/Module/ActivityPub/Followers.php +++ b/src/Module/ActivityPub/Followers.php @@ -31,7 +31,7 @@ use Friendica\Protocol\ActivityPub; */ class Followers extends BaseModule { - public function rawContent() + protected function rawContent(array $request = []) { if (empty($this->parameters['nickname'])) { throw new \Friendica\Network\HTTPException\NotFoundException(); diff --git a/src/Module/ActivityPub/Following.php b/src/Module/ActivityPub/Following.php index 3b45cf09a..7a17edd1d 100644 --- a/src/Module/ActivityPub/Following.php +++ b/src/Module/ActivityPub/Following.php @@ -31,7 +31,7 @@ use Friendica\Protocol\ActivityPub; */ class Following extends BaseModule { - public function rawContent() + protected function rawContent(array $request = []) { if (empty($this->parameters['nickname'])) { throw new \Friendica\Network\HTTPException\NotFoundException(); diff --git a/src/Module/ActivityPub/Inbox.php b/src/Module/ActivityPub/Inbox.php index 149e51106..19a695fc7 100644 --- a/src/Module/ActivityPub/Inbox.php +++ b/src/Module/ActivityPub/Inbox.php @@ -35,7 +35,7 @@ use Friendica\Util\Network; */ class Inbox extends BaseModule { - public function rawContent() + protected function rawContent(array $request = []) { $postdata = Network::postdata(); diff --git a/src/Module/ActivityPub/Objects.php b/src/Module/ActivityPub/Objects.php index 5798c5685..a2c553746 100644 --- a/src/Module/ActivityPub/Objects.php +++ b/src/Module/ActivityPub/Objects.php @@ -41,7 +41,7 @@ use Friendica\Util\Strings; */ class Objects extends BaseModule { - public function rawContent() + protected function rawContent(array $request = []) { if (empty($this->parameters['guid'])) { throw new HTTPException\BadRequestException(); diff --git a/src/Module/ActivityPub/Outbox.php b/src/Module/ActivityPub/Outbox.php index c459a55e3..7cfadff94 100644 --- a/src/Module/ActivityPub/Outbox.php +++ b/src/Module/ActivityPub/Outbox.php @@ -31,7 +31,7 @@ use Friendica\Util\HTTPSignature; */ class Outbox extends BaseModule { - public function rawContent() + protected function rawContent(array $request = []) { if (empty($this->parameters['nickname'])) { throw new \Friendica\Network\HTTPException\NotFoundException(); diff --git a/src/Module/Admin/Addons/Details.php b/src/Module/Admin/Addons/Details.php index bab52fb0d..90abc54b5 100644 --- a/src/Module/Admin/Addons/Details.php +++ b/src/Module/Admin/Addons/Details.php @@ -30,7 +30,7 @@ use Friendica\Util\Strings; class Details extends BaseAdmin { - public function post() + public function post(array $request = [], array $post = []) { self::checkAdminAccess(); @@ -52,7 +52,7 @@ class Details extends BaseAdmin DI::baseUrl()->redirect($redirect); } - public function content(): string + protected function content(array $request = []): string { parent::content(); diff --git a/src/Module/Admin/Addons/Index.php b/src/Module/Admin/Addons/Index.php index 6330ee2cf..aa6159431 100644 --- a/src/Module/Admin/Addons/Index.php +++ b/src/Module/Admin/Addons/Index.php @@ -28,7 +28,7 @@ use Friendica\Module\BaseAdmin; class Index extends BaseAdmin { - public function content(): string + protected function content(array $request = []): string { parent::content(); diff --git a/src/Module/Admin/Blocklist/Contact.php b/src/Module/Admin/Blocklist/Contact.php index a0a5c282f..1263b7c3f 100644 --- a/src/Module/Admin/Blocklist/Contact.php +++ b/src/Module/Admin/Blocklist/Contact.php @@ -32,7 +32,7 @@ use Friendica\Util\Network; class Contact extends BaseAdmin { - public function post() + protected function post(array $request = [], array $post = []) { self::checkAdminAccess(); @@ -76,7 +76,7 @@ class Contact extends BaseAdmin DI::baseUrl()->redirect('admin/blocklist/contact'); } - public function content(): string + protected function content(array $request = []): string { parent::content(); diff --git a/src/Module/Admin/Blocklist/Server/Add.php b/src/Module/Admin/Blocklist/Server/Add.php index 47c9016d9..b7397d22b 100644 --- a/src/Module/Admin/Blocklist/Server/Add.php +++ b/src/Module/Admin/Blocklist/Server/Add.php @@ -32,7 +32,7 @@ use GuzzleHttp\Psr7\Uri; class Add extends BaseAdmin { - public function post() + protected function post(array $request = [], array $post = []) { self::checkAdminAccess(); @@ -66,7 +66,7 @@ class Add extends BaseAdmin DI::baseUrl()->redirect('admin/blocklist/server'); } - public function content(): string + protected function content(array $request = []): string { parent::content(); diff --git a/src/Module/Admin/Blocklist/Server/Index.php b/src/Module/Admin/Blocklist/Server/Index.php index ebd39d36a..3be131fac 100644 --- a/src/Module/Admin/Blocklist/Server/Index.php +++ b/src/Module/Admin/Blocklist/Server/Index.php @@ -27,7 +27,7 @@ use Friendica\Module\BaseAdmin; class Index extends BaseAdmin { - public function post() + protected function post(array $request = [], array $post = []) { self::checkAdminAccess(); @@ -56,7 +56,7 @@ class Index extends BaseAdmin DI::baseUrl()->redirect('admin/blocklist/server'); } - public function content(): string + protected function content(array $request = []): string { parent::content(); diff --git a/src/Module/Admin/DBSync.php b/src/Module/Admin/DBSync.php index 6ef8d804a..dac953dc8 100644 --- a/src/Module/Admin/DBSync.php +++ b/src/Module/Admin/DBSync.php @@ -30,7 +30,7 @@ use Friendica\Module\BaseAdmin; class DBSync extends BaseAdmin { - public function content(): string + protected function content(array $request = []): string { parent::content(); diff --git a/src/Module/Admin/Features.php b/src/Module/Admin/Features.php index d2c8e2d83..f5fea300f 100644 --- a/src/Module/Admin/Features.php +++ b/src/Module/Admin/Features.php @@ -28,7 +28,7 @@ use Friendica\Module\BaseAdmin; class Features extends BaseAdmin { - public function post() + protected function post(array $request = [], array $post = []) { self::checkAdminAccess(); @@ -60,7 +60,7 @@ class Features extends BaseAdmin DI::baseUrl()->redirect('admin/features'); } - public function content(): string + protected function content(array $request = []): string { parent::content(); diff --git a/src/Module/Admin/Federation.php b/src/Module/Admin/Federation.php index 65d0453d9..d0b906d02 100644 --- a/src/Module/Admin/Federation.php +++ b/src/Module/Admin/Federation.php @@ -28,7 +28,7 @@ use Friendica\Module\BaseAdmin; class Federation extends BaseAdmin { - public function content(): string + protected function content(array $request = []): string { parent::content(); diff --git a/src/Module/Admin/Item/Delete.php b/src/Module/Admin/Item/Delete.php index 91bb71932..4ae0563e5 100644 --- a/src/Module/Admin/Item/Delete.php +++ b/src/Module/Admin/Item/Delete.php @@ -29,7 +29,7 @@ use Friendica\Util\Strings; class Delete extends BaseAdmin { - public function post() + protected function post(array $request = [], array $post = []) { self::checkAdminAccess(); @@ -55,7 +55,7 @@ class Delete extends BaseAdmin DI::baseUrl()->redirect('admin/item/delete'); } - public function content(): string + protected function content(array $request = []): string { parent::content(); diff --git a/src/Module/Admin/Item/Source.php b/src/Module/Admin/Item/Source.php index c1edabf60..2a6033029 100644 --- a/src/Module/Admin/Item/Source.php +++ b/src/Module/Admin/Item/Source.php @@ -29,7 +29,7 @@ use Friendica\Module\BaseAdmin; class Source extends BaseAdmin { - public function content(): string + protected function content(array $request = []): string { parent::content(); diff --git a/src/Module/Admin/Logs/Settings.php b/src/Module/Admin/Logs/Settings.php index aaf603f82..6f09b2957 100644 --- a/src/Module/Admin/Logs/Settings.php +++ b/src/Module/Admin/Logs/Settings.php @@ -29,7 +29,7 @@ use Psr\Log\LogLevel; class Settings extends BaseAdmin { - public function post() + protected function post(array $request = [], array $post = []) { self::checkAdminAccess(); @@ -56,7 +56,7 @@ class Settings extends BaseAdmin DI::baseUrl()->redirect('admin/logs'); } - public function content(): string + protected function content(array $request = []): string { parent::content(); diff --git a/src/Module/Admin/Logs/View.php b/src/Module/Admin/Logs/View.php index 3e312204b..92055ec29 100644 --- a/src/Module/Admin/Logs/View.php +++ b/src/Module/Admin/Logs/View.php @@ -31,7 +31,7 @@ class View extends BaseAdmin { const LIMIT = 500; - public function content(): string + protected function content(array $request = []): string { parent::content(); diff --git a/src/Module/Admin/PhpInfo.php b/src/Module/Admin/PhpInfo.php index e6cad66c7..2932a8d65 100644 --- a/src/Module/Admin/PhpInfo.php +++ b/src/Module/Admin/PhpInfo.php @@ -25,7 +25,7 @@ use Friendica\Module\BaseAdmin; class PhpInfo extends BaseAdmin { - public function rawContent() + protected function rawContent(array $request = []) { self::checkAdminAccess(); diff --git a/src/Module/Admin/Queue.php b/src/Module/Admin/Queue.php index f43dfdc09..6fe4facef 100644 --- a/src/Module/Admin/Queue.php +++ b/src/Module/Admin/Queue.php @@ -38,7 +38,7 @@ use Friendica\Util\DateTimeFormat; */ class Queue extends BaseAdmin { - public function content(): string + protected function content(array $request = []): string { parent::content(); diff --git a/src/Module/Admin/Site.php b/src/Module/Admin/Site.php index 27623880a..71f042f8d 100644 --- a/src/Module/Admin/Site.php +++ b/src/Module/Admin/Site.php @@ -43,7 +43,7 @@ require_once __DIR__ . '/../../../boot.php'; class Site extends BaseAdmin { - public function post() + protected function post(array $request = [], array $post = []) { self::checkAdminAccess(); @@ -384,7 +384,7 @@ class Site extends BaseAdmin DI::baseUrl()->redirect('admin/site' . $active_panel); } - public function content(): string + protected function content(array $request = []): string { parent::content(); diff --git a/src/Module/Admin/Storage.php b/src/Module/Admin/Storage.php index 68d7d065d..796f88bb3 100644 --- a/src/Module/Admin/Storage.php +++ b/src/Module/Admin/Storage.php @@ -31,7 +31,7 @@ use Friendica\Util\Strings; class Storage extends BaseAdmin { - public function post() + protected function post(array $request = [], array $post = []) { self::checkAdminAccess(); @@ -91,7 +91,7 @@ class Storage extends BaseAdmin DI::baseUrl()->redirect('admin/storage'); } - public function content(): string + protected function content(array $request = []): string { parent::content(); diff --git a/src/Module/Admin/Summary.php b/src/Module/Admin/Summary.php index 5b2efca1e..c919524b1 100644 --- a/src/Module/Admin/Summary.php +++ b/src/Module/Admin/Summary.php @@ -37,7 +37,7 @@ use Friendica\Util\DateTimeFormat; class Summary extends BaseAdmin { - public function content(): string + protected function content(array $request = []): string { parent::content(); diff --git a/src/Module/Admin/Themes/Details.php b/src/Module/Admin/Themes/Details.php index b7161d1b9..7d64ce637 100644 --- a/src/Module/Admin/Themes/Details.php +++ b/src/Module/Admin/Themes/Details.php @@ -30,7 +30,7 @@ use Friendica\Util\Strings; class Details extends BaseAdmin { - public function content(): string + protected function content(array $request = []): string { parent::content(); diff --git a/src/Module/Admin/Themes/Embed.php b/src/Module/Admin/Themes/Embed.php index 0d2a2dc04..1eb3018d5 100644 --- a/src/Module/Admin/Themes/Embed.php +++ b/src/Module/Admin/Themes/Embed.php @@ -25,24 +25,24 @@ use Friendica\App; use Friendica\Core\L10n; use Friendica\Core\Renderer; use Friendica\Module\BaseAdmin; +use Friendica\Module\Response; +use Friendica\Util\Profiler; use Friendica\Util\Strings; +use Psr\Log\LoggerInterface; class Embed extends BaseAdmin { /** @var App */ protected $app; - /** @var App\BaseURL */ - protected $baseUrl; /** @var App\Mode */ protected $mode; - public function __construct(App $app, App\BaseURL $baseUrl, App\Mode $mode, L10n $l10n, array $parameters = []) + public function __construct(App $app, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, App\Mode $mode, array $server, array $parameters = []) { - parent::__construct($l10n, $parameters); + parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters); - $this->app = $app; - $this->baseUrl = $baseUrl; - $this->mode = $mode; + $this->app = $app; + $this->mode = $mode; $theme = Strings::sanitizeFilePathItem($this->parameters['theme']); if (is_file("view/theme/$theme/config.php")) { @@ -50,7 +50,7 @@ class Embed extends BaseAdmin } } - public function post() + protected function post(array $request = [], array $post = []) { self::checkAdminAccess(); @@ -70,7 +70,7 @@ class Embed extends BaseAdmin $this->baseUrl->redirect('admin/themes/' . $theme . '/embed?mode=minimal'); } - public function content(): string + protected function content(array $request = []): string { parent::content(); diff --git a/src/Module/Admin/Themes/Index.php b/src/Module/Admin/Themes/Index.php index ad4dfef94..0b458a909 100644 --- a/src/Module/Admin/Themes/Index.php +++ b/src/Module/Admin/Themes/Index.php @@ -29,7 +29,7 @@ use Friendica\Util\Strings; class Index extends BaseAdmin { - public function content(): string + protected function content(array $request = []): string { parent::content(); diff --git a/src/Module/Admin/Tos.php b/src/Module/Admin/Tos.php index 0e019cc32..684eb4f76 100644 --- a/src/Module/Admin/Tos.php +++ b/src/Module/Admin/Tos.php @@ -21,11 +21,14 @@ namespace Friendica\Module\Admin; -use Friendica\App\BaseURL; +use Friendica\App; use Friendica\Core\Config\Capability\IManageConfigValues; use Friendica\Core\L10n; use Friendica\Core\Renderer; use Friendica\Module\BaseAdmin; +use Friendica\Module\Response; +use Friendica\Util\Profiler; +use Psr\Log\LoggerInterface; class Tos extends BaseAdmin { @@ -33,19 +36,16 @@ class Tos extends BaseAdmin protected $tos; /** @var IManageConfigValues */ protected $config; - /** @var BaseURL */ - protected $baseUrl; - public function __construct(\Friendica\Module\Tos $tos, IManageConfigValues $config, BaseURL $baseUrl, L10n $l10n, array $parameters = []) + public function __construct(L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, IManageConfigValues $config, array $server, array $parameters = []) { - parent::__construct($l10n, $parameters); + parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters); - $this->tos = $tos; + $this->tos = new \Friendica\Module\Tos($l10n, $baseUrl, $args, $logger, $profiler, $response, $config, $server, $parameters); $this->config = $config; - $this->baseUrl = $baseUrl; } - public function post() + protected function post(array $request = [], array $post = []) { self::checkAdminAccess(); @@ -66,7 +66,7 @@ class Tos extends BaseAdmin $this->baseUrl->redirect('admin/tos'); } - public function content(): string + protected function content(array $request = []): string { parent::content(); diff --git a/src/Module/Admin/Users/Active.php b/src/Module/Admin/Users/Active.php index 6bcd22be4..fa8847d0f 100644 --- a/src/Module/Admin/Users/Active.php +++ b/src/Module/Admin/Users/Active.php @@ -30,7 +30,7 @@ use Friendica\Module\Admin\BaseUsers; class Active extends BaseUsers { - public function post() + protected function post(array $request = [], array $post = []) { self::checkAdminAccess(); @@ -60,7 +60,7 @@ class Active extends BaseUsers DI::baseUrl()->redirect(DI::args()->getQueryString()); } - public function content(): string + protected function content(array $request = []): string { parent::content(); diff --git a/src/Module/Admin/Users/Blocked.php b/src/Module/Admin/Users/Blocked.php index a24c95df0..8a8c105fa 100644 --- a/src/Module/Admin/Users/Blocked.php +++ b/src/Module/Admin/Users/Blocked.php @@ -31,7 +31,7 @@ use Friendica\Util\Temporal; class Blocked extends BaseUsers { - public function post() + protected function post(array $request = [], array $post = []) { self::checkAdminAccess(); @@ -61,7 +61,7 @@ class Blocked extends BaseUsers DI::baseUrl()->redirect('admin/users/blocked'); } - public function content(): string + protected function content(array $request = []): string { parent::content(); diff --git a/src/Module/Admin/Users/Create.php b/src/Module/Admin/Users/Create.php index 71ab5b4cb..644b93434 100644 --- a/src/Module/Admin/Users/Create.php +++ b/src/Module/Admin/Users/Create.php @@ -28,7 +28,7 @@ use Friendica\Module\Admin\BaseUsers; class Create extends BaseUsers { - public function post() + protected function post(array $request = [], array $post = []) { self::checkAdminAccess(); @@ -51,7 +51,7 @@ class Create extends BaseUsers DI::baseUrl()->redirect('admin/users/create'); } - public function content(): string + protected function content(array $request = []): string { parent::content(); diff --git a/src/Module/Admin/Users/Deleted.php b/src/Module/Admin/Users/Deleted.php index 6357b2396..4ebe153b8 100644 --- a/src/Module/Admin/Users/Deleted.php +++ b/src/Module/Admin/Users/Deleted.php @@ -33,7 +33,7 @@ use Friendica\Util\Temporal; class Deleted extends BaseUsers { - public function post() + protected function post(array $request = [], array $post = []) { self::checkAdminAccess(); @@ -44,7 +44,7 @@ class Deleted extends BaseUsers DI::baseUrl()->redirect('admin/users/deleted'); } - public function content(): string + protected function content(array $request = []): string { parent::content(); diff --git a/src/Module/Admin/Users/Index.php b/src/Module/Admin/Users/Index.php index eb7b57c25..d0f29ee39 100644 --- a/src/Module/Admin/Users/Index.php +++ b/src/Module/Admin/Users/Index.php @@ -30,7 +30,7 @@ use Friendica\Module\Admin\BaseUsers; class Index extends BaseUsers { - public function post() + protected function post(array $request = [], array $post = []) { self::checkAdminAccess(); @@ -67,7 +67,7 @@ class Index extends BaseUsers DI::baseUrl()->redirect(DI::args()->getQueryString()); } - public function content(): string + protected function content(array $request = []): string { parent::content(); diff --git a/src/Module/Admin/Users/Pending.php b/src/Module/Admin/Users/Pending.php index 801c15974..2917bc260 100644 --- a/src/Module/Admin/Users/Pending.php +++ b/src/Module/Admin/Users/Pending.php @@ -33,7 +33,7 @@ use Friendica\Util\Temporal; class Pending extends BaseUsers { - public function post() + protected function post(array $request = [], array $post = []) { self::checkAdminAccess(); @@ -58,7 +58,7 @@ class Pending extends BaseUsers DI::baseUrl()->redirect('admin/users/pending'); } - public function content(): string + protected function content(array $request = []): string { parent::content(); diff --git a/src/Module/Api/ApiResponse.php b/src/Module/Api/ApiResponse.php index 61886412a..863e1d21d 100644 --- a/src/Module/Api/ApiResponse.php +++ b/src/Module/Api/ApiResponse.php @@ -5,6 +5,7 @@ namespace Friendica\Module\Api; use Friendica\App\Arguments; use Friendica\App\BaseURL; use Friendica\Core\L10n; +use Friendica\Module\Response; use Friendica\Util\Arrays; use Friendica\Util\DateTimeFormat; use Friendica\Util\HTTPInputData; @@ -13,9 +14,9 @@ use Psr\Log\LoggerInterface; use Friendica\Factory\Api\Twitter\User as TwitterUser; /** - * This class is used to format and return API responses + * This class is used to format and create API responses */ -class ApiResponse +class ApiResponse extends Response { /** @var L10n */ protected $l10n; @@ -23,42 +24,18 @@ class ApiResponse protected $args; /** @var LoggerInterface */ protected $logger; + /** @var BaseURL */ + protected $baseUrl; + /** @var TwitterUser */ + protected $twitterUser; - /** - * @param L10n $l10n - * @param Arguments $args - * @param LoggerInterface $logger - */ - public function __construct(L10n $l10n, Arguments $args, LoggerInterface $logger, BaseURL $baseurl, TwitterUser $twitteruser) + public function __construct(L10n $l10n, Arguments $args, LoggerInterface $logger, BaseURL $baseUrl, TwitterUser $twitterUser) { $this->l10n = $l10n; $this->args = $args; $this->logger = $logger; - $this->baseurl = $baseurl; - $this->twitterUser = $twitteruser; - } - - /** - * Sets header directly - * mainly used to override it for tests - * - * @param string $header - */ - protected function setHeader(string $header) - { - header($header); - } - - /** - * Prints output directly to the caller - * mainly used to override it for tests - * - * @param string $output - */ - protected function printOutput(string $output) - { - echo $output; - exit; + $this->baseUrl = $baseUrl; + $this->twitterUser = $twitterUser; } /** @@ -125,12 +102,12 @@ class ApiResponse $arr['$user'] = $user_info; $arr['$rss'] = [ 'alternate' => $user_info['url'], - 'self' => $this->baseurl . '/' . $this->args->getQueryString(), - 'base' => $this->baseurl, + 'self' => $this->baseUrl . '/' . $this->args->getQueryString(), + 'base' => $this->baseUrl, 'updated' => DateTimeFormat::utc(null, DateTimeFormat::API), 'atom_updated' => DateTimeFormat::utcNow(DateTimeFormat::ATOM), 'language' => $user_info['lang'], - 'logo' => $this->baseurl . '/images/friendica-32.png', + 'logo' => $this->baseUrl . '/images/friendica-32.png', ]; return $arr; @@ -222,10 +199,10 @@ class ApiResponse switch ($format) { case 'xml': - $this->setHeader('Content-Type: text/xml'); + $this->setType(static::TYPE_XML); break; case 'json': - $this->setHeader('Content-Type: application/json'); + $this->setType(static::TYPE_JSON); if (!empty($return)) { $json = json_encode(end($return)); if (!empty($_GET['callback'])) { @@ -235,14 +212,14 @@ class ApiResponse } break; case 'rss': - $this->setHeader('Content-Type: application/rss+xml'); + $this->setType(static::TYPE_RSS); break; case 'atom': - $this->setHeader('Content-Type: application/atom+xml'); + $this->setType(static::TYPE_ATOM); break; } - $this->printOutput($return); + $this->addContent($return); } /** diff --git a/src/Module/Api/Friendica/Activity.php b/src/Module/Api/Friendica/Activity.php index 1b2b95d06..aaab6417f 100644 --- a/src/Module/Api/Friendica/Activity.php +++ b/src/Module/Api/Friendica/Activity.php @@ -40,7 +40,7 @@ use Friendica\Module\BaseApi; */ class Activity extends BaseApi { - public function rawContent() + protected function rawContent(array $request = []) { self::checkAllowedScope(self::SCOPE_WRITE); $uid = self::getCurrentUserID(); @@ -57,9 +57,9 @@ class Activity extends BaseApi } else { $ok = 'ok'; } - DI::apiResponse()->exit('ok', ['ok' => $ok], $this->parameters['extension'] ?? null); + $this->response->exit('ok', ['ok' => $ok], $this->parameters['extension'] ?? null); } else { - DI::apiResponse()->error(500, 'Error adding activity', '', $this->parameters['extension'] ?? null); + $this->response->error(500, 'Error adding activity', '', $this->parameters['extension'] ?? null); } } } diff --git a/src/Module/Api/Friendica/DirectMessages/Setseen.php b/src/Module/Api/Friendica/DirectMessages/Setseen.php index 600d5fe17..d64b4ee15 100644 --- a/src/Module/Api/Friendica/DirectMessages/Setseen.php +++ b/src/Module/Api/Friendica/DirectMessages/Setseen.php @@ -30,7 +30,7 @@ use Friendica\Module\BaseApi; */ class Setseen extends BaseApi { - public function rawContent() + protected function rawContent(array $request = []) { self::checkAllowedScope(self::SCOPE_WRITE); $uid = self::getCurrentUserID(); @@ -42,13 +42,15 @@ class Setseen extends BaseApi // return error if id is zero if (empty($request['id'])) { $answer = ['result' => 'error', 'message' => 'message id not specified']; - DI::apiResponse()->exit('direct_messages_setseen', ['$result' => $answer], $this->parameters['extension'] ?? null); + $this->response->exit('direct_messages_setseen', ['$result' => $answer], $this->parameters['extension'] ?? null); + return; } // error message if specified id is not in database if (!DBA::exists('mail', ['id' => $request['id'], 'uid' => $uid])) { $answer = ['result' => 'error', 'message' => 'message id not in database']; - DI::apiResponse()->exit('direct_messages_setseen', ['$result' => $answer], $this->parameters['extension'] ?? null); + $this->response->exit('direct_messages_setseen', ['$result' => $answer], $this->parameters['extension'] ?? null); + return; } // update seen indicator @@ -58,6 +60,6 @@ class Setseen extends BaseApi $answer = ['result' => 'error', 'message' => 'unknown error']; } - DI::apiResponse()->exit('direct_messages_setseen', ['$result' => $answer], $this->parameters['extension'] ?? null); + $this->response->exit('direct_messages_setseen', ['$result' => $answer], $this->parameters['extension'] ?? null); } } diff --git a/src/Module/Api/Friendica/Events/Index.php b/src/Module/Api/Friendica/Events/Index.php index b6cfdd098..86f79578d 100644 --- a/src/Module/Api/Friendica/Events/Index.php +++ b/src/Module/Api/Friendica/Events/Index.php @@ -33,7 +33,7 @@ use Friendica\Module\BaseApi; */ class Index extends BaseApi { - public function rawContent() + protected function rawContent(array $request = []) { self::checkAllowedScope(self::SCOPE_READ); $uid = self::getCurrentUserID(); @@ -70,6 +70,6 @@ class Index extends BaseApi ]; } - DI::apiResponse()->exit('events', ['events' => $items], $this->parameters['extension'] ?? null); + $this->response->exit('events', ['events' => $items], $this->parameters['extension'] ?? null); } } diff --git a/src/Module/Api/Friendica/Group/Delete.php b/src/Module/Api/Friendica/Group/Delete.php index d78ea658e..56b3445c0 100644 --- a/src/Module/Api/Friendica/Group/Delete.php +++ b/src/Module/Api/Friendica/Group/Delete.php @@ -32,7 +32,7 @@ use Friendica\Network\HTTPException\BadRequestException; */ class Delete extends BaseApi { - public function rawContent() + protected function rawContent(array $request = []) { self::checkAllowedScope(self::SCOPE_WRITE); $uid = self::getCurrentUserID(); @@ -70,7 +70,7 @@ class Delete extends BaseApi if ($ret) { // return success $success = ['success' => $ret, 'gid' => $request['gid'], 'name' => $request['name'], 'status' => 'deleted', 'wrong users' => []]; - DI::apiResponse()->exit('group_delete', ['$result' => $success], $parameters['extension'] ?? null); + $this->response->exit('group_delete', ['$result' => $success], $parameters['extension'] ?? null); } else { throw new BadRequestException('other API error'); } diff --git a/src/Module/Api/Friendica/Index.php b/src/Module/Api/Friendica/Index.php index cc0428ae1..53229b98e 100644 --- a/src/Module/Api/Friendica/Index.php +++ b/src/Module/Api/Friendica/Index.php @@ -32,17 +32,17 @@ require_once __DIR__ . '/../../../../include/api.php'; */ class Index extends BaseApi { - public function post() + protected function post(array $request = [], array $post = []) { self::checkAllowedScope(self::SCOPE_WRITE); } - public function delete() + protected function delete() { self::checkAllowedScope(self::SCOPE_WRITE); } - public function rawContent() + protected function rawContent(array $request = []) { echo api_call(DI::args()->getCommand(), $this->parameters['extension'] ?? 'json'); exit(); diff --git a/src/Module/Api/Friendica/Notification.php b/src/Module/Api/Friendica/Notification.php index 9d316d94d..597f3d681 100644 --- a/src/Module/Api/Friendica/Notification.php +++ b/src/Module/Api/Friendica/Notification.php @@ -31,7 +31,7 @@ use Friendica\Object\Api\Friendica\Notification as ApiNotification; */ class Notification extends BaseApi { - public function rawContent() + protected function rawContent(array $request = []) { self::checkAllowedScope(self::SCOPE_READ); $uid = self::getCurrentUserID(); @@ -56,6 +56,6 @@ class Notification extends BaseApi $result = false; } - DI::apiResponse()->exit('notes', ['note' => $result], $this->parameters['extension'] ?? null); + $this->response->exit('notes', ['note' => $result], $this->parameters['extension'] ?? null); } } diff --git a/src/Module/Api/Friendica/Photo/Delete.php b/src/Module/Api/Friendica/Photo/Delete.php index ab749b4e8..2edf398aa 100644 --- a/src/Module/Api/Friendica/Photo/Delete.php +++ b/src/Module/Api/Friendica/Photo/Delete.php @@ -33,7 +33,7 @@ use Friendica\Network\HTTPException\InternalServerErrorException; */ class Delete extends BaseApi { - public function rawContent() + protected function rawContent(array $request = []) { self::checkAllowedScope(self::SCOPE_WRITE); $uid = self::getCurrentUserID(); @@ -64,7 +64,7 @@ class Delete extends BaseApi Item::deleteForUser($condition, $uid); $result = ['result' => 'deleted', 'message' => 'photo with id `' . $request['photo_id'] . '` has been deleted from server.']; - DI::apiResponse()->exit('photo_delete', ['$result' => $result], $this->parameters['extension'] ?? null); + $this->response->exit('photo_delete', ['$result' => $result], $this->parameters['extension'] ?? null); } else { throw new InternalServerErrorException("unknown error on deleting photo from database table"); } diff --git a/src/Module/Api/Friendica/Photoalbum/Delete.php b/src/Module/Api/Friendica/Photoalbum/Delete.php index 0a403270d..c7592a5ea 100644 --- a/src/Module/Api/Friendica/Photoalbum/Delete.php +++ b/src/Module/Api/Friendica/Photoalbum/Delete.php @@ -34,7 +34,7 @@ use Friendica\Network\HTTPException\InternalServerErrorException; */ class Delete extends BaseApi { - public function rawContent() + protected function rawContent(array $request = []) { self::checkAllowedScope(self::SCOPE_WRITE); $uid = self::getCurrentUserID(); @@ -67,7 +67,7 @@ class Delete extends BaseApi // return success of deletion or error message if ($result) { $answer = ['result' => 'deleted', 'message' => 'album `' . $request['album'] . '` with all containing photos has been deleted.']; - DI::apiResponse()->exit('photoalbum_delete', ['$result' => $answer], $this->parameters['extension'] ?? null); + $this->response->exit('photoalbum_delete', ['$result' => $answer], $this->parameters['extension'] ?? null); } else { throw new InternalServerErrorException("unknown error - deleting from database failed"); } diff --git a/src/Module/Api/Friendica/Photoalbum/Update.php b/src/Module/Api/Friendica/Photoalbum/Update.php index 9fc89dbf6..87513c5ad 100644 --- a/src/Module/Api/Friendica/Photoalbum/Update.php +++ b/src/Module/Api/Friendica/Photoalbum/Update.php @@ -32,7 +32,7 @@ use Friendica\Network\HTTPException\InternalServerErrorException; */ class Update extends BaseApi { - public function rawContent() + protected function rawContent(array $request = []) { self::checkAllowedScope(self::SCOPE_WRITE); $uid = self::getCurrentUserID(); @@ -59,7 +59,7 @@ class Update extends BaseApi // return success of updating or error message if ($result) { $answer = ['result' => 'updated', 'message' => 'album `' . $request['album'] . '` with all containing photos has been renamed to `' . $request['album_new'] . '`.']; - DI::apiResponse()->exit('photoalbum_update', ['$result' => $answer], $this->parameters['extension'] ?? null); + $this->response->exit('photoalbum_update', ['$result' => $answer], $this->parameters['extension'] ?? null); } else { throw new InternalServerErrorException("unknown error - updating in database failed"); } diff --git a/src/Module/Api/Friendica/Profile/Show.php b/src/Module/Api/Friendica/Profile/Show.php index 8f60c0f84..6e77f9731 100644 --- a/src/Module/Api/Friendica/Profile/Show.php +++ b/src/Module/Api/Friendica/Profile/Show.php @@ -33,7 +33,7 @@ use Friendica\Network\HTTPException; */ class Show extends BaseApi { - public function rawContent() + protected function rawContent(array $request = []) { self::checkAllowedScope(self::SCOPE_READ); $uid = self::getCurrentUserID(); @@ -61,7 +61,7 @@ class Show extends BaseApi 'profiles' => $profiles ]; - DI::apiResponse()->exit('friendica_profiles', ['$result' => $result], $this->parameters['extension'] ?? null); + $this->response->exit('friendica_profiles', ['$result' => $result], $this->parameters['extension'] ?? null); } /** diff --git a/src/Module/Api/GNUSocial/GNUSocial/Config.php b/src/Module/Api/GNUSocial/GNUSocial/Config.php index 6e661d2d7..094fd5a10 100644 --- a/src/Module/Api/GNUSocial/GNUSocial/Config.php +++ b/src/Module/Api/GNUSocial/GNUSocial/Config.php @@ -31,7 +31,7 @@ use Friendica\Module\Register; */ class Config extends BaseApi { - public function rawContent() + protected function rawContent(array $request = []) { $config = [ 'site' => [ @@ -61,6 +61,6 @@ class Config extends BaseApi ], ]; - DI::apiResponse()->exit('config', ['config' => $config], $this->parameters['extension'] ?? null); + $this->response->exit('config', ['config' => $config], $this->parameters['extension'] ?? null); } } diff --git a/src/Module/Api/GNUSocial/GNUSocial/Version.php b/src/Module/Api/GNUSocial/GNUSocial/Version.php index c9c7b98fd..9b2afe128 100644 --- a/src/Module/Api/GNUSocial/GNUSocial/Version.php +++ b/src/Module/Api/GNUSocial/GNUSocial/Version.php @@ -29,8 +29,8 @@ use Friendica\DI; */ class Version extends BaseApi { - public function rawContent() + protected function rawContent(array $request = []) { - DI::apiResponse()->exit('version', ['version' => '0.9.7'], $this->parameters['extension'] ?? null); + $this->response->exit('version', ['version' => '0.9.7'], $this->parameters['extension'] ?? null); } } diff --git a/src/Module/Api/GNUSocial/Help/Test.php b/src/Module/Api/GNUSocial/Help/Test.php index 78f18c3e6..0a2ef6f83 100644 --- a/src/Module/Api/GNUSocial/Help/Test.php +++ b/src/Module/Api/GNUSocial/Help/Test.php @@ -29,7 +29,7 @@ use Friendica\DI; */ class Test extends BaseApi { - public function rawContent() + protected function rawContent(array $request = []) { if (!empty($this->parameters['extension']) && ($this->parameters['extension'] == 'xml')) { $ok = 'true'; @@ -37,6 +37,6 @@ class Test extends BaseApi $ok = 'ok'; } - DI::apiResponse()->exit('ok', ['ok' => $ok], $this->parameters['extension'] ?? null); + $this->response->exit('ok', ['ok' => $ok], $this->parameters['extension'] ?? null); } } diff --git a/src/Module/Api/Mastodon/Accounts.php b/src/Module/Api/Mastodon/Accounts.php index 552889661..043d94b6d 100644 --- a/src/Module/Api/Mastodon/Accounts.php +++ b/src/Module/Api/Mastodon/Accounts.php @@ -35,7 +35,7 @@ class Accounts extends BaseApi /** * @throws \Friendica\Network\HTTPException\InternalServerErrorException */ - public function rawContent() + protected function rawContent(array $request = []) { $uid = self::getCurrentUserID(); diff --git a/src/Module/Api/Mastodon/Accounts/Block.php b/src/Module/Api/Mastodon/Accounts/Block.php index b2ae98bd5..a4e0bb88b 100644 --- a/src/Module/Api/Mastodon/Accounts/Block.php +++ b/src/Module/Api/Mastodon/Accounts/Block.php @@ -32,7 +32,7 @@ use Friendica\Module\BaseApi; */ class Block extends BaseApi { - public function post() + protected function post(array $request = [], array $post = []) { self::checkAllowedScope(self::SCOPE_FOLLOW); $uid = self::getCurrentUserID(); diff --git a/src/Module/Api/Mastodon/Accounts/FeaturedTags.php b/src/Module/Api/Mastodon/Accounts/FeaturedTags.php index fe92696a0..c476d1090 100644 --- a/src/Module/Api/Mastodon/Accounts/FeaturedTags.php +++ b/src/Module/Api/Mastodon/Accounts/FeaturedTags.php @@ -32,7 +32,7 @@ class FeaturedTags extends BaseApi /** * @throws \Friendica\Network\HTTPException\InternalServerErrorException */ - public function rawContent() + protected function rawContent(array $request = []) { self::checkAllowedScope(self::SCOPE_READ); diff --git a/src/Module/Api/Mastodon/Accounts/Follow.php b/src/Module/Api/Mastodon/Accounts/Follow.php index 2076d3307..443ac2540 100644 --- a/src/Module/Api/Mastodon/Accounts/Follow.php +++ b/src/Module/Api/Mastodon/Accounts/Follow.php @@ -31,7 +31,7 @@ use Friendica\Module\BaseApi; */ class Follow extends BaseApi { - public function post() + protected function post(array $request = [], array $post = []) { self::checkAllowedScope(self::SCOPE_FOLLOW); $uid = self::getCurrentUserID(); diff --git a/src/Module/Api/Mastodon/Accounts/Followers.php b/src/Module/Api/Mastodon/Accounts/Followers.php index 4c1a6429c..08c56b3d4 100644 --- a/src/Module/Api/Mastodon/Accounts/Followers.php +++ b/src/Module/Api/Mastodon/Accounts/Followers.php @@ -34,7 +34,7 @@ class Followers extends BaseApi /** * @throws \Friendica\Network\HTTPException\InternalServerErrorException */ - public function rawContent() + protected function rawContent(array $request = []) { self::checkAllowedScope(self::SCOPE_READ); $uid = self::getCurrentUserID(); diff --git a/src/Module/Api/Mastodon/Accounts/Following.php b/src/Module/Api/Mastodon/Accounts/Following.php index 4b67c9700..ded1e6a4b 100644 --- a/src/Module/Api/Mastodon/Accounts/Following.php +++ b/src/Module/Api/Mastodon/Accounts/Following.php @@ -34,7 +34,7 @@ class Following extends BaseApi /** * @throws \Friendica\Network\HTTPException\InternalServerErrorException */ - public function rawContent() + protected function rawContent(array $request = []) { self::checkAllowedScope(self::SCOPE_READ); $uid = self::getCurrentUserID(); diff --git a/src/Module/Api/Mastodon/Accounts/IdentityProofs.php b/src/Module/Api/Mastodon/Accounts/IdentityProofs.php index 88379440a..1edef9d81 100644 --- a/src/Module/Api/Mastodon/Accounts/IdentityProofs.php +++ b/src/Module/Api/Mastodon/Accounts/IdentityProofs.php @@ -32,7 +32,7 @@ class IdentityProofs extends BaseApi /** * @throws \Friendica\Network\HTTPException\InternalServerErrorException */ - public function rawContent() + protected function rawContent(array $request = []) { self::checkAllowedScope(self::SCOPE_READ); diff --git a/src/Module/Api/Mastodon/Accounts/Lists.php b/src/Module/Api/Mastodon/Accounts/Lists.php index f34b961b6..7a77902e7 100644 --- a/src/Module/Api/Mastodon/Accounts/Lists.php +++ b/src/Module/Api/Mastodon/Accounts/Lists.php @@ -35,7 +35,7 @@ class Lists extends BaseApi /** * @throws \Friendica\Network\HTTPException\InternalServerErrorException */ - public function rawContent() + protected function rawContent(array $request = []) { self::checkAllowedScope(self::SCOPE_READ); $uid = self::getCurrentUserID(); diff --git a/src/Module/Api/Mastodon/Accounts/Mute.php b/src/Module/Api/Mastodon/Accounts/Mute.php index 1c711db75..824277348 100644 --- a/src/Module/Api/Mastodon/Accounts/Mute.php +++ b/src/Module/Api/Mastodon/Accounts/Mute.php @@ -31,7 +31,7 @@ use Friendica\Module\BaseApi; */ class Mute extends BaseApi { - public function post() + protected function post(array $request = [], array $post = []) { self::checkAllowedScope(self::SCOPE_FOLLOW); $uid = self::getCurrentUserID(); diff --git a/src/Module/Api/Mastodon/Accounts/Note.php b/src/Module/Api/Mastodon/Accounts/Note.php index fe4611754..cb0c18135 100644 --- a/src/Module/Api/Mastodon/Accounts/Note.php +++ b/src/Module/Api/Mastodon/Accounts/Note.php @@ -32,7 +32,7 @@ use Friendica\Module\BaseApi; */ class Note extends BaseApi { - public function post() + protected function post(array $request = [], array $post = []) { self::checkAllowedScope(self::SCOPE_WRITE); $uid = self::getCurrentUserID(); diff --git a/src/Module/Api/Mastodon/Accounts/Relationships.php b/src/Module/Api/Mastodon/Accounts/Relationships.php index 451b7b49e..c3c886446 100644 --- a/src/Module/Api/Mastodon/Accounts/Relationships.php +++ b/src/Module/Api/Mastodon/Accounts/Relationships.php @@ -34,7 +34,7 @@ class Relationships extends BaseApi /** * @throws \Friendica\Network\HTTPException\InternalServerErrorException */ - public function rawContent() + protected function rawContent(array $request = []) { self::checkAllowedScope(self::SCOPE_READ); $uid = self::getCurrentUserID(); diff --git a/src/Module/Api/Mastodon/Accounts/Search.php b/src/Module/Api/Mastodon/Accounts/Search.php index fb3aafaec..b7b963e11 100644 --- a/src/Module/Api/Mastodon/Accounts/Search.php +++ b/src/Module/Api/Mastodon/Accounts/Search.php @@ -37,7 +37,7 @@ class Search extends BaseApi /** * @throws \Friendica\Network\HTTPException\InternalServerErrorException */ - public function rawContent() + protected function rawContent(array $request = []) { self::checkAllowedScope(self::SCOPE_READ); $uid = self::getCurrentUserID(); diff --git a/src/Module/Api/Mastodon/Accounts/Statuses.php b/src/Module/Api/Mastodon/Accounts/Statuses.php index 5bf7b4934..9027c68a4 100644 --- a/src/Module/Api/Mastodon/Accounts/Statuses.php +++ b/src/Module/Api/Mastodon/Accounts/Statuses.php @@ -39,7 +39,7 @@ class Statuses extends BaseApi /** * @throws \Friendica\Network\HTTPException\InternalServerErrorException */ - public function rawContent() + protected function rawContent(array $request = []) { $uid = self::getCurrentUserID(); diff --git a/src/Module/Api/Mastodon/Accounts/Unblock.php b/src/Module/Api/Mastodon/Accounts/Unblock.php index ae2414b8a..23d78e739 100644 --- a/src/Module/Api/Mastodon/Accounts/Unblock.php +++ b/src/Module/Api/Mastodon/Accounts/Unblock.php @@ -31,7 +31,7 @@ use Friendica\Module\BaseApi; */ class Unblock extends BaseApi { - public function post() + protected function post(array $request = [], array $post = []) { self::checkAllowedScope(self::SCOPE_FOLLOW); $uid = self::getCurrentUserID(); diff --git a/src/Module/Api/Mastodon/Accounts/Unfollow.php b/src/Module/Api/Mastodon/Accounts/Unfollow.php index a15c946bb..81f919a69 100644 --- a/src/Module/Api/Mastodon/Accounts/Unfollow.php +++ b/src/Module/Api/Mastodon/Accounts/Unfollow.php @@ -31,7 +31,7 @@ use Friendica\Module\BaseApi; */ class Unfollow extends BaseApi { - public function post() + protected function post(array $request = [], array $post = []) { self::checkAllowedScope(self::SCOPE_FOLLOW); $uid = self::getCurrentUserID(); diff --git a/src/Module/Api/Mastodon/Accounts/Unmute.php b/src/Module/Api/Mastodon/Accounts/Unmute.php index d1410f782..c9673b98c 100644 --- a/src/Module/Api/Mastodon/Accounts/Unmute.php +++ b/src/Module/Api/Mastodon/Accounts/Unmute.php @@ -31,7 +31,7 @@ use Friendica\Module\BaseApi; */ class Unmute extends BaseApi { - public function post() + protected function post(array $request = [], array $post = []) { self::checkAllowedScope(self::SCOPE_FOLLOW); $uid = self::getCurrentUserID(); diff --git a/src/Module/Api/Mastodon/Accounts/UpdateCredentials.php b/src/Module/Api/Mastodon/Accounts/UpdateCredentials.php index 2c55bff43..8d9fb4869 100644 --- a/src/Module/Api/Mastodon/Accounts/UpdateCredentials.php +++ b/src/Module/Api/Mastodon/Accounts/UpdateCredentials.php @@ -23,7 +23,6 @@ namespace Friendica\Module\Api\Mastodon\Accounts; use Friendica\App\Router; use Friendica\Core\Logger; -use Friendica\DI; use Friendica\Module\BaseApi; use Friendica\Util\HTTPInputData; @@ -32,7 +31,7 @@ use Friendica\Util\HTTPInputData; */ class UpdateCredentials extends BaseApi { - public function patch() + protected function patch() { self::checkAllowedScope(self::SCOPE_WRITE); $uid = self::getCurrentUserID(); @@ -41,6 +40,6 @@ class UpdateCredentials extends BaseApi Logger::info('Patch data', ['data' => $data]); - DI::apiResponse()->unsupported(Router::PATCH); + $this->response->unsupported(Router::PATCH); } } diff --git a/src/Module/Api/Mastodon/Accounts/VerifyCredentials.php b/src/Module/Api/Mastodon/Accounts/VerifyCredentials.php index 0cce46037..472ca7f56 100644 --- a/src/Module/Api/Mastodon/Accounts/VerifyCredentials.php +++ b/src/Module/Api/Mastodon/Accounts/VerifyCredentials.php @@ -35,7 +35,7 @@ class VerifyCredentials extends BaseApi /** * @throws \Friendica\Network\HTTPException\InternalServerErrorException */ - public function rawContent() + protected function rawContent(array $request = []) { self::checkAllowedScope(self::SCOPE_READ); $uid = self::getCurrentUserID(); diff --git a/src/Module/Api/Mastodon/Announcements.php b/src/Module/Api/Mastodon/Announcements.php index b8d231df6..46b1e85e0 100644 --- a/src/Module/Api/Mastodon/Announcements.php +++ b/src/Module/Api/Mastodon/Announcements.php @@ -32,7 +32,7 @@ class Announcements extends BaseApi /** * @throws \Friendica\Network\HTTPException\InternalServerErrorException */ - public function rawContent() + protected function rawContent(array $request = []) { self::checkAllowedScope(self::SCOPE_READ); diff --git a/src/Module/Api/Mastodon/Apps.php b/src/Module/Api/Mastodon/Apps.php index a00bd4085..7b0b103c4 100644 --- a/src/Module/Api/Mastodon/Apps.php +++ b/src/Module/Api/Mastodon/Apps.php @@ -35,7 +35,7 @@ class Apps extends BaseApi /** * @throws \Friendica\Network\HTTPException\InternalServerErrorException */ - public function post() + protected function post(array $request = [], array $post = []) { $request = self::getRequest([ 'client_name' => '', diff --git a/src/Module/Api/Mastodon/Apps/VerifyCredentials.php b/src/Module/Api/Mastodon/Apps/VerifyCredentials.php index e9720da0f..89e2fed08 100644 --- a/src/Module/Api/Mastodon/Apps/VerifyCredentials.php +++ b/src/Module/Api/Mastodon/Apps/VerifyCredentials.php @@ -30,7 +30,7 @@ use Friendica\Module\BaseApi; */ class VerifyCredentials extends BaseApi { - public function rawContent() + protected function rawContent(array $request = []) { self::checkAllowedScope(self::SCOPE_READ); $application = self::getCurrentApplication(); diff --git a/src/Module/Api/Mastodon/Blocks.php b/src/Module/Api/Mastodon/Blocks.php index 1f8b7ae6a..fe08f875d 100644 --- a/src/Module/Api/Mastodon/Blocks.php +++ b/src/Module/Api/Mastodon/Blocks.php @@ -34,7 +34,7 @@ class Blocks extends BaseApi /** * @throws \Friendica\Network\HTTPException\InternalServerErrorException */ - public function rawContent() + protected function rawContent(array $request = []) { self::checkAllowedScope(self::SCOPE_READ); $uid = self::getCurrentUserID(); diff --git a/src/Module/Api/Mastodon/Bookmarks.php b/src/Module/Api/Mastodon/Bookmarks.php index 7b51e4316..e5fcaeeaf 100644 --- a/src/Module/Api/Mastodon/Bookmarks.php +++ b/src/Module/Api/Mastodon/Bookmarks.php @@ -36,7 +36,7 @@ class Bookmarks extends BaseApi /** * @throws HTTPException\InternalServerErrorException */ - public function rawContent() + protected function rawContent(array $request = []) { self::checkAllowedScope(self::SCOPE_READ); $uid = self::getCurrentUserID(); diff --git a/src/Module/Api/Mastodon/Conversations.php b/src/Module/Api/Mastodon/Conversations.php index a3f6a26a2..fc32c76cc 100644 --- a/src/Module/Api/Mastodon/Conversations.php +++ b/src/Module/Api/Mastodon/Conversations.php @@ -31,7 +31,7 @@ use Friendica\Module\BaseApi; */ class Conversations extends BaseApi { - public function delete() + protected function delete() { self::checkAllowedScope(self::SCOPE_WRITE); $uid = self::getCurrentUserID(); @@ -49,7 +49,7 @@ class Conversations extends BaseApi /** * @throws \Friendica\Network\HTTPException\InternalServerErrorException */ - public function rawContent() + protected function rawContent(array $request = []) { self::checkAllowedScope(self::SCOPE_READ); $uid = self::getCurrentUserID(); diff --git a/src/Module/Api/Mastodon/Conversations/Read.php b/src/Module/Api/Mastodon/Conversations/Read.php index 1eadc671c..a70cdfb00 100644 --- a/src/Module/Api/Mastodon/Conversations/Read.php +++ b/src/Module/Api/Mastodon/Conversations/Read.php @@ -31,7 +31,7 @@ use Friendica\Module\BaseApi; */ class Read extends BaseApi { - public function post() + protected function post(array $request = [], array $post = []) { self::checkAllowedScope(self::SCOPE_WRITE); $uid = self::getCurrentUserID(); diff --git a/src/Module/Api/Mastodon/CustomEmojis.php b/src/Module/Api/Mastodon/CustomEmojis.php index 1fedf5348..b82a9f7d6 100644 --- a/src/Module/Api/Mastodon/CustomEmojis.php +++ b/src/Module/Api/Mastodon/CustomEmojis.php @@ -37,7 +37,7 @@ class CustomEmojis extends BaseApi * @throws \ImagickException * @see https://docs.joinmastodon.org/methods/accounts/follow_requests#pending-follows */ - public function rawContent() + protected function rawContent(array $request = []) { $emojis = DI::mstdnEmoji()->createCollectionFromSmilies(Smilies::getList()); diff --git a/src/Module/Api/Mastodon/Directory.php b/src/Module/Api/Mastodon/Directory.php index e48a70959..8ee6ac036 100644 --- a/src/Module/Api/Mastodon/Directory.php +++ b/src/Module/Api/Mastodon/Directory.php @@ -39,7 +39,7 @@ class Directory extends BaseApi * @throws \ImagickException * @see https://docs.joinmastodon.org/methods/instance/directory/ */ - public function rawContent() + protected function rawContent(array $request = []) { $request = self::getRequest([ 'offset' => 0, // How many accounts to skip before returning results. Default 0. diff --git a/src/Module/Api/Mastodon/Endorsements.php b/src/Module/Api/Mastodon/Endorsements.php index b9a5bc2cd..6c1097bc2 100644 --- a/src/Module/Api/Mastodon/Endorsements.php +++ b/src/Module/Api/Mastodon/Endorsements.php @@ -32,7 +32,7 @@ class Endorsements extends BaseApi /** * @throws \Friendica\Network\HTTPException\InternalServerErrorException */ - public function rawContent() + protected function rawContent(array $request = []) { System::jsonExit([]); } diff --git a/src/Module/Api/Mastodon/Favourited.php b/src/Module/Api/Mastodon/Favourited.php index 48aa452f2..3d3e6aad1 100644 --- a/src/Module/Api/Mastodon/Favourited.php +++ b/src/Module/Api/Mastodon/Favourited.php @@ -37,7 +37,7 @@ class Favourited extends BaseApi /** * @throws HTTPException\InternalServerErrorException */ - public function rawContent() + protected function rawContent(array $request = []) { self::checkAllowedScope(self::SCOPE_READ); $uid = self::getCurrentUserID(); diff --git a/src/Module/Api/Mastodon/Filters.php b/src/Module/Api/Mastodon/Filters.php index 5bf50db1a..3c902bc17 100644 --- a/src/Module/Api/Mastodon/Filters.php +++ b/src/Module/Api/Mastodon/Filters.php @@ -31,17 +31,17 @@ use Friendica\Module\BaseApi; */ class Filters extends BaseApi { - public function post() + public function post(array $request = [], array $post = []) { self::checkAllowedScope(self::SCOPE_WRITE); - DI::apiResponse()->unsupported(Router::POST); + $this->response->unsupported(Router::POST); } /** * @throws \Friendica\Network\HTTPException\InternalServerErrorException */ - public function rawContent() + protected function rawContent(array $request = []) { self::checkAllowedScope(self::SCOPE_READ); diff --git a/src/Module/Api/Mastodon/FollowRequests.php b/src/Module/Api/Mastodon/FollowRequests.php index af4ac5771..dbdab7e51 100644 --- a/src/Module/Api/Mastodon/FollowRequests.php +++ b/src/Module/Api/Mastodon/FollowRequests.php @@ -42,7 +42,7 @@ class FollowRequests extends BaseApi * @see https://docs.joinmastodon.org/methods/accounts/follow_requests#accept-follow * @see https://docs.joinmastodon.org/methods/accounts/follow_requests#reject-follow */ - public function post() + protected function post(array $request = [], array $post = []) { self::checkAllowedScope(self::SCOPE_FOLLOW); $uid = self::getCurrentUserID(); @@ -82,7 +82,7 @@ class FollowRequests extends BaseApi * @throws \ImagickException * @see https://docs.joinmastodon.org/methods/accounts/follow_requests/ */ - public function rawContent() + protected function rawContent(array $request = []) { self::checkAllowedScope(self::SCOPE_READ); $uid = self::getCurrentUserID(); diff --git a/src/Module/Api/Mastodon/Instance.php b/src/Module/Api/Mastodon/Instance.php index b7dc7d700..ef89de315 100644 --- a/src/Module/Api/Mastodon/Instance.php +++ b/src/Module/Api/Mastodon/Instance.php @@ -33,7 +33,7 @@ class Instance extends BaseApi /** * @throws \Friendica\Network\HTTPException\InternalServerErrorException */ - public function rawContent() + protected function rawContent(array $request = []) { System::jsonExit(InstanceEntity::get()); } diff --git a/src/Module/Api/Mastodon/Instance/Peers.php b/src/Module/Api/Mastodon/Instance/Peers.php index b1fdd062b..01b7045b2 100644 --- a/src/Module/Api/Mastodon/Instance/Peers.php +++ b/src/Module/Api/Mastodon/Instance/Peers.php @@ -36,7 +36,7 @@ class Peers extends BaseApi /** * @throws HTTPException\InternalServerErrorException */ - public function rawContent() + protected function rawContent(array $request = []) { $return = []; diff --git a/src/Module/Api/Mastodon/Instance/Rules.php b/src/Module/Api/Mastodon/Instance/Rules.php index 3063bf9ea..9154c4d6b 100644 --- a/src/Module/Api/Mastodon/Instance/Rules.php +++ b/src/Module/Api/Mastodon/Instance/Rules.php @@ -36,7 +36,7 @@ class Rules extends BaseApi /** * @throws HTTPException\InternalServerErrorException */ - public function rawContent() + protected function rawContent(array $request = []) { $rules = []; $id = 0; diff --git a/src/Module/Api/Mastodon/Lists.php b/src/Module/Api/Mastodon/Lists.php index e7a66f04d..ec9ad86a3 100644 --- a/src/Module/Api/Mastodon/Lists.php +++ b/src/Module/Api/Mastodon/Lists.php @@ -31,7 +31,7 @@ use Friendica\Model\Group; */ class Lists extends BaseApi { - public function delete() + protected function delete() { self::checkAllowedScope(self::SCOPE_WRITE); $uid = self::getCurrentUserID(); @@ -51,7 +51,7 @@ class Lists extends BaseApi System::jsonExit([]); } - public function post() + protected function post(array $request = [], array $post = []) { self::checkAllowedScope(self::SCOPE_WRITE); $uid = self::getCurrentUserID(); @@ -91,7 +91,7 @@ class Lists extends BaseApi /** * @throws \Friendica\Network\HTTPException\InternalServerErrorException */ - public function rawContent() + protected function rawContent(array $request = []) { self::checkAllowedScope(self::SCOPE_READ); $uid = self::getCurrentUserID(); diff --git a/src/Module/Api/Mastodon/Lists/Accounts.php b/src/Module/Api/Mastodon/Lists/Accounts.php index feb670b27..be87dbf9d 100644 --- a/src/Module/Api/Mastodon/Lists/Accounts.php +++ b/src/Module/Api/Mastodon/Lists/Accounts.php @@ -25,7 +25,6 @@ use Friendica\App\Router; use Friendica\Core\System; use Friendica\Database\DBA; use Friendica\DI; -use Friendica\Module\Api\ApiResponse; use Friendica\Module\BaseApi; /** @@ -35,20 +34,20 @@ use Friendica\Module\BaseApi; */ class Accounts extends BaseApi { - public function delete() + protected function delete() { - DI::apiResponse()->unsupported(Router::DELETE); + $this->response->unsupported(Router::DELETE); } - public function post() + protected function post(array $request = [], array $post = []) { - DI::apiResponse()->unsupported(Router::POST); + $this->response->unsupported(Router::POST); } /** * @throws \Friendica\Network\HTTPException\InternalServerErrorException */ - public function rawContent() + protected function rawContent(array $request = []) { self::checkAllowedScope(self::SCOPE_READ); $uid = self::getCurrentUserID(); diff --git a/src/Module/Api/Mastodon/Markers.php b/src/Module/Api/Mastodon/Markers.php index 6a01a30cf..9f208e926 100644 --- a/src/Module/Api/Mastodon/Markers.php +++ b/src/Module/Api/Mastodon/Markers.php @@ -31,17 +31,17 @@ use Friendica\Module\BaseApi; */ class Markers extends BaseApi { - public function post() + protected function post(array $request = [], array $post = []) { self::checkAllowedScope(self::SCOPE_WRITE); - DI::apiResponse()->unsupported(Router::POST); + $this->response->unsupported(Router::POST); } /** * @throws \Friendica\Network\HTTPException\InternalServerErrorException */ - public function rawContent() + protected function rawContent(array $request = []) { self::checkAllowedScope(self::SCOPE_READ); diff --git a/src/Module/Api/Mastodon/Media.php b/src/Module/Api/Mastodon/Media.php index dc31bdec6..65663882d 100644 --- a/src/Module/Api/Mastodon/Media.php +++ b/src/Module/Api/Mastodon/Media.php @@ -32,7 +32,7 @@ use Friendica\Module\BaseApi; */ class Media extends BaseApi { - public function post() + protected function post(array $request = [], array $post = []) { self::checkAllowedScope(self::SCOPE_WRITE); $uid = self::getCurrentUserID(); @@ -82,7 +82,7 @@ class Media extends BaseApi /** * @throws \Friendica\Network\HTTPException\InternalServerErrorException */ - public function rawContent() + protected function rawContent(array $request = []) { self::checkAllowedScope(self::SCOPE_READ); $uid = self::getCurrentUserID(); diff --git a/src/Module/Api/Mastodon/Mutes.php b/src/Module/Api/Mastodon/Mutes.php index 191a2d607..515e04848 100644 --- a/src/Module/Api/Mastodon/Mutes.php +++ b/src/Module/Api/Mastodon/Mutes.php @@ -34,7 +34,7 @@ class Mutes extends BaseApi /** * @throws \Friendica\Network\HTTPException\InternalServerErrorException */ - public function rawContent() + protected function rawContent(array $request = []) { self::checkAllowedScope(self::SCOPE_READ); $uid = self::getCurrentUserID(); diff --git a/src/Module/Api/Mastodon/Notifications.php b/src/Module/Api/Mastodon/Notifications.php index 274a85786..664c996c9 100644 --- a/src/Module/Api/Mastodon/Notifications.php +++ b/src/Module/Api/Mastodon/Notifications.php @@ -40,7 +40,7 @@ class Notifications extends BaseApi /** * @throws \Friendica\Network\HTTPException\InternalServerErrorException */ - public function rawContent() + protected function rawContent(array $request = []) { self::checkAllowedScope(self::SCOPE_READ); $uid = self::getCurrentUserID(); diff --git a/src/Module/Api/Mastodon/Notifications/Clear.php b/src/Module/Api/Mastodon/Notifications/Clear.php index 424979157..d910fe07d 100644 --- a/src/Module/Api/Mastodon/Notifications/Clear.php +++ b/src/Module/Api/Mastodon/Notifications/Clear.php @@ -30,7 +30,7 @@ use Friendica\Module\BaseApi; */ class Clear extends BaseApi { - public function post() + protected function post(array $request = [], array $post = []) { self::checkAllowedScope(self::SCOPE_WRITE); $uid = self::getCurrentUserID(); diff --git a/src/Module/Api/Mastodon/Notifications/Dismiss.php b/src/Module/Api/Mastodon/Notifications/Dismiss.php index b978e46ee..98861a275 100644 --- a/src/Module/Api/Mastodon/Notifications/Dismiss.php +++ b/src/Module/Api/Mastodon/Notifications/Dismiss.php @@ -32,7 +32,7 @@ use Friendica\Network\HTTPException\ForbiddenException; */ class Dismiss extends BaseApi { - public function post() + protected function post(array $request = [], array $post = []) { self::checkAllowedScope(self::SCOPE_WRITE); $uid = self::getCurrentUserID(); diff --git a/src/Module/Api/Mastodon/Preferences.php b/src/Module/Api/Mastodon/Preferences.php index 6d846c35b..14b5efe68 100644 --- a/src/Module/Api/Mastodon/Preferences.php +++ b/src/Module/Api/Mastodon/Preferences.php @@ -34,7 +34,7 @@ class Preferences extends BaseApi /** * @throws \Friendica\Network\HTTPException\InternalServerErrorException */ - public function rawContent() + protected function rawContent(array $request = []) { self::checkAllowedScope(self::SCOPE_READ); $uid = self::getCurrentUserID(); diff --git a/src/Module/Api/Mastodon/Proofs.php b/src/Module/Api/Mastodon/Proofs.php index c9b92246a..f39cfcf27 100644 --- a/src/Module/Api/Mastodon/Proofs.php +++ b/src/Module/Api/Mastodon/Proofs.php @@ -32,7 +32,7 @@ class Proofs extends BaseApi /** * @throws \Friendica\Network\HTTPException\InternalServerErrorException */ - public function rawContent() + protected function rawContent(array $request = []) { System::jsonError(404, ['error' => 'Record not found']); } diff --git a/src/Module/Api/Mastodon/PushSubscription.php b/src/Module/Api/Mastodon/PushSubscription.php index e45c943f5..91e79b82d 100644 --- a/src/Module/Api/Mastodon/PushSubscription.php +++ b/src/Module/Api/Mastodon/PushSubscription.php @@ -33,7 +33,7 @@ use Friendica\Object\Api\Mastodon\Notification; */ class PushSubscription extends BaseApi { - public function post() + protected function post(array $request = [], array $post = []) { self::checkAllowedScope(self::SCOPE_PUSH); $uid = self::getCurrentUserID(); @@ -99,7 +99,7 @@ class PushSubscription extends BaseApi return DI::mstdnSubscription()->createForApplicationIdAndUserId($application['id'], $uid)->toArray(); } - public function delete() + protected function delete() { self::checkAllowedScope(self::SCOPE_PUSH); $uid = self::getCurrentUserID(); @@ -112,7 +112,7 @@ class PushSubscription extends BaseApi System::jsonExit([]); } - public function rawContent() + protected function rawContent(array $request = []) { self::checkAllowedScope(self::SCOPE_PUSH); $uid = self::getCurrentUserID(); diff --git a/src/Module/Api/Mastodon/ScheduledStatuses.php b/src/Module/Api/Mastodon/ScheduledStatuses.php index bfb2cff45..e79d1e153 100644 --- a/src/Module/Api/Mastodon/ScheduledStatuses.php +++ b/src/Module/Api/Mastodon/ScheduledStatuses.php @@ -26,7 +26,6 @@ use Friendica\Core\System; use Friendica\Database\DBA; use Friendica\DI; use Friendica\Model\Post; -use Friendica\Module\Api\ApiResponse; use Friendica\Module\BaseApi; /** @@ -39,10 +38,10 @@ class ScheduledStatuses extends BaseApi self::checkAllowedScope(self::SCOPE_WRITE); $uid = self::getCurrentUserID(); - DI::apiResponse()->unsupported(Router::PUT); + $this->response->unsupported(Router::PUT); } - public function delete() + protected function delete() { self::checkAllowedScope(self::SCOPE_WRITE); $uid = self::getCurrentUserID(); @@ -63,7 +62,7 @@ class ScheduledStatuses extends BaseApi /** * @throws \Friendica\Network\HTTPException\InternalServerErrorException */ - public function rawContent() + protected function rawContent(array $request = []) { self::checkAllowedScope(self::SCOPE_READ); $uid = self::getCurrentUserID(); diff --git a/src/Module/Api/Mastodon/Search.php b/src/Module/Api/Mastodon/Search.php index 6753b0909..026d71f04 100644 --- a/src/Module/Api/Mastodon/Search.php +++ b/src/Module/Api/Mastodon/Search.php @@ -40,7 +40,7 @@ class Search extends BaseApi /** * @throws \Friendica\Network\HTTPException\InternalServerErrorException */ - public function rawContent() + protected function rawContent(array $request = []) { self::checkAllowedScope(self::SCOPE_READ); $uid = self::getCurrentUserID(); diff --git a/src/Module/Api/Mastodon/Statuses.php b/src/Module/Api/Mastodon/Statuses.php index 50c35f347..21bb97285 100644 --- a/src/Module/Api/Mastodon/Statuses.php +++ b/src/Module/Api/Mastodon/Statuses.php @@ -41,7 +41,7 @@ use Friendica\Util\Images; */ class Statuses extends BaseApi { - public function post() + protected function post(array $request = [], array $post = []) { self::checkAllowedScope(self::SCOPE_WRITE); $uid = self::getCurrentUserID(); @@ -207,7 +207,7 @@ class Statuses extends BaseApi DI::mstdnError()->InternalError(); } - public function delete() + protected function delete() { self::checkAllowedScope(self::SCOPE_READ); $uid = self::getCurrentUserID(); @@ -231,7 +231,7 @@ class Statuses extends BaseApi /** * @throws \Friendica\Network\HTTPException\InternalServerErrorException */ - public function rawContent() + protected function rawContent(array $request = []) { $uid = self::getCurrentUserID(); diff --git a/src/Module/Api/Mastodon/Statuses/Bookmark.php b/src/Module/Api/Mastodon/Statuses/Bookmark.php index de0ef641d..0ff561189 100644 --- a/src/Module/Api/Mastodon/Statuses/Bookmark.php +++ b/src/Module/Api/Mastodon/Statuses/Bookmark.php @@ -33,7 +33,7 @@ use Friendica\Module\BaseApi; */ class Bookmark extends BaseApi { - public function post() + protected function post(array $request = [], array $post = []) { self::checkAllowedScope(self::SCOPE_WRITE); $uid = self::getCurrentUserID(); diff --git a/src/Module/Api/Mastodon/Statuses/Card.php b/src/Module/Api/Mastodon/Statuses/Card.php index d3c1801a2..eeed4bb0a 100644 --- a/src/Module/Api/Mastodon/Statuses/Card.php +++ b/src/Module/Api/Mastodon/Statuses/Card.php @@ -35,7 +35,7 @@ class Card extends BaseApi /** * @throws \Friendica\Network\HTTPException\InternalServerErrorException */ - public function rawContent() + protected function rawContent(array $request = []) { $uid = self::getCurrentUserID(); diff --git a/src/Module/Api/Mastodon/Statuses/Context.php b/src/Module/Api/Mastodon/Statuses/Context.php index 03782ef1c..674be5f22 100644 --- a/src/Module/Api/Mastodon/Statuses/Context.php +++ b/src/Module/Api/Mastodon/Statuses/Context.php @@ -35,7 +35,7 @@ class Context extends BaseApi /** * @throws \Friendica\Network\HTTPException\InternalServerErrorException */ - public function rawContent() + protected function rawContent(array $request = []) { $uid = self::getCurrentUserID(); diff --git a/src/Module/Api/Mastodon/Statuses/Favourite.php b/src/Module/Api/Mastodon/Statuses/Favourite.php index 8ec818a8f..fc070548b 100644 --- a/src/Module/Api/Mastodon/Statuses/Favourite.php +++ b/src/Module/Api/Mastodon/Statuses/Favourite.php @@ -33,7 +33,7 @@ use Friendica\Module\BaseApi; */ class Favourite extends BaseApi { - public function post() + protected function post(array $request = [], array $post = []) { self::checkAllowedScope(self::SCOPE_WRITE); $uid = self::getCurrentUserID(); diff --git a/src/Module/Api/Mastodon/Statuses/FavouritedBy.php b/src/Module/Api/Mastodon/Statuses/FavouritedBy.php index 37d9e7521..d29da2c99 100644 --- a/src/Module/Api/Mastodon/Statuses/FavouritedBy.php +++ b/src/Module/Api/Mastodon/Statuses/FavouritedBy.php @@ -35,7 +35,7 @@ class FavouritedBy extends BaseApi /** * @throws \Friendica\Network\HTTPException\InternalServerErrorException */ - public function rawContent() + protected function rawContent(array $request = []) { $uid = self::getCurrentUserID(); diff --git a/src/Module/Api/Mastodon/Statuses/Mute.php b/src/Module/Api/Mastodon/Statuses/Mute.php index 4a0e943f3..7b7a67051 100644 --- a/src/Module/Api/Mastodon/Statuses/Mute.php +++ b/src/Module/Api/Mastodon/Statuses/Mute.php @@ -32,7 +32,7 @@ use Friendica\Module\BaseApi; */ class Mute extends BaseApi { - public function post() + protected function post(array $request = [], array $post = []) { self::checkAllowedScope(self::SCOPE_WRITE); $uid = self::getCurrentUserID(); diff --git a/src/Module/Api/Mastodon/Statuses/Pin.php b/src/Module/Api/Mastodon/Statuses/Pin.php index 7648d12a0..9697d795b 100644 --- a/src/Module/Api/Mastodon/Statuses/Pin.php +++ b/src/Module/Api/Mastodon/Statuses/Pin.php @@ -32,7 +32,7 @@ use Friendica\Module\BaseApi; */ class Pin extends BaseApi { - public function post() + protected function post(array $request = [], array $post = []) { self::checkAllowedScope(self::SCOPE_WRITE); $uid = self::getCurrentUserID(); diff --git a/src/Module/Api/Mastodon/Statuses/Reblog.php b/src/Module/Api/Mastodon/Statuses/Reblog.php index d10149616..64d30e66d 100644 --- a/src/Module/Api/Mastodon/Statuses/Reblog.php +++ b/src/Module/Api/Mastodon/Statuses/Reblog.php @@ -35,7 +35,7 @@ use Friendica\Module\BaseApi; */ class Reblog extends BaseApi { - public function post() + protected function post(array $request = [], array $post = []) { self::checkAllowedScope(self::SCOPE_WRITE); $uid = self::getCurrentUserID(); diff --git a/src/Module/Api/Mastodon/Statuses/RebloggedBy.php b/src/Module/Api/Mastodon/Statuses/RebloggedBy.php index 52f1e2f67..a3010e882 100644 --- a/src/Module/Api/Mastodon/Statuses/RebloggedBy.php +++ b/src/Module/Api/Mastodon/Statuses/RebloggedBy.php @@ -35,7 +35,7 @@ class RebloggedBy extends BaseApi /** * @throws \Friendica\Network\HTTPException\InternalServerErrorException */ - public function rawContent() + protected function rawContent(array $request = []) { $uid = self::getCurrentUserID(); diff --git a/src/Module/Api/Mastodon/Statuses/Unbookmark.php b/src/Module/Api/Mastodon/Statuses/Unbookmark.php index 9279fec60..3232e1298 100644 --- a/src/Module/Api/Mastodon/Statuses/Unbookmark.php +++ b/src/Module/Api/Mastodon/Statuses/Unbookmark.php @@ -33,7 +33,7 @@ use Friendica\Module\BaseApi; */ class Unbookmark extends BaseApi { - public function post() + protected function post(array $request = [], array $post = []) { self::checkAllowedScope(self::SCOPE_WRITE); $uid = self::getCurrentUserID(); diff --git a/src/Module/Api/Mastodon/Statuses/Unfavourite.php b/src/Module/Api/Mastodon/Statuses/Unfavourite.php index 7898647ac..7e5081656 100644 --- a/src/Module/Api/Mastodon/Statuses/Unfavourite.php +++ b/src/Module/Api/Mastodon/Statuses/Unfavourite.php @@ -33,7 +33,7 @@ use Friendica\Module\BaseApi; */ class Unfavourite extends BaseApi { - public function post() + protected function post(array $request = [], array $post = []) { self::checkAllowedScope(self::SCOPE_WRITE); $uid = self::getCurrentUserID(); diff --git a/src/Module/Api/Mastodon/Statuses/Unmute.php b/src/Module/Api/Mastodon/Statuses/Unmute.php index 80b9c2c54..c380f05d0 100644 --- a/src/Module/Api/Mastodon/Statuses/Unmute.php +++ b/src/Module/Api/Mastodon/Statuses/Unmute.php @@ -32,7 +32,7 @@ use Friendica\Module\BaseApi; */ class Unmute extends BaseApi { - public function post() + protected function post(array $request = [], array $post = []) { self::checkAllowedScope(self::SCOPE_WRITE); $uid = self::getCurrentUserID(); diff --git a/src/Module/Api/Mastodon/Statuses/Unpin.php b/src/Module/Api/Mastodon/Statuses/Unpin.php index 21f44b7cb..9af2fe28d 100644 --- a/src/Module/Api/Mastodon/Statuses/Unpin.php +++ b/src/Module/Api/Mastodon/Statuses/Unpin.php @@ -32,7 +32,7 @@ use Friendica\Module\BaseApi; */ class Unpin extends BaseApi { - public function post() + protected function post(array $request = [], array $post = []) { self::checkAllowedScope(self::SCOPE_WRITE); $uid = self::getCurrentUserID(); diff --git a/src/Module/Api/Mastodon/Statuses/Unreblog.php b/src/Module/Api/Mastodon/Statuses/Unreblog.php index 972a6aa1a..27708acad 100644 --- a/src/Module/Api/Mastodon/Statuses/Unreblog.php +++ b/src/Module/Api/Mastodon/Statuses/Unreblog.php @@ -35,7 +35,7 @@ use Friendica\Module\BaseApi; */ class Unreblog extends BaseApi { - public function post() + protected function post(array $request = [], array $post = []) { self::checkAllowedScope(self::SCOPE_WRITE); $uid = self::getCurrentUserID(); diff --git a/src/Module/Api/Mastodon/Suggestions.php b/src/Module/Api/Mastodon/Suggestions.php index b80c239f6..bda78becf 100644 --- a/src/Module/Api/Mastodon/Suggestions.php +++ b/src/Module/Api/Mastodon/Suggestions.php @@ -34,7 +34,7 @@ class Suggestions extends BaseApi /** * @throws \Friendica\Network\HTTPException\InternalServerErrorException */ - public function rawContent() + protected function rawContent(array $request = []) { self::checkAllowedScope(self::SCOPE_READ); $uid = self::getCurrentUserID(); diff --git a/src/Module/Api/Mastodon/Timelines/Direct.php b/src/Module/Api/Mastodon/Timelines/Direct.php index d50c97f47..ef2a9bb1a 100644 --- a/src/Module/Api/Mastodon/Timelines/Direct.php +++ b/src/Module/Api/Mastodon/Timelines/Direct.php @@ -35,7 +35,7 @@ class Direct extends BaseApi /** * @throws HTTPException\InternalServerErrorException */ - public function rawContent() + protected function rawContent(array $request = []) { self::checkAllowedScope(self::SCOPE_READ); $uid = self::getCurrentUserID(); diff --git a/src/Module/Api/Mastodon/Timelines/Home.php b/src/Module/Api/Mastodon/Timelines/Home.php index de21bb2a1..2727745f0 100644 --- a/src/Module/Api/Mastodon/Timelines/Home.php +++ b/src/Module/Api/Mastodon/Timelines/Home.php @@ -36,7 +36,7 @@ class Home extends BaseApi /** * @throws HTTPException\InternalServerErrorException */ - public function rawContent() + protected function rawContent(array $request = []) { self::checkAllowedScope(self::SCOPE_READ); $uid = self::getCurrentUserID(); diff --git a/src/Module/Api/Mastodon/Timelines/ListTimeline.php b/src/Module/Api/Mastodon/Timelines/ListTimeline.php index c9316fdf5..1fe3f3b47 100644 --- a/src/Module/Api/Mastodon/Timelines/ListTimeline.php +++ b/src/Module/Api/Mastodon/Timelines/ListTimeline.php @@ -36,7 +36,7 @@ class ListTimeline extends BaseApi /** * @throws HTTPException\InternalServerErrorException */ - public function rawContent() + protected function rawContent(array $request = []) { self::checkAllowedScope(self::SCOPE_READ); $uid = self::getCurrentUserID(); diff --git a/src/Module/Api/Mastodon/Timelines/PublicTimeline.php b/src/Module/Api/Mastodon/Timelines/PublicTimeline.php index 162236d1e..91894f5c6 100644 --- a/src/Module/Api/Mastodon/Timelines/PublicTimeline.php +++ b/src/Module/Api/Mastodon/Timelines/PublicTimeline.php @@ -39,7 +39,7 @@ class PublicTimeline extends BaseApi /** * @throws HTTPException\InternalServerErrorException */ - public function rawContent() + protected function rawContent(array $request = []) { $uid = self::getCurrentUserID(); diff --git a/src/Module/Api/Mastodon/Timelines/Tag.php b/src/Module/Api/Mastodon/Timelines/Tag.php index 3571dd733..701d656e4 100644 --- a/src/Module/Api/Mastodon/Timelines/Tag.php +++ b/src/Module/Api/Mastodon/Timelines/Tag.php @@ -37,7 +37,7 @@ class Tag extends BaseApi /** * @throws HTTPException\InternalServerErrorException */ - public function rawContent() + protected function rawContent(array $request = []) { self::checkAllowedScope(self::SCOPE_READ); $uid = self::getCurrentUserID(); diff --git a/src/Module/Api/Mastodon/Trends.php b/src/Module/Api/Mastodon/Trends.php index 3536e737c..c9659f7d2 100644 --- a/src/Module/Api/Mastodon/Trends.php +++ b/src/Module/Api/Mastodon/Trends.php @@ -34,7 +34,7 @@ class Trends extends BaseApi /** * @throws \Friendica\Network\HTTPException\InternalServerErrorException */ - public function rawContent() + protected function rawContent(array $request = []) { $request = self::getRequest([ 'limit' => 20, // Maximum number of results to return. Defaults to 10. diff --git a/src/Module/Api/Mastodon/Unimplemented.php b/src/Module/Api/Mastodon/Unimplemented.php index f5f76afd5..22111781b 100644 --- a/src/Module/Api/Mastodon/Unimplemented.php +++ b/src/Module/Api/Mastodon/Unimplemented.php @@ -22,7 +22,6 @@ namespace Friendica\Module\Api\Mastodon; use Friendica\App\Router; -use Friendica\DI; use Friendica\Module\BaseApi; /** @@ -33,25 +32,25 @@ class Unimplemented extends BaseApi /** * @throws \Friendica\Network\HTTPException\InternalServerErrorException */ - public function delete() + protected function delete() { - DI::apiResponse()->unsupported(Router::DELETE); + $this->response->unsupported(Router::DELETE); } /** * @throws \Friendica\Network\HTTPException\InternalServerErrorException */ - public function patch() + protected function patch() { - DI::apiResponse()->unsupported(Router::PATCH); + $this->response->unsupported(Router::PATCH); } /** * @throws \Friendica\Network\HTTPException\InternalServerErrorException */ - public function post() + protected function post(array $request = [], array $post = []) { - DI::apiResponse()->unsupported(Router::POST); + $this->response->unsupported(Router::POST); } /** @@ -59,14 +58,14 @@ class Unimplemented extends BaseApi */ public function put() { - DI::apiResponse()->unsupported(Router::PUT); + $this->response->unsupported(Router::PUT); } /** * @throws \Friendica\Network\HTTPException\InternalServerErrorException */ - public function rawContent() + protected function rawContent(array $request = []) { - DI::apiResponse()->unsupported(Router::GET); + $this->response->unsupported(Router::GET); } } diff --git a/src/Module/Api/Twitter/Account/RateLimitStatus.php b/src/Module/Api/Twitter/Account/RateLimitStatus.php index 9a275cecb..5f1d37e7b 100644 --- a/src/Module/Api/Twitter/Account/RateLimitStatus.php +++ b/src/Module/Api/Twitter/Account/RateLimitStatus.php @@ -22,7 +22,6 @@ namespace Friendica\Module\Api\Twitter\Account; use Friendica\Module\BaseApi; -use Friendica\DI; use Friendica\Util\DateTimeFormat; /** @@ -30,7 +29,7 @@ use Friendica\Util\DateTimeFormat; */ class RateLimitStatus extends BaseApi { - public function rawContent() + protected function rawContent(array $request = []) { if (!empty($this->parameters['extension']) && ($this->parameters['extension'] == 'xml')) { $hash = [ @@ -52,6 +51,6 @@ class RateLimitStatus extends BaseApi ]; } - DI::apiResponse()->exit('hash', ['hash' => $hash], $this->parameters['extension'] ?? null); + $this->response->exit('hash', ['hash' => $hash], $this->parameters['extension'] ?? null); } } diff --git a/src/Module/Api/Twitter/ContactEndpoint.php b/src/Module/Api/Twitter/ContactEndpoint.php index 9227815a0..541f7fd86 100644 --- a/src/Module/Api/Twitter/ContactEndpoint.php +++ b/src/Module/Api/Twitter/ContactEndpoint.php @@ -21,24 +21,28 @@ namespace Friendica\Module\Api\Twitter; +use Friendica\App; use Friendica\Core\L10n; use Friendica\Database\DBA; use Friendica\DI; use Friendica\Model\Profile; use Friendica\Model\User; +use Friendica\Module\Api\ApiResponse; use Friendica\Module\BaseApi; use Friendica\Model\Contact; use Friendica\Network\HTTPException; +use Friendica\Util\Profiler; use Friendica\Util\Strings; +use Psr\Log\LoggerInterface; abstract class ContactEndpoint extends BaseApi { const DEFAULT_COUNT = 20; const MAX_COUNT = 200; - public function __construct(L10n $l10n, array $parameters = []) + public function __construct(App $app, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, ApiResponse $response, array $server, array $parameters = []) { - parent::__construct($l10n, $parameters); + parent::__construct($app, $l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters); self::checkAllowedScope(self::SCOPE_READ); } diff --git a/src/Module/Api/Twitter/Followers/Ids.php b/src/Module/Api/Twitter/Followers/Ids.php index f529fc926..5f203a052 100644 --- a/src/Module/Api/Twitter/Followers/Ids.php +++ b/src/Module/Api/Twitter/Followers/Ids.php @@ -31,7 +31,7 @@ use Friendica\Module\BaseApi; */ class Ids extends ContactEndpoint { - public function rawContent() + protected function rawContent(array $request = []) { self::checkAllowedScope(self::SCOPE_READ); $uid = BaseApi::getCurrentUserID(); diff --git a/src/Module/Api/Twitter/Followers/Lists.php b/src/Module/Api/Twitter/Followers/Lists.php index 0bd3addd5..a812e38da 100644 --- a/src/Module/Api/Twitter/Followers/Lists.php +++ b/src/Module/Api/Twitter/Followers/Lists.php @@ -31,7 +31,7 @@ use Friendica\Module\BaseApi; */ class Lists extends ContactEndpoint { - public function rawContent() + protected function rawContent(array $request = []) { self::checkAllowedScope(self::SCOPE_READ); $uid = BaseApi::getCurrentUserID(); diff --git a/src/Module/Api/Twitter/Friends/Ids.php b/src/Module/Api/Twitter/Friends/Ids.php index 0c25700cc..62164840d 100644 --- a/src/Module/Api/Twitter/Friends/Ids.php +++ b/src/Module/Api/Twitter/Friends/Ids.php @@ -31,7 +31,7 @@ use Friendica\Module\BaseApi; */ class Ids extends ContactEndpoint { - public function rawContent() + protected function rawContent(array $request = []) { self::checkAllowedScope(self::SCOPE_READ); $uid = BaseApi::getCurrentUserID(); diff --git a/src/Module/Api/Twitter/Friends/Lists.php b/src/Module/Api/Twitter/Friends/Lists.php index 25bd32969..57841c3c9 100644 --- a/src/Module/Api/Twitter/Friends/Lists.php +++ b/src/Module/Api/Twitter/Friends/Lists.php @@ -31,7 +31,7 @@ use Friendica\Module\BaseApi; */ class Lists extends ContactEndpoint { - public function rawContent() + protected function rawContent(array $request = []) { self::checkAllowedScope(self::SCOPE_READ); $uid = BaseApi::getCurrentUserID(); diff --git a/src/Module/Api/Twitter/SavedSearches.php b/src/Module/Api/Twitter/SavedSearches.php index ac7531671..31824a8d4 100644 --- a/src/Module/Api/Twitter/SavedSearches.php +++ b/src/Module/Api/Twitter/SavedSearches.php @@ -22,7 +22,6 @@ namespace Friendica\Module\Api\Twitter; use Friendica\Database\DBA; -use Friendica\DI; use Friendica\Module\BaseApi; /** @@ -31,7 +30,7 @@ use Friendica\Module\BaseApi; */ class SavedSearches extends BaseApi { - public function rawContent() + protected function rawContent(array $request = []) { self::checkAllowedScope(self::SCOPE_READ); $uid = self::getCurrentUserID(); @@ -45,6 +44,6 @@ class SavedSearches extends BaseApi DBA::close($terms); - DI::apiResponse()->exit('terms', ['terms' => $result], $this->parameters['extension'] ?? null); + $this->response->exit('terms', ['terms' => $result], $this->parameters['extension'] ?? null); } } diff --git a/src/Module/Apps.php b/src/Module/Apps.php index f414f7f8c..6b8d18b94 100644 --- a/src/Module/Apps.php +++ b/src/Module/Apps.php @@ -21,21 +21,24 @@ namespace Friendica\Module; +use Friendica\App; use Friendica\App\BaseURL; use Friendica\BaseModule; use Friendica\Content\Nav; use Friendica\Core\Config\Capability\IManageConfigValues; use Friendica\Core\L10n; use Friendica\Core\Renderer; +use Friendica\Util\Profiler; +use Psr\Log\LoggerInterface; /** * Shows the App menu */ class Apps extends BaseModule { - public function __construct(L10n $l10n, IManageConfigValues $config, BaseURL $baseUrl, array $parameters = []) + public function __construct(L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, IManageConfigValues $config, array $server, array $parameters = []) { - parent::__construct($l10n, $parameters); + parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters); $privateaddons = $config->get('config', 'private_addons'); if ($privateaddons === "1" && !local_user()) { @@ -43,7 +46,7 @@ class Apps extends BaseModule } } - public function content(): string + protected function content(array $request = []): string { $apps = Nav::getAppMenu(); diff --git a/src/Module/Attach.php b/src/Module/Attach.php index c35e6b9ba..bd785881c 100644 --- a/src/Module/Attach.php +++ b/src/Module/Attach.php @@ -34,7 +34,7 @@ class Attach extends BaseModule /** * Return to user an attached file given the id */ - public function rawContent() + protected function rawContent(array $request = []) { $a = DI::app(); if (empty($this->parameters['item'])) { diff --git a/src/Module/BaseAdmin.php b/src/Module/BaseAdmin.php index 83e3ca0b1..91b9e85b6 100644 --- a/src/Module/BaseAdmin.php +++ b/src/Module/BaseAdmin.php @@ -68,7 +68,7 @@ abstract class BaseAdmin extends BaseModule } } - public function content(): string + protected function content(array $request = []): string { self::checkAdminAccess(true); diff --git a/src/Module/BaseApi.php b/src/Module/BaseApi.php index 03c8467a4..009809376 100644 --- a/src/Module/BaseApi.php +++ b/src/Module/BaseApi.php @@ -21,18 +21,23 @@ namespace Friendica\Module; +use Friendica\App; use Friendica\BaseModule; +use Friendica\Core\L10n; use Friendica\Core\Logger; use Friendica\Core\System; use Friendica\DI; use Friendica\Model\Contact; use Friendica\Model\Post; use Friendica\Model\User; +use Friendica\Module\Api\ApiResponse; use Friendica\Network\HTTPException; use Friendica\Security\BasicAuth; use Friendica\Security\OAuth; use Friendica\Util\DateTimeFormat; use Friendica\Util\HTTPInputData; +use Friendica\Util\Profiler; +use Psr\Log\LoggerInterface; class BaseApi extends BaseModule { @@ -53,30 +58,41 @@ class BaseApi extends BaseModule */ protected static $request = []; - public function delete() + /** @var App */ + protected $app; + + /** @var ApiResponse */ + protected $response; + + public function __construct(App $app, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, ApiResponse $response, array $server, array $parameters = []) + { + parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters); + } + + protected function delete() { self::checkAllowedScope(self::SCOPE_WRITE); - if (!DI::app()->isLoggedIn()) { - throw new HTTPException\ForbiddenException(DI::l10n()->t('Permission denied.')); + if (!$this->app->isLoggedIn()) { + throw new HTTPException\ForbiddenException($this->t('Permission denied.')); } } - public function patch() + protected function patch() { self::checkAllowedScope(self::SCOPE_WRITE); - if (!DI::app()->isLoggedIn()) { - throw new HTTPException\ForbiddenException(DI::l10n()->t('Permission denied.')); + if (!$this->app->isLoggedIn()) { + throw new HTTPException\ForbiddenException($this->t('Permission denied.')); } } - public function post() + protected function post(array $request = [], array $post = []) { self::checkAllowedScope(self::SCOPE_WRITE); - if (!DI::app()->isLoggedIn()) { - throw new HTTPException\ForbiddenException(DI::l10n()->t('Permission denied.')); + if (!$this->app->isLoggedIn()) { + throw new HTTPException\ForbiddenException($this->t('Permission denied.')); } } @@ -84,8 +100,8 @@ class BaseApi extends BaseModule { self::checkAllowedScope(self::SCOPE_WRITE); - if (!DI::app()->isLoggedIn()) { - throw new HTTPException\ForbiddenException(DI::l10n()->t('Permission denied.')); + if (!$this->app->isLoggedIn()) { + throw new HTTPException\ForbiddenException($this->t('Permission denied.')); } } diff --git a/src/Module/BaseNotifications.php b/src/Module/BaseNotifications.php index 0e39eb651..bd19fb477 100644 --- a/src/Module/BaseNotifications.php +++ b/src/Module/BaseNotifications.php @@ -22,6 +22,7 @@ namespace Friendica\Module; use Exception; +use Friendica\App; use Friendica\App\Arguments; use Friendica\BaseModule; use Friendica\Content\Pager; @@ -30,6 +31,8 @@ use Friendica\Core\Renderer; use Friendica\Core\System; use Friendica\Navigation\Notifications\ValueObject\FormattedNotification; use Friendica\Network\HTTPException\ForbiddenException; +use Friendica\Util\Profiler; +use Psr\Log\LoggerInterface; /** * Base Module for each tab of the notification display @@ -86,9 +89,9 @@ abstract class BaseNotifications extends BaseModule */ abstract public function getNotifications(); - public function __construct(Arguments $args, L10n $l10n, array $parameters = []) + public function __construct(L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, array $server, array $parameters = []) { - parent::__construct($l10n, $parameters); + parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters); if (!local_user()) { throw new ForbiddenException($this->t('Permission denied.')); @@ -98,11 +101,9 @@ abstract class BaseNotifications extends BaseModule $this->firstItemNum = ($page * self::ITEMS_PER_PAGE) - self::ITEMS_PER_PAGE; $this->showAll = ($_REQUEST['show'] ?? '') === 'all'; - - $this->args = $args; } - public function rawContent() + protected function rawContent(array $request = []) { // If the last argument of the query is NOT json, return if ($this->args->get($this->args->getArgc() - 1) !== 'json') { diff --git a/src/Module/BaseSettings.php b/src/Module/BaseSettings.php index 7afaa35d0..ff8d2c3af 100644 --- a/src/Module/BaseSettings.php +++ b/src/Module/BaseSettings.php @@ -28,10 +28,8 @@ use Friendica\DI; class BaseSettings extends BaseModule { - public function content(): string + public static function createAside() { - $a = DI::app(); - $tpl = Renderer::getMarkupTemplate('settings/head.tpl'); DI::page()['htmlhead'] .= Renderer::replaceMacros($tpl, [ '$ispublic' => DI::l10n()->t('everybody') @@ -125,6 +123,13 @@ class BaseSettings extends BaseModule '$class' => 'settings-widget', '$items' => $tabs, ]); + } + + protected function content(array $request = []): string + { + $a = DI::app(); + + static::createAside(); return ''; } diff --git a/src/Module/Bookmarklet.php b/src/Module/Bookmarklet.php index 5061254aa..b5306cca0 100644 --- a/src/Module/Bookmarklet.php +++ b/src/Module/Bookmarklet.php @@ -34,7 +34,7 @@ use Friendica\Util\Strings; */ class Bookmarklet extends BaseModule { - public function content(): string + protected function content(array $request = []): string { $_GET['mode'] = 'minimal'; diff --git a/src/Module/Contact.php b/src/Module/Contact.php index 2db4af5e9..8d5e26a26 100644 --- a/src/Module/Contact.php +++ b/src/Module/Contact.php @@ -91,7 +91,7 @@ class Contact extends BaseModule DI::baseUrl()->redirect($redirectUrl); } - public function post() + protected function post(array $request = [], array $post = []) { if (!local_user()) { return; diff --git a/src/Module/Contact/Advanced.php b/src/Module/Contact/Advanced.php index 8d0a4e0f3..2d99abf72 100644 --- a/src/Module/Contact/Advanced.php +++ b/src/Module/Contact/Advanced.php @@ -21,6 +21,7 @@ namespace Friendica\Module\Contact; +use Friendica\App; use Friendica\App\Page; use Friendica\BaseModule; use Friendica\Content\Widget; @@ -31,8 +32,10 @@ use Friendica\Core\Session; use Friendica\Database\Database; use Friendica\Model; use Friendica\Module\Contact; +use Friendica\Module\Response; use Friendica\Network\HTTPException\BadRequestException; use Friendica\Network\HTTPException\ForbiddenException; +use Friendica\Util\Profiler; use Friendica\Util\Strings; use Psr\Log\LoggerInterface; @@ -43,25 +46,22 @@ class Advanced extends BaseModule { /** @var Database */ protected $dba; - /** @var LoggerInterface */ - protected $logger; /** @var Page */ protected $page; - public function __construct(Database $dba, LoggerInterface $logger, Page $page, L10n $l10n, array $parameters = []) + public function __construct(L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, App\Page $page, LoggerInterface $logger, Profiler $profiler, Response $response, Database $dba, array $server, array $parameters = []) { - parent::__construct($l10n, $parameters); + parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters); - $this->dba = $dba; - $this->logger = $logger; - $this->page = $page; + $this->dba = $dba; + $this->page = $page; if (!Session::isAuthenticated()) { throw new ForbiddenException($this->t('Permission denied.')); } } - public function post() + protected function post(array $request = [], array $post = []) { $cid = $this->parameters['id']; @@ -110,7 +110,7 @@ class Advanced extends BaseModule } } - public function content(): string + protected function content(array $request = []): string { $cid = $this->parameters['id']; diff --git a/src/Module/Contact/Contacts.php b/src/Module/Contact/Contacts.php index bfe689c1e..4d7493538 100644 --- a/src/Module/Contact/Contacts.php +++ b/src/Module/Contact/Contacts.php @@ -14,7 +14,7 @@ use Friendica\Network\HTTPException; class Contacts extends BaseModule { - public function content(): string + protected function content(array $request = []): string { $app = DI::app(); diff --git a/src/Module/Contact/Conversations.php b/src/Module/Contact/Conversations.php index 2c1cf91d6..5dd21bd12 100644 --- a/src/Module/Contact/Conversations.php +++ b/src/Module/Contact/Conversations.php @@ -32,8 +32,11 @@ use Friendica\Core\Protocol; use Friendica\Core\Theme; use Friendica\Model; use Friendica\Module\Contact; +use Friendica\Module\Response; use Friendica\Module\Security\Login; use Friendica\Network\HTTPException\NotFoundException; +use Friendica\Util\Profiler; +use Psr\Log\LoggerInterface; /** * Manages and show Contacts and their content @@ -48,26 +51,21 @@ class Conversations extends BaseModule * @var Conversation */ private $conversation; - /** - * @var App\BaseURL - */ - private $baseUrl; /** * @var LocalRelationship */ private $localRelationship; - public function __construct(L10n $l10n, LocalRelationship $localRelationship, App\BaseURL $baseUrl, App\Page $page, Conversation $conversation, array $parameters = []) + public function __construct(L10n $l10n, LocalRelationship $localRelationship, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, App\Page $page, Conversation $conversation, array $server, array $parameters = []) { - parent::__construct($l10n, $parameters); + parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters); $this->page = $page; $this->conversation = $conversation; - $this->baseUrl = $baseUrl; $this->localRelationship = $localRelationship; } - public function content(): string + protected function content(array $request = []): string { if (!local_user()) { return Login::form($_SERVER['REQUEST_URI']); diff --git a/src/Module/Contact/Hovercard.php b/src/Module/Contact/Hovercard.php index 34560313d..adc503fa5 100644 --- a/src/Module/Contact/Hovercard.php +++ b/src/Module/Contact/Hovercard.php @@ -35,7 +35,7 @@ use Friendica\Util\Strings; */ class Hovercard extends BaseModule { - public function rawContent() + protected function rawContent(array $request = []) { $contact_url = $_REQUEST['url'] ?? ''; diff --git a/src/Module/Contact/Media.php b/src/Module/Contact/Media.php index a3a498b6d..f2ff694e4 100644 --- a/src/Module/Contact/Media.php +++ b/src/Module/Contact/Media.php @@ -34,7 +34,7 @@ use Friendica\Network\HTTPException\BadRequestException; */ class Media extends BaseModule { - public function content(): string + protected function content(array $request = []): string { $cid = $this->parameters['id']; diff --git a/src/Module/Contact/Poke.php b/src/Module/Contact/Poke.php index 23ec95a43..718095c50 100644 --- a/src/Module/Contact/Poke.php +++ b/src/Module/Contact/Poke.php @@ -18,7 +18,7 @@ use Friendica\Util\XML; class Poke extends BaseModule { - public function post() + protected function post(array $request = [], array $post = []) { if (!local_user() || empty($this->parameters['id'])) { return self::postReturn(false); @@ -123,7 +123,7 @@ class Poke extends BaseModule return $success; } - public function content(): string + protected function content(array $request = []): string { if (!local_user()) { throw new HTTPException\UnauthorizedException(DI::l10n()->t('You must be logged in to use this module.')); diff --git a/src/Module/Contact/Posts.php b/src/Module/Contact/Posts.php index 3409d9169..8823b7b40 100644 --- a/src/Module/Contact/Posts.php +++ b/src/Module/Contact/Posts.php @@ -31,8 +31,11 @@ use Friendica\Core\Protocol; use Friendica\Database\DBA; use Friendica\Model; use Friendica\Module\Contact; +use Friendica\Module\Response; use Friendica\Module\Security\Login; use Friendica\Network\HTTPException\NotFoundException; +use Friendica\Util\Profiler; +use Psr\Log\LoggerInterface; /** * Show a contact posts and comments @@ -43,25 +46,20 @@ class Posts extends BaseModule * @var LocalRelationship */ private $localRelationship; - /** - * @var App\BaseURL - */ - private $baseUrl; /** * @var App\Page */ private $page; - public function __construct(L10n $l10n, LocalRelationship $localRelationship, App\BaseURL $baseUrl, App\Page $page, array $parameters = []) + public function __construct(L10n $l10n, LocalRelationship $localRelationship, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, App\Page $page, array $server, array $parameters = []) { - parent::__construct($l10n, $parameters); + parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters); $this->localRelationship = $localRelationship; - $this->baseUrl = $baseUrl; $this->page = $page; } - public function content(): string + protected function content(array $request = []): string { if (!local_user()) { return Login::form($_SERVER['REQUEST_URI']); diff --git a/src/Module/Contact/Profile.php b/src/Module/Contact/Profile.php index 1af171872..e58c329f2 100644 --- a/src/Module/Contact/Profile.php +++ b/src/Module/Contact/Profile.php @@ -38,8 +38,11 @@ use Friendica\Database\DBA; use Friendica\Model\Contact; use Friendica\Model\Group; use Friendica\Module; +use Friendica\Module\Response; use Friendica\Network\HTTPException; use Friendica\Util\DateTimeFormat; +use Friendica\Util\Profiler; +use Psr\Log\LoggerInterface; /** * Show a contact profile @@ -50,35 +53,25 @@ class Profile extends BaseModule * @var Repository\LocalRelationship */ private $localRelationship; - /** - * @var App\BaseURL - */ - private $baseUrl; /** * @var App\Page */ private $page; - /** - * @var App\Arguments - */ - private $args; /** * @var IManageConfigValues */ private $config; - public function __construct(L10n $l10n, Repository\LocalRelationship $localRelationship, App\BaseURL $baseUrl, App\Page $page, App\Arguments $args, IManageConfigValues $config, array $parameters = []) + public function __construct(L10n $l10n, Repository\LocalRelationship $localRelationship, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, App\Page $page, IManageConfigValues $config, array $server, array $parameters = []) { - parent::__construct($l10n, $parameters); + parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters); $this->localRelationship = $localRelationship; - $this->baseUrl = $baseUrl; $this->page = $page; - $this->args = $args; $this->config = $config; } - public function post() + protected function post(array $request = [], array $post = []) { if (!local_user()) { return; @@ -101,8 +94,8 @@ class Profile extends BaseModule $fields['hidden'] = !empty($_POST['hidden']); } - if (isset($_POST['notify'])) { - $fields['notify'] = !empty($_POST['notify']); + if (isset($_POST['notify_new_posts'])) { + $fields['notify_new_posts'] = !empty($_POST['notify_new_posts']); } if (isset($_POST['fetch_further_information'])) { @@ -135,7 +128,7 @@ class Profile extends BaseModule } } - public function content(): string + protected function content(array $request = []): string { if (!local_user()) { return Module\Security\Login::form($_SERVER['REQUEST_URI']); @@ -362,7 +355,7 @@ class Profile extends BaseModule '$archived' => ($contact['archive'] ? $this->t('Currently archived') : ''), '$pending' => ($contact['pending'] ? $this->t('Awaiting connection acknowledge') : ''), '$hidden' => ['hidden', $this->t('Hide this contact from others'), $localRelationship->hidden, $this->t('Replies/likes to your public posts may still be visible')], - '$notify' => ['notify', $this->t('Notification for new posts'), ($contact['notify_new_posts'] == 1), $this->t('Send a notification of every new post of this contact')], + '$notify_new_posts' => ['notify_new_posts', $this->t('Notification for new posts'), ($localRelationship->notifyNewPosts), $this->t('Send a notification of every new post of this contact')], '$fetch_further_information' => $fetch_further_information, '$ffi_keyword_denylist' => ['ffi_keyword_denylist', $this->t('Keyword Deny List'), $localRelationship->ffiKeywordDenylist, $this->t('Comma separated list of keywords that should not be converted to hashtags, when "Fetch information and keywords" is selected')], '$photo' => Contact::getPhoto($contact), diff --git a/src/Module/Contact/Revoke.php b/src/Module/Contact/Revoke.php index 88177cc3b..4c3a6dade 100644 --- a/src/Module/Contact/Revoke.php +++ b/src/Module/Contact/Revoke.php @@ -21,8 +21,7 @@ namespace Friendica\Module\Contact; -use Friendica\App\Arguments; -use Friendica\App\BaseURL; +use Friendica\App; use Friendica\BaseModule; use Friendica\Content\Nav; use Friendica\Core\L10n; @@ -31,8 +30,11 @@ use Friendica\Core\Renderer; use Friendica\Database\Database; use Friendica\Model; use Friendica\Module\Contact; +use Friendica\Module\Response; use Friendica\Module\Security\Login; use Friendica\Network\HTTPException; +use Friendica\Util\Profiler; +use Psr\Log\LoggerInterface; class Revoke extends BaseModule { @@ -41,18 +43,12 @@ class Revoke extends BaseModule /** @var Database */ protected $dba; - /** @var BaseURL */ - protected $baseUrl; - /** @var Arguments */ - protected $args; - - public function __construct(Database $dba, BaseURL $baseUrl, Arguments $args, L10n $l10n, array $parameters = []) + + public function __construct(L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Database $dba, Response $response, array $server, array $parameters = []) { - parent::__construct($l10n, $parameters); + parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters); $this->dba = $dba; - $this->baseUrl = $baseUrl; - $this->args = $args; if (!local_user()) { return; @@ -78,7 +74,7 @@ class Revoke extends BaseModule } } - public function post() + protected function post(array $request = [], array $post = []) { if (!local_user()) { throw new HTTPException\UnauthorizedException(); @@ -98,7 +94,7 @@ class Revoke extends BaseModule $this->baseUrl->redirect('contact/' . $this->parameters['id']); } - public function content(): string + protected function content(array $request = []): string { if (!local_user()) { return Login::form($_SERVER['REQUEST_URI']); diff --git a/src/Module/Conversation/Community.php b/src/Module/Conversation/Community.php index d954ef8f3..0edd12c30 100644 --- a/src/Module/Conversation/Community.php +++ b/src/Module/Conversation/Community.php @@ -49,7 +49,7 @@ class Community extends BaseModule protected static $max_id; protected static $item_id; - public function content(): string + protected function content(array $request = []): string { $this->parseRequest(); diff --git a/src/Module/Conversation/Network.php b/src/Module/Conversation/Network.php index 0f2d9cd6f..ac04cf2ae 100644 --- a/src/Module/Conversation/Network.php +++ b/src/Module/Conversation/Network.php @@ -57,7 +57,7 @@ class Network extends BaseModule /** @var string */ protected static $order; - public function content(): string + protected function content(array $request = []): string { if (!local_user()) { return Login::form(); diff --git a/src/Module/Credits.php b/src/Module/Credits.php index fdd4f6974..cdd16c7b4 100644 --- a/src/Module/Credits.php +++ b/src/Module/Credits.php @@ -32,7 +32,7 @@ use Friendica\DI; */ class Credits extends BaseModule { - public function content(): string + protected function content(array $request = []): string { /* fill the page with credits */ $credits_string = file_get_contents('CREDITS.txt'); diff --git a/src/Module/DFRN/Notify.php b/src/Module/DFRN/Notify.php index eda5da936..de03992da 100644 --- a/src/Module/DFRN/Notify.php +++ b/src/Module/DFRN/Notify.php @@ -38,7 +38,7 @@ use Friendica\Network\HTTPException; */ class Notify extends BaseModule { - public function post() + protected function post(array $request = [], array $post = []) { $postdata = Network::postdata(); diff --git a/src/Module/DFRN/Poll.php b/src/Module/DFRN/Poll.php index 0cf43f2a7..7cb9c2921 100644 --- a/src/Module/DFRN/Poll.php +++ b/src/Module/DFRN/Poll.php @@ -29,7 +29,7 @@ use Friendica\Protocol\OStatus; */ class Poll extends BaseModule { - public function rawContent() + protected function rawContent(array $request = []) { header("Content-type: application/atom+xml"); $last_update = $_GET['last_update'] ?? ''; diff --git a/src/Module/Debug/ActivityPubConversion.php b/src/Module/Debug/ActivityPubConversion.php index 7f5fa6274..c9c2526a9 100644 --- a/src/Module/Debug/ActivityPubConversion.php +++ b/src/Module/Debug/ActivityPubConversion.php @@ -34,7 +34,7 @@ use Friendica\Util\XML; class ActivityPubConversion extends BaseModule { - public function content(): string + protected function content(array $request = []): string { function visible_whitespace($s) { diff --git a/src/Module/Debug/Babel.php b/src/Module/Debug/Babel.php index c50bd08d7..d449bd07c 100644 --- a/src/Module/Debug/Babel.php +++ b/src/Module/Debug/Babel.php @@ -35,7 +35,7 @@ use Friendica\Util\XML; */ class Babel extends BaseModule { - public function content(): string + protected function content(array $request = []): string { function visible_whitespace($s) { diff --git a/src/Module/Debug/Feed.php b/src/Module/Debug/Feed.php index 9368dd026..5d6d03658 100644 --- a/src/Module/Debug/Feed.php +++ b/src/Module/Debug/Feed.php @@ -21,13 +21,16 @@ namespace Friendica\Module\Debug; -use Friendica\App\BaseURL; +use Friendica\App; use Friendica\BaseModule; use Friendica\Core\L10n; use Friendica\Core\Renderer; use Friendica\Model; +use Friendica\Module\Response; use Friendica\Network\HTTPClient\Capability\ICanSendHttpRequests; use Friendica\Protocol; +use Friendica\Util\Profiler; +use Psr\Log\LoggerInterface; /** * Tests a given feed of a contact @@ -37,9 +40,9 @@ class Feed extends BaseModule /** @var ICanSendHttpRequests */ protected $httpClient; - public function __construct(BaseURL $baseUrl, ICanSendHttpRequests $httpClient, L10n $l10n, array $parameters = []) + public function __construct(L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, ICanSendHttpRequests $httpClient, array $server, array $parameters = []) { - parent::__construct($l10n, $parameters); + parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters); $this->httpClient = $httpClient; @@ -49,7 +52,7 @@ class Feed extends BaseModule } } - public function content(): string + protected function content(array $request = []): string { $result = []; if (!empty($_REQUEST['url'])) { diff --git a/src/Module/Debug/ItemBody.php b/src/Module/Debug/ItemBody.php index 375993114..1477b629d 100644 --- a/src/Module/Debug/ItemBody.php +++ b/src/Module/Debug/ItemBody.php @@ -31,7 +31,7 @@ use Friendica\Network\HTTPException; */ class ItemBody extends BaseModule { - public function content(): string + protected function content(array $request = []): string { if (!local_user()) { throw new HTTPException\UnauthorizedException(DI::l10n()->t('Access denied.')); diff --git a/src/Module/Debug/Localtime.php b/src/Module/Debug/Localtime.php index 6fb91380a..97a645485 100644 --- a/src/Module/Debug/Localtime.php +++ b/src/Module/Debug/Localtime.php @@ -31,7 +31,7 @@ class Localtime extends BaseModule { static $mod_localtime = ''; - public function post() + protected function post(array $request = [], array $post = []) { $time = ($_REQUEST['time'] ?? '') ?: 'now'; @@ -42,7 +42,7 @@ class Localtime extends BaseModule } } - public function content(): string + protected function content(array $request = []): string { $time = ($_REQUEST['time'] ?? '') ?: 'now'; diff --git a/src/Module/Debug/Probe.php b/src/Module/Debug/Probe.php index fcb7dda21..07f82eaac 100644 --- a/src/Module/Debug/Probe.php +++ b/src/Module/Debug/Probe.php @@ -32,7 +32,7 @@ use Friendica\Network\Probe as NetworkProbe; */ class Probe extends BaseModule { - public function content(): string + protected function content(array $request = []): string { if (!local_user()) { throw new HTTPException\ForbiddenException(DI::l10n()->t('Only logged in users are permitted to perform a probing.')); diff --git a/src/Module/Debug/WebFinger.php b/src/Module/Debug/WebFinger.php index 4527d2fb2..1f576e7f9 100644 --- a/src/Module/Debug/WebFinger.php +++ b/src/Module/Debug/WebFinger.php @@ -31,7 +31,7 @@ use Friendica\Network\Probe; */ class WebFinger extends BaseModule { - public function content(): string + protected function content(array $request = []): string { if (!local_user()) { throw new \Friendica\Network\HTTPException\ForbiddenException(DI::l10n()->t('Only logged in users are permitted to perform a probing.')); diff --git a/src/Module/Delegation.php b/src/Module/Delegation.php index 2b36fc2a3..b242f5faa 100644 --- a/src/Module/Delegation.php +++ b/src/Module/Delegation.php @@ -37,7 +37,7 @@ use Friendica\Util\Proxy; */ class Delegation extends BaseModule { - public function post() + protected function post(array $request = [], array $post = []) { if (!local_user()) { return; @@ -112,7 +112,7 @@ class Delegation extends BaseModule // NOTREACHED } - public function content(): string + protected function content(array $request = []): string { if (!local_user()) { throw new ForbiddenException(DI::l10n()->t('Permission denied.')); diff --git a/src/Module/Diaspora/Fetch.php b/src/Module/Diaspora/Fetch.php index e3d6f4616..7a32dac6d 100644 --- a/src/Module/Diaspora/Fetch.php +++ b/src/Module/Diaspora/Fetch.php @@ -38,7 +38,7 @@ use Friendica\Util\Strings; */ class Fetch extends BaseModule { - public function rawContent() + protected function rawContent(array $request = []) { if (empty($this->parameters['guid'])) { throw new HTTPException\NotFoundException(); diff --git a/src/Module/Diaspora/Receive.php b/src/Module/Diaspora/Receive.php index ed4f8a5d2..242b774b3 100644 --- a/src/Module/Diaspora/Receive.php +++ b/src/Module/Diaspora/Receive.php @@ -21,13 +21,16 @@ namespace Friendica\Module\Diaspora; +use Friendica\App; use Friendica\BaseModule; use Friendica\Core\Config\Capability\IManageConfigValues; use Friendica\Core\L10n; use Friendica\Model\User; +use Friendica\Module\Response; use Friendica\Network\HTTPException; use Friendica\Protocol\Diaspora; use Friendica\Util\Network; +use Friendica\Util\Profiler; use Psr\Log\LoggerInterface; /** @@ -36,20 +39,17 @@ use Psr\Log\LoggerInterface; */ class Receive extends BaseModule { - /** @var LoggerInterface */ - protected $logger; /** @var IManageConfigValues */ protected $config; - public function __construct(LoggerInterface $logger, IManageConfigValues $config, L10n $l10n, array $parameters = []) + public function __construct(L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, IManageConfigValues $config, array $server, array $parameters = []) { - parent::__construct($l10n, $parameters); - - $this->logger = $logger; + parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters); + $this->config = $config; } - public function post() + protected function post(array $request = [], array $post = []) { $enabled = $this->config->get('system', 'diaspora_enabled', false); if (!$enabled) { diff --git a/src/Module/Directory.php b/src/Module/Directory.php index a81780a28..e43d27261 100644 --- a/src/Module/Directory.php +++ b/src/Module/Directory.php @@ -38,7 +38,7 @@ use Friendica\Network\HTTPException; */ class Directory extends BaseModule { - public function content(): string + protected function content(array $request = []): string { $app = DI::app(); $config = DI::config(); diff --git a/src/Module/Events/Json.php b/src/Module/Events/Json.php index 566cf648a..859b0621e 100644 --- a/src/Module/Events/Json.php +++ b/src/Module/Events/Json.php @@ -13,7 +13,7 @@ use Friendica\Util\Temporal; class Json extends \Friendica\BaseModule { - public function rawContent() + protected function rawContent(array $request = []) { if (!local_user()) { throw new HTTPException\UnauthorizedException(); diff --git a/src/Module/Feed.php b/src/Module/Feed.php index 6470ab5c3..f4a671c05 100644 --- a/src/Module/Feed.php +++ b/src/Module/Feed.php @@ -41,7 +41,7 @@ use Friendica\Protocol\Feed as ProtocolFeed; */ class Feed extends BaseModule { - public function content(): string + protected function content(array $request = []): string { $a = DI::app(); diff --git a/src/Module/Filer/RemoveTag.php b/src/Module/Filer/RemoveTag.php index e6749de02..68d265c5f 100644 --- a/src/Module/Filer/RemoveTag.php +++ b/src/Module/Filer/RemoveTag.php @@ -33,7 +33,7 @@ use Friendica\Util\XML; */ class RemoveTag extends BaseModule { - public function content(): string + protected function content(array $request = []): string { if (!local_user()) { throw new HTTPException\ForbiddenException(); diff --git a/src/Module/Filer/SaveTag.php b/src/Module/Filer/SaveTag.php index fd572a7be..3adf4f1fb 100644 --- a/src/Module/Filer/SaveTag.php +++ b/src/Module/Filer/SaveTag.php @@ -21,13 +21,15 @@ namespace Friendica\Module\Filer; -use Friendica\App\BaseURL; +use Friendica\App; use Friendica\BaseModule; use Friendica\Core\L10n; use Friendica\Core\Renderer; use Friendica\Database\DBA; use Friendica\Model; +use Friendica\Module\Response; use Friendica\Network\HTTPException; +use Friendica\Util\Profiler; use Friendica\Util\XML; use Psr\Log\LoggerInterface; @@ -36,22 +38,17 @@ use Psr\Log\LoggerInterface; */ class SaveTag extends BaseModule { - /** @var LoggerInterface */ - protected $logger; - - public function __construct(LoggerInterface $logger, BaseURL $baseUrl, L10n $l10n, array $parameters = []) + public function __construct(L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, array $server, array $parameters = []) { - parent::__construct($l10n, $parameters); - - $this->logger = $logger; - + parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters); + if (!local_user()) { notice($this->t('You must be logged in to use this module')); $baseUrl->redirect(); } } - public function rawContent() + protected function rawContent(array $request = []) { $term = XML::unescape(trim($_GET['term'] ?? '')); diff --git a/src/Module/FollowConfirm.php b/src/Module/FollowConfirm.php index 41f811698..388c07a37 100644 --- a/src/Module/FollowConfirm.php +++ b/src/Module/FollowConfirm.php @@ -10,8 +10,9 @@ use Friendica\Model\Contact; */ class FollowConfirm extends BaseModule { - public function post() + protected function post(array $request = [], array $post = []) { + parent::post($post); $uid = local_user(); if (!$uid) { notice(DI::l10n()->t('Permission denied.')); diff --git a/src/Module/FriendSuggest.php b/src/Module/FriendSuggest.php index 940e6ff9c..153f86d60 100644 --- a/src/Module/FriendSuggest.php +++ b/src/Module/FriendSuggest.php @@ -21,7 +21,7 @@ namespace Friendica\Module; -use Friendica\App\BaseURL; +use Friendica\App; use Friendica\BaseModule; use Friendica\Core\L10n; use Friendica\Core\Protocol; @@ -31,16 +31,16 @@ use Friendica\Database\Database; use Friendica\Model\Contact as ContactModel; use Friendica\Network\HTTPException\ForbiddenException; use Friendica\Network\HTTPException\NotFoundException; +use Friendica\Util\Profiler; use Friendica\Util\Strings; use Friendica\Worker\Delivery; +use Psr\Log\LoggerInterface; /** * Suggest friends to a known contact */ class FriendSuggest extends BaseModule { - /** @var BaseURL */ - protected $baseUrl; /** @var Database */ protected $dba; /** @var \Friendica\Contact\FriendSuggest\Repository\FriendSuggest */ @@ -48,21 +48,20 @@ class FriendSuggest extends BaseModule /** @var \Friendica\Contact\FriendSuggest\Factory\FriendSuggest */ protected $friendSuggestFac; - public function __construct(BaseURL $baseUrl, Database $dba, \Friendica\Contact\FriendSuggest\Repository\FriendSuggest $friendSuggestRepo, \Friendica\Contact\FriendSuggest\Factory\FriendSuggest $friendSuggestFac, L10n $l10n, array $parameters = []) + public function __construct(L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, Database $dba, \Friendica\Contact\FriendSuggest\Repository\FriendSuggest $friendSuggestRepo, \Friendica\Contact\FriendSuggest\Factory\FriendSuggest $friendSuggestFac, array $server, array $parameters = []) { - parent::__construct($l10n, $parameters); + parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters); if (!local_user()) { throw new ForbiddenException($this->t('Permission denied.')); } - $this->baseUrl = $baseUrl; $this->dba = $dba; $this->friendSuggestRepo = $friendSuggestRepo; $this->friendSuggestFac = $friendSuggestFac; } - public function post() + protected function post(array $request = [], array $post = []) { $cid = intval($this->parameters['contact']); @@ -100,7 +99,7 @@ class FriendSuggest extends BaseModule info($this->t('Friend suggestion sent.')); } - public function content(): string + protected function content(array $request = []): string { $cid = intval($this->parameters['contact']); diff --git a/src/Module/Friendica.php b/src/Module/Friendica.php index b4de151e9..74d9309bd 100644 --- a/src/Module/Friendica.php +++ b/src/Module/Friendica.php @@ -38,7 +38,7 @@ use Friendica\Protocol\ActivityPub; */ class Friendica extends BaseModule { - public function content(): string + protected function content(array $request = []): string { $config = DI::config(); @@ -110,7 +110,7 @@ class Friendica extends BaseModule ]); } - public function rawContent() + protected function rawContent(array $request = []) { if (ActivityPub::isRequest()) { try { diff --git a/src/Module/Group.php b/src/Module/Group.php index 39eb896d4..883f09cb5 100644 --- a/src/Module/Group.php +++ b/src/Module/Group.php @@ -32,7 +32,7 @@ require_once 'boot.php'; class Group extends BaseModule { - public function post() + protected function post(array $request = [], array $post = []) { if (DI::mode()->isAjax()) { $this->ajaxPost(); @@ -140,7 +140,7 @@ class Group extends BaseModule } } - public function content(): string + protected function content(array $request = []): string { $change = false; diff --git a/src/Module/HCard.php b/src/Module/HCard.php index 110371ee9..12ea65f13 100644 --- a/src/Module/HCard.php +++ b/src/Module/HCard.php @@ -34,7 +34,7 @@ use Friendica\Network\HTTPException; */ class HCard extends BaseModule { - public function content(): string + protected function content(array $request = []): string { if ((local_user()) && ($this->parameters['action'] ?? '') === 'view') { // A logged in user views a profile of a user diff --git a/src/Module/HTTPException/MethodNotAllowed.php b/src/Module/HTTPException/MethodNotAllowed.php index 07aab537a..bfe0e18f8 100644 --- a/src/Module/HTTPException/MethodNotAllowed.php +++ b/src/Module/HTTPException/MethodNotAllowed.php @@ -27,7 +27,7 @@ use Friendica\Network\HTTPException; class MethodNotAllowed extends BaseModule { - public function content(): string + protected function content(array $request = []): string { throw new HTTPException\MethodNotAllowedException(DI::l10n()->t('Method Not Allowed.')); } diff --git a/src/Module/HTTPException/PageNotFound.php b/src/Module/HTTPException/PageNotFound.php index 6af5e91ae..ae156f05c 100644 --- a/src/Module/HTTPException/PageNotFound.php +++ b/src/Module/HTTPException/PageNotFound.php @@ -24,11 +24,43 @@ namespace Friendica\Module\HTTPException; use Friendica\BaseModule; use Friendica\DI; use Friendica\Network\HTTPException; +use Psr\Http\Message\ResponseInterface; class PageNotFound extends BaseModule { - public function content(): string + protected function content(array $request = []): string { throw new HTTPException\NotFoundException(DI::l10n()->t('Page not found.')); } + + public function run(array $post = [], array $request = []): ResponseInterface + { + /* The URL provided does not resolve to a valid module. + * + * On Dreamhost sites, quite often things go wrong for no apparent reason and they send us to '/internal_error.html'. + * We don't like doing this, but as it occasionally accounts for 10-20% or more of all site traffic - + * we are going to trap this and redirect back to the requested page. As long as you don't have a critical error on your page + * this will often succeed and eventually do the right thing. + * + * Otherwise we are going to emit a 404 not found. + */ + $queryString = $this->server['QUERY_STRING']; + // Stupid browser tried to pre-fetch our Javascript img template. Don't log the event or return anything - just quietly exit. + if (!empty($queryString) && preg_match('/{[0-9]}/', $queryString) !== 0) { + exit(); + } + + if (!empty($queryString) && ($queryString === 'q=internal_error.html') && isset($dreamhost_error_hack)) { + $this->logger->info('index.php: dreamhost_error_hack invoked.', ['Original URI' => $this->server['REQUEST_URI']]); + $this->baseUrl->redirect($this->server['REQUEST_URI']); + } + + $this->logger->debug('index.php: page not found.', [ + 'request_uri' => $this->server['REQUEST_URI'], + 'address' => $this->server['REMOTE_ADDR'], + 'query' => $this->server['QUERY_STRING'] + ]); + + return parent::run($post, $request); // TODO: Change the autogenerated stub + } } diff --git a/src/Module/Hashtag.php b/src/Module/Hashtag.php index 8910d9cce..1ac73de53 100644 --- a/src/Module/Hashtag.php +++ b/src/Module/Hashtag.php @@ -31,7 +31,7 @@ use Friendica\Util\Strings; */ class Hashtag extends BaseModule { - public function content(): string + protected function content(array $request = []): string { $result = []; diff --git a/src/Module/Help.php b/src/Module/Help.php index d0b61c221..f4083c310 100644 --- a/src/Module/Help.php +++ b/src/Module/Help.php @@ -32,7 +32,7 @@ use Friendica\Network\HTTPException; */ class Help extends BaseModule { - public function content(): string + protected function content(array $request = []): string { Nav::setSelected('help'); diff --git a/src/Module/Home.php b/src/Module/Home.php index f4e6b9733..ca0ce0b72 100644 --- a/src/Module/Home.php +++ b/src/Module/Home.php @@ -32,7 +32,7 @@ use Friendica\Module\Security\Login; */ class Home extends BaseModule { - public function content(): string + protected function content(array $request = []): string { $app = DI::app(); $config = DI::config(); diff --git a/src/Module/Install.php b/src/Module/Install.php index 4385ba851..2b287d96b 100644 --- a/src/Module/Install.php +++ b/src/Module/Install.php @@ -31,7 +31,9 @@ use Friendica\Core\Theme; use Friendica\DI; use Friendica\Network\HTTPException; use Friendica\Util\BasePath; +use Friendica\Util\Profiler; use Friendica\Util\Temporal; +use Psr\Log\LoggerInterface; class Install extends BaseModule { @@ -70,16 +72,13 @@ class Install extends BaseModule protected $app; /** @var App\Mode */ protected $mode; - /** @var App\BaseURL */ - protected $baseUrl; - public function __construct(App $app, App\Mode $mode, App\BaseURL $baseUrl, App\Arguments $args, Core\Installer $installer, L10n $l10n, array $parameters = []) + public function __construct(App $app, App\Mode $mode, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, Core\Installer $installer, array $server, array $parameters = []) { - parent::__construct($l10n, $parameters); + parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters); $this->app = $app; $this->mode = $mode; - $this->baseUrl = $baseUrl; $this->installer = $installer; if (!$this->mode->isInstall()) { @@ -105,7 +104,7 @@ class Install extends BaseModule $this->currentWizardStep = ($_POST['pass'] ?? '') ?: self::SYSTEM_CHECK; } - public function post() + protected function post(array $request = [], array $post = []) { $configCache = $this->app->getConfigCache(); @@ -187,7 +186,7 @@ class Install extends BaseModule } } - public function content(): string + protected function content(array $request = []): string { $configCache = $this->app->getConfigCache(); diff --git a/src/Module/Invite.php b/src/Module/Invite.php index 10346a516..8c9c59d30 100644 --- a/src/Module/Invite.php +++ b/src/Module/Invite.php @@ -35,7 +35,7 @@ use Friendica\Util\Strings; */ class Invite extends BaseModule { - public function post() + protected function post(array $request = [], array $post = []) { if (!local_user()) { throw new HTTPException\ForbiddenException(DI::l10n()->t('Permission denied.')); @@ -124,7 +124,7 @@ class Invite extends BaseModule info(DI::l10n()->tt('%d message sent.', '%d messages sent.', $total)); } - public function content(): string + protected function content(array $request = []): string { if (!local_user()) { throw new HTTPException\ForbiddenException(DI::l10n()->t('Permission denied.')); diff --git a/src/Module/Item/Activity.php b/src/Module/Item/Activity.php index 3936aa2bc..f82d1b430 100644 --- a/src/Module/Item/Activity.php +++ b/src/Module/Item/Activity.php @@ -38,7 +38,7 @@ use Friendica\Network\HTTPException; */ class Activity extends BaseModule { - public function rawContent() + protected function rawContent(array $request = []) { if (!Session::isAuthenticated()) { throw new HTTPException\ForbiddenException(); diff --git a/src/Module/Item/Compose.php b/src/Module/Item/Compose.php index 6521ddc91..0564e2f98 100644 --- a/src/Module/Item/Compose.php +++ b/src/Module/Item/Compose.php @@ -40,7 +40,7 @@ use Friendica\Util\Temporal; class Compose extends BaseModule { - public function post() + protected function post(array $request = [], array $post = []) { if (!empty($_REQUEST['body'])) { $_REQUEST['return'] = 'network'; @@ -51,7 +51,7 @@ class Compose extends BaseModule } } - public function content(): string + protected function content(array $request = []): string { if (!local_user()) { return Login::form('compose', false); diff --git a/src/Module/Item/Follow.php b/src/Module/Item/Follow.php index f89353170..b12a0ac24 100644 --- a/src/Module/Item/Follow.php +++ b/src/Module/Item/Follow.php @@ -34,7 +34,7 @@ use Friendica\Network\HTTPException; */ class Follow extends BaseModule { - public function rawContent() + protected function rawContent(array $request = []) { $l10n = DI::l10n(); diff --git a/src/Module/Item/Ignore.php b/src/Module/Item/Ignore.php index 33481fd2e..0987e75e9 100644 --- a/src/Module/Item/Ignore.php +++ b/src/Module/Item/Ignore.php @@ -33,7 +33,7 @@ use Friendica\Network\HTTPException; */ class Ignore extends BaseModule { - public function rawContent() + protected function rawContent(array $request = []) { $l10n = DI::l10n(); diff --git a/src/Module/Item/Pin.php b/src/Module/Item/Pin.php index 12ff94655..71aff6916 100644 --- a/src/Module/Item/Pin.php +++ b/src/Module/Item/Pin.php @@ -34,7 +34,7 @@ use Friendica\Network\HTTPException; */ class Pin extends BaseModule { - public function rawContent() + protected function rawContent(array $request = []) { $l10n = DI::l10n(); diff --git a/src/Module/Item/Star.php b/src/Module/Item/Star.php index b3e4ed2a1..1b581f715 100644 --- a/src/Module/Item/Star.php +++ b/src/Module/Item/Star.php @@ -35,7 +35,7 @@ use Friendica\Network\HTTPException; */ class Star extends BaseModule { - public function rawContent() + protected function rawContent(array $request = []) { $l10n = DI::l10n(); diff --git a/src/Module/Magic.php b/src/Module/Magic.php index c47a7a4d5..c861d3054 100644 --- a/src/Module/Magic.php +++ b/src/Module/Magic.php @@ -31,6 +31,7 @@ use Friendica\Model\User; use Friendica\Network\HTTPClient\Capability\ICanSendHttpRequests; use Friendica\Network\HTTPClient\Client\HttpClientOptions; use Friendica\Util\HTTPSignature; +use Friendica\Util\Profiler; use Friendica\Util\Strings; use Psr\Log\LoggerInterface; @@ -43,26 +44,21 @@ class Magic extends BaseModule { /** @var App */ protected $app; - /** @var LoggerInterface */ - protected $logger; /** @var Database */ protected $dba; /** @var ICanSendHttpRequests */ protected $httpClient; - protected $baseUrl; - public function __construct(App $app, App\BaseURL $baseUrl, LoggerInterface $logger, Database $dba, ICanSendHttpRequests $httpClient, L10n $l10n, array $parameters = []) + public function __construct(App $app, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, Database $dba, ICanSendHttpRequests $httpClient, array $server, array $parameters = []) { - parent::__construct($l10n, $parameters); + parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters); $this->app = $app; - $this->logger = $logger; $this->dba = $dba; $this->httpClient = $httpClient; - $this->baseUrl = $baseUrl; } - public function rawContent() + protected function rawContent(array $request = []) { $this->logger->info('magic module: invoked'); diff --git a/src/Module/Maintenance.php b/src/Module/Maintenance.php index 2025a5fa4..b695c53ab 100644 --- a/src/Module/Maintenance.php +++ b/src/Module/Maintenance.php @@ -34,7 +34,7 @@ use Friendica\Util\Strings; */ class Maintenance extends BaseModule { - public function content(): string + protected function content(array $request = []): string { $reason = DI::config()->get('system', 'maintenance_reason'); diff --git a/src/Module/Manifest.php b/src/Module/Manifest.php index ff462fd3e..e23b97686 100644 --- a/src/Module/Manifest.php +++ b/src/Module/Manifest.php @@ -27,7 +27,7 @@ use Friendica\DI; class Manifest extends BaseModule { - public function rawContent() + protected function rawContent(array $request = []) { $config = DI::config(); diff --git a/src/Module/NoScrape.php b/src/Module/NoScrape.php index 06bce3e24..131cec13c 100644 --- a/src/Module/NoScrape.php +++ b/src/Module/NoScrape.php @@ -35,7 +35,7 @@ use Friendica\Model\User; */ class NoScrape extends BaseModule { - public function rawContent() + protected function rawContent(array $request = []) { $a = DI::app(); diff --git a/src/Module/NodeInfo110.php b/src/Module/NodeInfo110.php index d8f8a5049..4e740ab3f 100644 --- a/src/Module/NodeInfo110.php +++ b/src/Module/NodeInfo110.php @@ -21,11 +21,15 @@ namespace Friendica\Module; +use Friendica\App; use Friendica\BaseModule; +use Friendica\Capabilities\ICanCreateResponses; use Friendica\Core\Addon; -use Friendica\Core\System; -use Friendica\DI; +use Friendica\Core\Config\Capability\IManageConfigValues; +use Friendica\Core\L10n; use Friendica\Model\Nodeinfo; +use Friendica\Util\Profiler; +use Psr\Log\LoggerInterface; /** * Version 1.0 of Nodeinfo, a standardized way of exposing metadata about a server running one of the distributed social networks. @@ -33,10 +37,18 @@ use Friendica\Model\Nodeinfo; */ class NodeInfo110 extends BaseModule { - public function rawContent() - { - $config = DI::config(); + /** @var IManageConfigValues */ + protected $config; + public function __construct(L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, IManageConfigValues $config, array $server, array $parameters = []) + { + parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters); + + $this->config = $config; + } + + protected function rawContent(array $request = []) + { $nodeinfo = [ 'version' => '1.0', 'software' => [ @@ -53,19 +65,19 @@ class NodeInfo110 extends BaseModule ], 'services' => [], 'usage' => [], - 'openRegistrations' => intval($config->get('config', 'register_policy')) !== Register::CLOSED, + 'openRegistrations' => intval($this->config->get('config', 'register_policy')) !== Register::CLOSED, 'metadata' => [ - 'nodeName' => $config->get('config', 'sitename'), + 'nodeName' => $this->config->get('config', 'sitename'), ], ]; - if (!empty($config->get('system', 'diaspora_enabled'))) { - $nodeinfo['protocols']['inbound'][] = 'diaspora'; + if (!empty($this->config->get('system', 'diaspora_enabled'))) { + $nodeinfo['protocols']['inbound'][] = 'diaspora'; $nodeinfo['protocols']['outbound'][] = 'diaspora'; } - if (empty($config->get('system', 'ostatus_disabled'))) { - $nodeinfo['protocols']['inbound'][] = 'gnusocial'; + if (empty($this->config->get('system', 'ostatus_disabled'))) { + $nodeinfo['protocols']['inbound'][] = 'gnusocial'; $nodeinfo['protocols']['outbound'][] = 'gnusocial'; } @@ -73,10 +85,10 @@ class NodeInfo110 extends BaseModule $nodeinfo['services'] = Nodeinfo::getServices(); - $nodeinfo['metadata']['protocols'] = $nodeinfo['protocols']; + $nodeinfo['metadata']['protocols'] = $nodeinfo['protocols']; $nodeinfo['metadata']['protocols']['outbound'][] = 'atom1.0'; - $nodeinfo['metadata']['protocols']['inbound'][] = 'atom1.0'; - $nodeinfo['metadata']['protocols']['inbound'][] = 'rss2.0'; + $nodeinfo['metadata']['protocols']['inbound'][] = 'atom1.0'; + $nodeinfo['metadata']['protocols']['inbound'][] = 'rss2.0'; $nodeinfo['metadata']['services'] = $nodeinfo['services']; @@ -84,8 +96,9 @@ class NodeInfo110 extends BaseModule $nodeinfo['metadata']['services']['inbound'][] = 'twitter'; } - $nodeinfo['metadata']['explicitContent'] = $config->get('system', 'explicit_content', false) == true; + $nodeinfo['metadata']['explicitContent'] = $this->config->get('system', 'explicit_content', false) == true; - System::jsonExit($nodeinfo, 'application/json; charset=utf-8', JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES); + $this->response->setType(ICanCreateResponses::TYPE_JSON); + $this->response->addContent(json_encode($nodeinfo, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES)); } } diff --git a/src/Module/NodeInfo120.php b/src/Module/NodeInfo120.php index aac8c6d4f..c8dcbd280 100644 --- a/src/Module/NodeInfo120.php +++ b/src/Module/NodeInfo120.php @@ -21,11 +21,15 @@ namespace Friendica\Module; +use Friendica\App; use Friendica\BaseModule; +use Friendica\Capabilities\ICanCreateResponses; use Friendica\Core\Addon; -use Friendica\Core\System; -use Friendica\DI; +use Friendica\Core\Config\Capability\IManageConfigValues; +use Friendica\Core\L10n; use Friendica\Model\Nodeinfo; +use Friendica\Util\Profiler; +use Psr\Log\LoggerInterface; /** * Version 2.0 of Nodeinfo, a standardized way of exposing metadata about a server running one of the distributed social networks. @@ -33,30 +37,38 @@ use Friendica\Model\Nodeinfo; */ class NodeInfo120 extends BaseModule { - public function rawContent() - { - $config = DI::config(); + /** @var IManageConfigValues */ + protected $config; + public function __construct(L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, IManageConfigValues $config, array $server, array $parameters = []) + { + parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters); + + $this->config = $config; + } + + protected function rawContent(array $request = []) + { $nodeinfo = [ - 'version' => '2.0', - 'software' => [ + 'version' => '2.0', + 'software' => [ 'name' => 'friendica', 'version' => FRIENDICA_VERSION . '-' . DB_UPDATE_VERSION, ], 'protocols' => ['dfrn', 'activitypub'], 'services' => [], 'usage' => [], - 'openRegistrations' => intval($config->get('config', 'register_policy')) !== Register::CLOSED, + 'openRegistrations' => intval($this->config->get('config', 'register_policy')) !== Register::CLOSED, 'metadata' => [ - 'nodeName' => $config->get('config', 'sitename'), + 'nodeName' => $this->config->get('config', 'sitename'), ], ]; - if (!empty($config->get('system', 'diaspora_enabled'))) { + if (!empty($this->config->get('system', 'diaspora_enabled'))) { $nodeinfo['protocols'][] = 'diaspora'; } - if (empty($config->get('system', 'ostatus_disabled'))) { + if (empty($this->config->get('system', 'ostatus_disabled'))) { $nodeinfo['protocols'][] = 'ostatus'; } @@ -72,12 +84,13 @@ class NodeInfo120 extends BaseModule $nodeinfo['services']['inbound'][] = 'rss2.0'; $nodeinfo['services']['outbound'][] = 'atom1.0'; - if (function_exists('imap_open') && !$config->get('system', 'imap_disabled')) { + if (function_exists('imap_open') && !$this->config->get('system', 'imap_disabled')) { $nodeinfo['services']['inbound'][] = 'imap'; } - $nodeinfo['metadata']['explicitContent'] = $config->get('system', 'explicit_content', false) == true; + $nodeinfo['metadata']['explicitContent'] = $this->config->get('system', 'explicit_content', false) == true; - System::jsonExit($nodeinfo, 'application/json; charset=utf-8', JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES); + $this->response->setType(ICanCreateResponses::TYPE_JSON, 'application/json; charset=utf-8'); + $this->response->addContent(json_encode($nodeinfo, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES)); } } diff --git a/src/Module/NodeInfo210.php b/src/Module/NodeInfo210.php index cb55411f2..43857c87a 100644 --- a/src/Module/NodeInfo210.php +++ b/src/Module/NodeInfo210.php @@ -21,11 +21,15 @@ namespace Friendica\Module; +use Friendica\App; use Friendica\BaseModule; +use Friendica\Capabilities\ICanCreateResponses; use Friendica\Core\Addon; -use Friendica\Core\System; -use Friendica\DI; +use Friendica\Core\Config\Capability\IManageConfigValues; +use Friendica\Core\L10n; use Friendica\Model\Nodeinfo; +use Friendica\Util\Profiler; +use Psr\Log\LoggerInterface; /** * Version 1.0 of Nodeinfo 2, a sStandardized way of exposing metadata about a server running one of the distributed social networks. @@ -33,30 +37,38 @@ use Friendica\Model\Nodeinfo; */ class NodeInfo210 extends BaseModule { - public function rawContent() - { - $config = DI::config(); + /** @var IManageConfigValues */ + protected $config; + public function __construct(L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, IManageConfigValues $config, array $server, array $parameters = []) + { + parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters); + + $this->config = $config; + } + + protected function rawContent(array $request = []) + { $nodeinfo = [ - 'version' => '1.0', - 'server' => [ - 'baseUrl' => DI::baseUrl()->get(), - 'name' => $config->get('config', 'sitename'), + 'version' => '1.0', + 'server' => [ + 'baseUrl' => $this->baseUrl->get(), + 'name' => $this->config->get('config', 'sitename'), 'software' => 'friendica', 'version' => FRIENDICA_VERSION . '-' . DB_UPDATE_VERSION, ], - 'organization' => Nodeinfo::getOrganization($config), + 'organization' => Nodeinfo::getOrganization($this->config), 'protocols' => ['dfrn', 'activitypub'], 'services' => [], - 'openRegistrations' => intval($config->get('config', 'register_policy')) !== Register::CLOSED, + 'openRegistrations' => intval($this->config->get('config', 'register_policy')) !== Register::CLOSED, 'usage' => [], ]; - if (!empty($config->get('system', 'diaspora_enabled'))) { + if (!empty($this->config->get('system', 'diaspora_enabled'))) { $nodeinfo['protocols'][] = 'diaspora'; } - if (empty($config->get('system', 'ostatus_disabled'))) { + if (empty($this->config->get('system', 'ostatus_disabled'))) { $nodeinfo['protocols'][] = 'ostatus'; } @@ -72,10 +84,11 @@ class NodeInfo210 extends BaseModule $nodeinfo['services']['inbound'][] = 'rss2.0'; $nodeinfo['services']['outbound'][] = 'atom1.0'; - if (function_exists('imap_open') && !$config->get('system', 'imap_disabled')) { + if (function_exists('imap_open') && !$this->config->get('system', 'imap_disabled')) { $nodeinfo['services']['inbound'][] = 'imap'; } - System::jsonExit($nodeinfo, 'application/json; charset=utf-8', JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES); + $this->response->setType(ICanCreateResponses::TYPE_JSON, 'application/json; charset=utf-8'); + $this->response->addContent(json_encode($nodeinfo, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES)); } } diff --git a/src/Module/Notifications/Introductions.php b/src/Module/Notifications/Introductions.php index b9bbd0be9..f8eacb85e 100644 --- a/src/Module/Notifications/Introductions.php +++ b/src/Module/Notifications/Introductions.php @@ -21,6 +21,7 @@ namespace Friendica\Module\Notifications; +use Friendica\App; use Friendica\App\Arguments; use Friendica\App\Mode; use Friendica\Content\ContactSelector; @@ -31,8 +32,11 @@ use Friendica\Core\Protocol; use Friendica\Core\Renderer; use Friendica\Model\User; use Friendica\Module\BaseNotifications; +use Friendica\Module\Response; use Friendica\Navigation\Notifications\Factory\Introduction as IntroductionFactory; use Friendica\Navigation\Notifications\ValueObject\Introduction; +use Friendica\Util\Profiler; +use Psr\Log\LoggerInterface; /** * Prints notifications about introduction @@ -44,9 +48,9 @@ class Introductions extends BaseNotifications /** @var Mode */ protected $mode; - public function __construct(Mode $mode, IntroductionFactory $notificationIntro, Arguments $args, L10n $l10n, array $parameters = []) + public function __construct(L10n $l10n, App\BaseURL $baseUrl, Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, Mode $mode, IntroductionFactory $notificationIntro, array $server, array $parameters = []) { - parent::__construct($args, $l10n, $parameters); + parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters); $this->notificationIntro = $notificationIntro; $this->mode = $mode; @@ -71,7 +75,7 @@ class Introductions extends BaseNotifications ]; } - public function content(): string + protected function content(array $request = []): string { Nav::setSelected('introductions'); diff --git a/src/Module/Notifications/Notification.php b/src/Module/Notifications/Notification.php index 486054f98..525159840 100644 --- a/src/Module/Notifications/Notification.php +++ b/src/Module/Notifications/Notification.php @@ -42,7 +42,7 @@ class Notification extends BaseModule * @throws \ImagickException * @throws \Exception */ - public function post() + protected function post(array $request = [], array $post = []) { if (!local_user()) { throw new HTTPException\UnauthorizedException(DI::l10n()->t('Permission denied.')); @@ -73,7 +73,7 @@ class Notification extends BaseModule * * @throws HTTPException\UnauthorizedException */ - public function rawContent() + protected function rawContent(array $request = []) { if (!local_user()) { throw new HTTPException\UnauthorizedException(DI::l10n()->t('Permission denied.')); @@ -101,7 +101,7 @@ class Notification extends BaseModule * @throws HTTPException\InternalServerErrorException * @throws \Exception */ - public function content(): string + protected function content(array $request = []): string { if (!local_user()) { notice(DI::l10n()->t('You must be logged in to show this page.')); diff --git a/src/Module/Notifications/Notifications.php b/src/Module/Notifications/Notifications.php index 269acb79d..5ed8a0141 100644 --- a/src/Module/Notifications/Notifications.php +++ b/src/Module/Notifications/Notifications.php @@ -21,13 +21,16 @@ namespace Friendica\Module\Notifications; +use Friendica\App; use Friendica\App\Arguments; -use Friendica\App\BaseURL; use Friendica\Content\Nav; use Friendica\Core\L10n; use Friendica\Core\Renderer; use Friendica\Module\BaseNotifications; +use Friendica\Module\Response; use Friendica\Navigation\Notifications\ValueObject\FormattedNotification; +use Friendica\Util\Profiler; +use Psr\Log\LoggerInterface; /** * Prints all notification types except introduction: @@ -41,15 +44,11 @@ class Notifications extends BaseNotifications /** @var \Friendica\Navigation\Notifications\Factory\FormattedNotification */ protected $formattedNotificationFactory; - /** @var BaseURL */ - protected $baseUrl; - - public function __construct(BaseURL $baseUrl, \Friendica\Navigation\Notifications\Factory\FormattedNotification $formattedNotificationFactory, Arguments $args, L10n $l10n, array $parameters = []) + public function __construct(L10n $l10n, App\BaseURL $baseUrl, Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, \Friendica\Navigation\Notifications\Factory\FormattedNotification $formattedNotificationFactory, array $server, array $parameters = []) { - parent::__construct($args, $l10n, $parameters); + parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters); $this->formattedNotificationFactory = $formattedNotificationFactory; - $this->baseUrl = $baseUrl; } /** @@ -96,7 +95,7 @@ class Notifications extends BaseNotifications ]; } - public function content(): string + protected function content(array $request = []): string { Nav::setSelected('notifications'); diff --git a/src/Module/OAuth/Acknowledge.php b/src/Module/OAuth/Acknowledge.php index f0915df41..f19837364 100644 --- a/src/Module/OAuth/Acknowledge.php +++ b/src/Module/OAuth/Acknowledge.php @@ -30,13 +30,13 @@ use Friendica\Module\BaseApi; */ class Acknowledge extends BaseApi { - public function post() + protected function post(array $request = [], array $post = []) { DI::session()->set('oauth_acknowledge', true); DI::app()->redirect(DI::session()->get('return_path')); } - public function content(): string + protected function content(array $request = []): string { DI::session()->set('return_path', $_REQUEST['return_path'] ?? ''); diff --git a/src/Module/OAuth/Authorize.php b/src/Module/OAuth/Authorize.php index d39cbe353..851e0f461 100644 --- a/src/Module/OAuth/Authorize.php +++ b/src/Module/OAuth/Authorize.php @@ -37,7 +37,7 @@ class Authorize extends BaseApi /** * @throws \Friendica\Network\HTTPException\InternalServerErrorException */ - public function rawContent() + protected function rawContent(array $request = []) { $request = self::getRequest([ 'force_login' => '', // Forces the user to re-login, which is necessary for authorizing with multiple accounts from the same instance. @@ -97,7 +97,7 @@ class Authorize extends BaseApi self::$oauth_code = $token['code']; } - public function content(): string + protected function content(array $request = []): string { if (empty(self::$oauth_code)) { return ''; diff --git a/src/Module/OAuth/Revoke.php b/src/Module/OAuth/Revoke.php index bf906ab45..8e92c63c3 100644 --- a/src/Module/OAuth/Revoke.php +++ b/src/Module/OAuth/Revoke.php @@ -32,7 +32,7 @@ use Friendica\Module\BaseApi; */ class Revoke extends BaseApi { - public function post() + public function post(array $request = [], array $post = []) { $request = self::getRequest([ 'client_id' => '', // Client ID, obtained during app registration diff --git a/src/Module/OAuth/Token.php b/src/Module/OAuth/Token.php index 6aef63f30..20ba22490 100644 --- a/src/Module/OAuth/Token.php +++ b/src/Module/OAuth/Token.php @@ -34,7 +34,7 @@ use Friendica\Security\OAuth; */ class Token extends BaseApi { - public function post() + protected function post(array $request = [], array $post = []) { $request = self::getRequest([ 'client_id' => '', // Client ID, obtained during app registration diff --git a/src/Module/Oembed.php b/src/Module/Oembed.php index 1b38c0e97..f433ca188 100644 --- a/src/Module/Oembed.php +++ b/src/Module/Oembed.php @@ -37,7 +37,7 @@ use Friendica\Util\Strings; */ class Oembed extends BaseModule { - public function content(): string + protected function content(array $request = []): string { // Unused form: /oembed/b2h?url=... if (DI::args()->getArgv()[1] == 'b2h') { diff --git a/src/Module/OpenSearch.php b/src/Module/OpenSearch.php index e5212c251..1342ba3af 100644 --- a/src/Module/OpenSearch.php +++ b/src/Module/OpenSearch.php @@ -36,7 +36,7 @@ class OpenSearch extends BaseModule /** * @throws \Exception */ - public function rawContent() + protected function rawContent(array $request = []) { header('Content-type: application/opensearchdescription+xml'); diff --git a/src/Module/Owa.php b/src/Module/Owa.php index 6062f2c99..2b8aa81bd 100644 --- a/src/Module/Owa.php +++ b/src/Module/Owa.php @@ -44,7 +44,7 @@ use Friendica\Util\Strings; */ class Owa extends BaseModule { - public function rawContent() + protected function rawContent(array $request = []) { $ret = [ 'success' => false ]; diff --git a/src/Module/ParseUrl.php b/src/Module/ParseUrl.php index 092d6ec74..7ccc8bd57 100644 --- a/src/Module/ParseUrl.php +++ b/src/Module/ParseUrl.php @@ -31,7 +31,7 @@ use Friendica\Util; class ParseUrl extends BaseModule { - public function rawContent() + protected function rawContent(array $request = []) { if (!Session::isAuthenticated()) { throw new \Friendica\Network\HTTPException\ForbiddenException(); diff --git a/src/Module/PermissionTooltip.php b/src/Module/PermissionTooltip.php index 1f6b58e4a..44176ecf8 100644 --- a/src/Module/PermissionTooltip.php +++ b/src/Module/PermissionTooltip.php @@ -15,7 +15,7 @@ use Friendica\Network\HTTPException; */ class PermissionTooltip extends \Friendica\BaseModule { - public function rawContent() + protected function rawContent(array $request = []) { $type = $this->parameters['type']; $referenceId = $this->parameters['id']; diff --git a/src/Module/Photo.php b/src/Module/Photo.php index 824edeb6a..e1eae44bd 100644 --- a/src/Module/Photo.php +++ b/src/Module/Photo.php @@ -51,7 +51,7 @@ class Photo extends BaseModule * Fetch a photo or an avatar, in optional size, check for permissions and * return the image */ - public function rawContent() + protected function rawContent(array $request = []) { $totalstamp = microtime(true); diff --git a/src/Module/Profile/Common.php b/src/Module/Profile/Common.php index 4a335ddf7..2bda4466b 100644 --- a/src/Module/Profile/Common.php +++ b/src/Module/Profile/Common.php @@ -35,7 +35,7 @@ use Friendica\Network\HTTPException; class Common extends BaseProfile { - public function content(): string + protected function content(array $request = []): string { if (DI::config()->get('system', 'block_public') && !Session::isAuthenticated()) { throw new HTTPException\NotFoundException(DI::l10n()->t('User not found.')); diff --git a/src/Module/Profile/Contacts.php b/src/Module/Profile/Contacts.php index e20fd3f2d..133b2c81a 100644 --- a/src/Module/Profile/Contacts.php +++ b/src/Module/Profile/Contacts.php @@ -34,7 +34,7 @@ use Friendica\Network\HTTPException; class Contacts extends Module\BaseProfile { - public function content(): string + protected function content(array $request = []): string { if (DI::config()->get('system', 'block_public') && !Session::isAuthenticated()) { throw new HTTPException\NotFoundException(DI::l10n()->t('User not found.')); diff --git a/src/Module/Profile/Index.php b/src/Module/Profile/Index.php index 653eb2a19..6980380fc 100644 --- a/src/Module/Profile/Index.php +++ b/src/Module/Profile/Index.php @@ -35,13 +35,13 @@ use Friendica\Core\L10n; */ class Index extends BaseModule { - public function rawContent() + protected function rawContent(array $request = []) { - (new Profile($this->l10n, $this->parameters))->rawContent(); + (new Profile($this->l10n, $this->baseUrl, $this->args, $this->logger, $this->profiler, $this->response, $this->server, $this->parameters))->rawContent(); } - public function content(): string + protected function content(array $request = []): string { - return (new Status($this->l10n, $this->parameters))->content(); + return (new Status($this->l10n, $this->baseUrl, $this->args, $this->logger, $this->profiler, $this->response, $this->server, $this->parameters))->content(); } } diff --git a/src/Module/Profile/Media.php b/src/Module/Profile/Media.php index 74af5f95e..049232dff 100644 --- a/src/Module/Profile/Media.php +++ b/src/Module/Profile/Media.php @@ -29,7 +29,7 @@ use Friendica\Network\HTTPException; class Media extends BaseProfile { - public function content(): string + protected function content(array $request = []): string { $a = DI::app(); diff --git a/src/Module/Profile/Profile.php b/src/Module/Profile/Profile.php index a497fc4dd..6624d993f 100644 --- a/src/Module/Profile/Profile.php +++ b/src/Module/Profile/Profile.php @@ -46,7 +46,7 @@ use Friendica\Util\Temporal; class Profile extends BaseProfile { - public function rawContent() + protected function rawContent(array $request = []) { if (ActivityPub::isRequest()) { $user = DBA::selectFirst('user', ['uid'], ['nickname' => $this->parameters['nickname']]); @@ -73,7 +73,7 @@ class Profile extends BaseProfile } } - public function content(): string + protected function content(array $request = []): string { $a = DI::app(); diff --git a/src/Module/Profile/Schedule.php b/src/Module/Profile/Schedule.php index 1e9cd5fa5..c14c19b9b 100644 --- a/src/Module/Profile/Schedule.php +++ b/src/Module/Profile/Schedule.php @@ -33,7 +33,7 @@ use Friendica\Util\DateTimeFormat; class Schedule extends BaseProfile { - public function post() + protected function post(array $request = [], array $post = []) { if (!local_user()) { throw new HTTPException\ForbiddenException(DI::l10n()->t('Permission denied.')); @@ -50,7 +50,7 @@ class Schedule extends BaseProfile Post\Delayed::deleteById($_REQUEST['delete']); } - public function content(): string + protected function content(array $request = []): string { if (!local_user()) { throw new HTTPException\ForbiddenException(DI::l10n()->t('Permission denied.')); diff --git a/src/Module/Profile/Status.php b/src/Module/Profile/Status.php index ad9a4acde..a3b0ff1ea 100644 --- a/src/Module/Profile/Status.php +++ b/src/Module/Profile/Status.php @@ -46,7 +46,7 @@ use Friendica\Util\XML; class Status extends BaseProfile { - public function content(): string + protected function content(array $request = []): string { $args = DI::args(); diff --git a/src/Module/Proxy.php b/src/Module/Proxy.php index abe9a8c2e..c84564e0f 100644 --- a/src/Module/Proxy.php +++ b/src/Module/Proxy.php @@ -44,7 +44,7 @@ class Proxy extends BaseModule /** * Fetch remote image content */ - public function rawContent() + protected function rawContent(array $request = []) { $request = $this->getRequestInfo(); diff --git a/src/Module/PublicRSAKey.php b/src/Module/PublicRSAKey.php index d159255ee..f0e9dc285 100644 --- a/src/Module/PublicRSAKey.php +++ b/src/Module/PublicRSAKey.php @@ -33,7 +33,7 @@ use Friendica\Util\Strings; */ class PublicRSAKey extends BaseModule { - public function rawContent() + protected function rawContent(array $request = []) { if (empty($this->parameters['nick'])) { throw new BadRequestException(); diff --git a/src/Module/RandomProfile.php b/src/Module/RandomProfile.php index 38cd68429..c4882b1bf 100644 --- a/src/Module/RandomProfile.php +++ b/src/Module/RandomProfile.php @@ -30,7 +30,7 @@ use Friendica\Model\Contact; */ class RandomProfile extends BaseModule { - public function content(): string + protected function content(array $request = []): string { $a = DI::app(); diff --git a/src/Module/ReallySimpleDiscovery.php b/src/Module/ReallySimpleDiscovery.php index fe071fc55..dacee205b 100644 --- a/src/Module/ReallySimpleDiscovery.php +++ b/src/Module/ReallySimpleDiscovery.php @@ -31,7 +31,7 @@ use Friendica\Util\XML; */ class ReallySimpleDiscovery extends BaseModule { - public function rawContent() + protected function rawContent(array $request = []) { header('Content-Type: text/xml'); diff --git a/src/Module/Register.php b/src/Module/Register.php index 609e86a91..3c92c0062 100644 --- a/src/Module/Register.php +++ b/src/Module/Register.php @@ -21,8 +21,10 @@ namespace Friendica\Module; +use Friendica\App; use Friendica\BaseModule; use Friendica\Content\Text\BBCode; +use Friendica\Core\Config\Capability\IManageConfigValues; use Friendica\Core\Hook; use Friendica\Core\L10n; use Friendica\Core\Logger; @@ -32,7 +34,9 @@ use Friendica\Database\DBA; use Friendica\DI; use Friendica\Model; use Friendica\Model\User; +use Friendica\Util\Profiler; use Friendica\Util\Proxy; +use Psr\Log\LoggerInterface; /** * @author Hypolite Petovan @@ -46,11 +50,11 @@ class Register extends BaseModule /** @var Tos */ protected $tos; - public function __construct(Tos $tos, L10n $l10n, array $parameters = []) + public function __construct(L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, IManageConfigValues $config, array $server, array $parameters = []) { - parent::__construct($l10n, $parameters); + parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters); - $this->tos = $tos; + $this->tos = new Tos($l10n, $baseUrl, $args, $logger, $profiler, $response, $config, $server, $parameters); } /** @@ -62,7 +66,7 @@ class Register extends BaseModule * * @return string */ - public function content(): string + protected function content(array $request = []): string { // logged in users can register others (people/pages/groups) // even with closed registrations, unless specifically prohibited by site policy. @@ -189,7 +193,7 @@ class Register extends BaseModule * Extend this method if the module is supposed to process POST requests. * Doesn't display any content */ - public function post() + protected function post(array $request = [], array $post = []) { BaseModule::checkFormSecurityTokenRedirectOnError('/register', 'register'); diff --git a/src/Module/RemoteFollow.php b/src/Module/RemoteFollow.php index bc42998e3..ee2dcfe4d 100644 --- a/src/Module/RemoteFollow.php +++ b/src/Module/RemoteFollow.php @@ -21,7 +21,7 @@ namespace Friendica\Module; -use Friendica\App\BaseURL; +use Friendica\App; use Friendica\App\Page; use Friendica\BaseModule; use Friendica\Content\Widget; @@ -36,6 +36,8 @@ use Friendica\Model\Profile; use Friendica\Model\User; use Friendica\Network\HTTPException; use Friendica\Network\Probe; +use Friendica\Util\Profiler; +use Psr\Log\LoggerInterface; /** * Remotely follow the account on this system by the provided account @@ -46,23 +48,20 @@ class RemoteFollow extends BaseModule protected $owner; /** @var Page */ protected $page; - /** @var BaseURL */ - protected $baseUrl; - public function __construct(L10n $l10n, Page $page, BaseURL $baseUrl, array $parameters = []) + public function __construct(L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, App\Page $page, LoggerInterface $logger, Profiler $profiler, Response $response, array $server, array $parameters = []) { - parent::__construct($l10n, $parameters); + parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters); $this->owner = User::getOwnerDataByNick($this->parameters['profile']); if (!$this->owner) { throw new HTTPException\NotFoundException($this->t('User not found.')); } - $this->baseUrl = $baseUrl; $this->page = $page; } - public function post() + protected function post(array $request = [], array $post = []) { if (!empty($_POST['cancel']) || empty($_POST['dfrn_url'])) { $this->baseUrl->redirect(); @@ -106,7 +105,7 @@ class RemoteFollow extends BaseModule System::externalRedirect($follow_link); } - public function content(): string + protected function content(array $request = []): string { if (empty($this->owner)) { return ''; diff --git a/src/Module/Response.php b/src/Module/Response.php new file mode 100644 index 000000000..d24ebe954 --- /dev/null +++ b/src/Module/Response.php @@ -0,0 +1,113 @@ +headers[$key]); + } + + if (isset($header)) { + if (empty($key)) { + $this->headers[] = $header; + } else { + $this->headers[$key] = $header; + } + } + } + + /** + * {@inheritDoc} + */ + public function addContent($content): void + { + $this->content .= $content; + } + + /** + * {@inheritDoc} + */ + public function getHeaders(): array + { + return $this->headers; + } + + /** + * {@inheritDoc} + */ + public function getContent() + { + return $this->content; + } + + /** + * {@inheritDoc} + */ + public function setType(string $type, ?string $content_type = null): void + { + if (!in_array($type, static::ALLOWED_TYPES)) { + throw new InternalServerErrorException('wrong type'); + } + + switch ($type) { + case static::TYPE_JSON: + $content_type = $content_type ?? 'application/json'; + break; + case static::TYPE_XML: + $content_type = $content_type ?? 'text/xml'; + break; + case static::TYPE_RSS: + $content_type = $content_type ?? 'application/rss+xml'; + break; + case static::TYPE_ATOM: + $content_type = $content_type ?? 'application/atom+xml'; + break; + } + + $this->setHeader($content_type, 'Content-type'); + + $this->type = $type; + } + + /** + * {@inheritDoc} + */ + public function getType(): string + { + return $this->type; + } + + /** + * {@inheritDoc} + */ + public function generate(): ResponseInterface + { + // Setting the response type as an X-header for direct usage + $this->headers[static::X_HEADER] = $this->type; + + return new \GuzzleHttp\Psr7\Response(200, $this->headers, $this->content); + } +} diff --git a/src/Module/RobotsTxt.php b/src/Module/RobotsTxt.php index ec7ee086e..9297c98de 100644 --- a/src/Module/RobotsTxt.php +++ b/src/Module/RobotsTxt.php @@ -28,7 +28,7 @@ use Friendica\BaseModule; */ class RobotsTxt extends BaseModule { - public function rawContent() + protected function rawContent(array $request = []) { $allDisalloweds = [ '/settings/', diff --git a/src/Module/Search/Acl.php b/src/Module/Search/Acl.php index 0866b5f9a..ec5480400 100644 --- a/src/Module/Search/Acl.php +++ b/src/Module/Search/Acl.php @@ -48,7 +48,7 @@ class Acl extends BaseModule const TYPE_PRIVATE_MESSAGE = 'm'; const TYPE_ANY_CONTACT = 'a'; - public function rawContent() + protected function rawContent(array $request = []) { if (!local_user()) { throw new HTTPException\UnauthorizedException(DI::l10n()->t('You must be logged in to use this module.')); diff --git a/src/Module/Search/Directory.php b/src/Module/Search/Directory.php index bbd90f137..ca57b3251 100644 --- a/src/Module/Search/Directory.php +++ b/src/Module/Search/Directory.php @@ -31,7 +31,7 @@ use Friendica\Module\Security\Login; */ class Directory extends BaseSearch { - public function content(): string + protected function content(array $request = []): string { if (!local_user()) { notice(DI::l10n()->t('Permission denied.')); diff --git a/src/Module/Search/Filed.php b/src/Module/Search/Filed.php index 519b0ece0..cfecce8eb 100644 --- a/src/Module/Search/Filed.php +++ b/src/Module/Search/Filed.php @@ -17,7 +17,7 @@ use Friendica\Module\Security\Login; class Filed extends BaseSearch { - public function content(): string + protected function content(array $request = []): string { if (!local_user()) { return Login::form(); diff --git a/src/Module/Search/Index.php b/src/Module/Search/Index.php index 2118aeaae..ad90e729e 100644 --- a/src/Module/Search/Index.php +++ b/src/Module/Search/Index.php @@ -41,7 +41,7 @@ use Friendica\Network\HTTPException; class Index extends BaseSearch { - public function content(): string + protected function content(array $request = []): string { $search = (!empty($_GET['q']) ? trim(rawurldecode($_GET['q'])) : ''); diff --git a/src/Module/Search/Saved.php b/src/Module/Search/Saved.php index c94183367..9dd1ed019 100644 --- a/src/Module/Search/Saved.php +++ b/src/Module/Search/Saved.php @@ -21,32 +21,28 @@ namespace Friendica\Module\Search; -use Friendica\App\Arguments; -use Friendica\App\BaseURL; +use Friendica\App; use Friendica\BaseModule; use Friendica\Core\L10n; use Friendica\Core\Search; use Friendica\Database\Database; +use Friendica\Module\Response; +use Friendica\Util\Profiler; +use Psr\Log\LoggerInterface; class Saved extends BaseModule { - /** @var Arguments */ - protected $args; /** @var Database */ protected $dba; - /** @var BaseURL */ - protected $baseUrl; - public function __construct(BaseURL $baseUrl, Database $dba, Arguments $args, L10n $l10n, array $parameters = []) + public function __construct(L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, Database $dba, array $server, array $parameters = []) { - parent::__construct($l10n, $parameters); + parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters); - $this->baseUrl = $baseUrl; - $this->dba = $dba; - $this->args = $args; + $this->dba = $dba; } - public function rawContent() + protected function rawContent(array $request = []) { $action = $this->args->get(2, 'none'); $search = trim(rawurldecode($_GET['term'] ?? '')); diff --git a/src/Module/Security/Login.php b/src/Module/Security/Login.php index 5c47e9749..90f2d663a 100644 --- a/src/Module/Security/Login.php +++ b/src/Module/Security/Login.php @@ -33,7 +33,7 @@ use Friendica\Module\Register; */ class Login extends BaseModule { - public function content(): string + protected function content(array $request = []): string { $return_path = $_REQUEST['return_path'] ?? '' ; @@ -46,7 +46,7 @@ class Login extends BaseModule return self::form(Session::get('return_path'), intval(DI::config()->get('config', 'register_policy')) !== \Friendica\Module\Register::CLOSED); } - public function post() + protected function post(array $request = [], array $post = []) { $return_path = Session::get('return_path'); Session::clear(); diff --git a/src/Module/Security/Logout.php b/src/Module/Security/Logout.php index 61b32c28b..f9c702d51 100644 --- a/src/Module/Security/Logout.php +++ b/src/Module/Security/Logout.php @@ -21,7 +21,7 @@ namespace Friendica\Module\Security; -use Friendica\App\BaseURL; +use Friendica\App; use Friendica\BaseModule; use Friendica\Core\Cache\Capability\ICanCache; use Friendica\Core\Hook; @@ -30,7 +30,10 @@ use Friendica\Core\Session\Capability\IHandleSessions; use Friendica\Core\System; use Friendica\Model\Profile; use Friendica\Model\User\Cookie; +use Friendica\Module\Response; use Friendica\Security\TwoFactor; +use Friendica\Util\Profiler; +use Psr\Log\LoggerInterface; /** * Logout module @@ -43,19 +46,16 @@ class Logout extends BaseModule protected $cookie; /** @var IHandleSessions */ protected $session; - /** @var BaseURL */ - protected $baseUrl; /** @var TwoFactor\Repository\TrustedBrowser */ protected $trustedBrowserRepo; - public function __construct(TwoFactor\Repository\TrustedBrowser $trustedBrowserRepo, ICanCache $cache, Cookie $cookie, IHandleSessions $session, BaseURL $baseUrl, L10n $l10n, array $parameters = []) + public function __construct(L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, TwoFactor\Repository\TrustedBrowser $trustedBrowserRepo, ICanCache $cache, Cookie $cookie, IHandleSessions $session, array $server, array $parameters = []) { - parent::__construct($l10n, $parameters); + parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters); $this->cache = $cache; $this->cookie = $cookie; $this->session = $session; - $this->baseUrl = $baseUrl; $this->trustedBrowserRepo = $trustedBrowserRepo; } @@ -63,7 +63,7 @@ class Logout extends BaseModule /** * Process logout requests */ - public function rawContent() + protected function rawContent(array $request = []) { $visitor_home = null; if (remote_user()) { diff --git a/src/Module/Security/OpenID.php b/src/Module/Security/OpenID.php index 360c9c672..af2b0fd09 100644 --- a/src/Module/Security/OpenID.php +++ b/src/Module/Security/OpenID.php @@ -31,7 +31,7 @@ use LightOpenID; */ class OpenID extends BaseModule { - public function content(): string + protected function content(array $request = []): string { if (DI::config()->get('system', 'no_openid')) { DI::baseUrl()->redirect(); diff --git a/src/Module/Security/TwoFactor/Recovery.php b/src/Module/Security/TwoFactor/Recovery.php index 60de6e404..6556e07c2 100644 --- a/src/Module/Security/TwoFactor/Recovery.php +++ b/src/Module/Security/TwoFactor/Recovery.php @@ -27,8 +27,11 @@ use Friendica\Core\L10n; use Friendica\Core\Renderer; use Friendica\Core\Session\Capability\IHandleSessions; use Friendica\Model\User; +use Friendica\Module\Response; use Friendica\Security\Authentication; use Friendica\Security\TwoFactor\Model\RecoveryCode; +use Friendica\Util\Profiler; +use Psr\Log\LoggerInterface; /** * // Page 1a: Recovery code verification @@ -41,22 +44,19 @@ class Recovery extends BaseModule protected $session; /** @var App */ protected $app; - /** @var App\BaseURL */ - protected $baseUrl; /** @var Authentication */ protected $auth; - public function __construct(App $app, App\BaseURL $baseUrl, Authentication $auth, IHandleSessions $session, L10n $l10n, array $parameters = []) + public function __construct(App $app, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, Authentication $auth, IHandleSessions $session, array $server, array $parameters = []) { - parent::__construct($l10n, $parameters); + parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters); $this->app = $app; - $this->baseUrl = $baseUrl; $this->auth = $auth; $this->session = $session; } - public function post() + protected function post(array $request = [], array $post = []) { if (!local_user()) { return; @@ -79,7 +79,7 @@ class Recovery extends BaseModule } } - public function content(): string + protected function content(array $request = []): string { if (!local_user()) { $this->baseUrl->redirect(); diff --git a/src/Module/Security/TwoFactor/Verify.php b/src/Module/Security/TwoFactor/Verify.php index 3669943ba..454cc9f7c 100644 --- a/src/Module/Security/TwoFactor/Verify.php +++ b/src/Module/Security/TwoFactor/Verify.php @@ -38,7 +38,7 @@ class Verify extends BaseModule { private static $errors = []; - public function post() + protected function post(array $request = [], array $post = []) { if (!local_user()) { return; @@ -78,7 +78,7 @@ class Verify extends BaseModule } } - public function content(): string + protected function content(array $request = []): string { if (!local_user()) { DI::baseUrl()->redirect(); diff --git a/src/Module/Settings/Delegation.php b/src/Module/Settings/Delegation.php index a2e458839..d385544af 100644 --- a/src/Module/Settings/Delegation.php +++ b/src/Module/Settings/Delegation.php @@ -36,7 +36,7 @@ use Friendica\Util\Strings; */ class Delegation extends BaseSettings { - public function post() + protected function post(array $request = [], array $post = []) { if (!DI::app()->isLoggedIn()) { throw new HTTPException\ForbiddenException(DI::l10n()->t('Permission denied.')); @@ -62,7 +62,7 @@ class Delegation extends BaseSettings DBA::update('user', ['parent-uid' => $parent_uid], ['uid' => local_user()]); } - public function content(): string + protected function content(array $request = []): string { parent::content(); diff --git a/src/Module/Settings/Display.php b/src/Module/Settings/Display.php index aab8f864b..2155391a9 100644 --- a/src/Module/Settings/Display.php +++ b/src/Module/Settings/Display.php @@ -36,7 +36,7 @@ use Friendica\Network\HTTPException; */ class Display extends BaseSettings { - public function post() + protected function post(array $request = [], array $post = []) { if (!DI::app()->isLoggedIn()) { throw new HTTPException\ForbiddenException(DI::l10n()->t('Permission denied.')); @@ -112,7 +112,7 @@ class Display extends BaseSettings DI::baseUrl()->redirect('settings/display'); } - public function content(): string + protected function content(array $request = []): string { parent::content(); diff --git a/src/Module/Settings/Profile/Index.php b/src/Module/Settings/Profile/Index.php index 161c440b6..9f25db524 100644 --- a/src/Module/Settings/Profile/Index.php +++ b/src/Module/Settings/Profile/Index.php @@ -41,7 +41,7 @@ use Friendica\Util\Temporal; class Index extends BaseSettings { - public function post() + protected function post(array $request = [], array $post = []) { if (!local_user()) { return; @@ -135,7 +135,7 @@ class Index extends BaseSettings DI::baseUrl()->redirect('settings/profile'); } - public function content(): string + protected function content(array $request = []): string { if (!local_user()) { notice(DI::l10n()->t('You must be logged in to use this module')); diff --git a/src/Module/Settings/Profile/Photo/Crop.php b/src/Module/Settings/Profile/Photo/Crop.php index 3b5f109d7..a77057e1a 100644 --- a/src/Module/Settings/Profile/Photo/Crop.php +++ b/src/Module/Settings/Profile/Photo/Crop.php @@ -33,7 +33,7 @@ use Friendica\Network\HTTPException; class Crop extends BaseSettings { - public function post() + protected function post(array $request = [], array $post = []) { if (!Session::isAuthenticated()) { return; @@ -160,7 +160,7 @@ class Crop extends BaseSettings DI::baseUrl()->redirect($path); } - public function content(): string + protected function content(array $request = []): string { if (!Session::isAuthenticated()) { throw new HTTPException\ForbiddenException(DI::l10n()->t('Permission denied.')); diff --git a/src/Module/Settings/Profile/Photo/Index.php b/src/Module/Settings/Profile/Photo/Index.php index 2e65a01c6..309a893e6 100644 --- a/src/Module/Settings/Profile/Photo/Index.php +++ b/src/Module/Settings/Profile/Photo/Index.php @@ -34,7 +34,7 @@ use Friendica\Util\Strings; class Index extends BaseSettings { - public function post() + protected function post(array $request = [], array $post = []) { if (!Session::isAuthenticated()) { return; @@ -106,7 +106,7 @@ class Index extends BaseSettings DI::baseUrl()->redirect('settings/profile/photo/crop/' . $resource_id); } - public function content(): string + protected function content(array $request = []): string { if (!Session::isAuthenticated()) { throw new HTTPException\ForbiddenException(DI::l10n()->t('Permission denied.')); diff --git a/src/Module/Settings/TwoFactor/AppSpecific.php b/src/Module/Settings/TwoFactor/AppSpecific.php index 21db4f8ab..94dfc6d41 100644 --- a/src/Module/Settings/TwoFactor/AppSpecific.php +++ b/src/Module/Settings/TwoFactor/AppSpecific.php @@ -21,13 +21,16 @@ namespace Friendica\Module\Settings\TwoFactor; -use Friendica\App\BaseURL; +use Friendica\App; use Friendica\Core\L10n; use Friendica\Core\PConfig\Capability\IManagePersonalConfigValues; use Friendica\Core\Renderer; +use Friendica\Module\Response; use Friendica\Security\TwoFactor\Model\AppSpecificPassword; use Friendica\Module\BaseSettings; use Friendica\Module\Security\Login; +use Friendica\Util\Profiler; +use Psr\Log\LoggerInterface; /** * // Page 5: 2FA enabled, app-specific password generation @@ -40,15 +43,12 @@ class AppSpecific extends BaseSettings /** @var IManagePersonalConfigValues */ protected $pConfig; - /** @var BaseURL */ - protected $baseUrl; - - public function __construct(IManagePersonalConfigValues $pConfig, BaseURL $baseUrl, L10n $l10n, array $parameters = []) + + public function __construct(L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, IManagePersonalConfigValues $pConfig, array $server, array $parameters = []) { - parent::__construct($l10n, $parameters); + parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters); $this->pConfig = $pConfig; - $this->baseUrl = $baseUrl; if (!local_user()) { return; @@ -66,7 +66,7 @@ class AppSpecific extends BaseSettings } } - public function post() + protected function post(array $request = [], array $post = []) { if (!local_user()) { return; @@ -109,7 +109,7 @@ class AppSpecific extends BaseSettings } } - public function content(): string + protected function content(array $request = []): string { if (!local_user()) { return Login::form('settings/2fa/app_specific'); diff --git a/src/Module/Settings/TwoFactor/Index.php b/src/Module/Settings/TwoFactor/Index.php index 0dcef14ad..ec57a8d14 100644 --- a/src/Module/Settings/TwoFactor/Index.php +++ b/src/Module/Settings/TwoFactor/Index.php @@ -33,7 +33,7 @@ use PragmaRX\Google2FA\Google2FA; class Index extends BaseSettings { - public function post() + protected function post(array $request = [], array $post = []) { if (!local_user()) { return; @@ -94,7 +94,7 @@ class Index extends BaseSettings } } - public function content(): string + protected function content(array $request = []): string { if (!local_user()) { return Login::form('settings/2fa'); diff --git a/src/Module/Settings/TwoFactor/Recovery.php b/src/Module/Settings/TwoFactor/Recovery.php index 961c2cd90..fb13b8b60 100644 --- a/src/Module/Settings/TwoFactor/Recovery.php +++ b/src/Module/Settings/TwoFactor/Recovery.php @@ -21,13 +21,16 @@ namespace Friendica\Module\Settings\TwoFactor; -use Friendica\App\BaseURL; +use Friendica\App; use Friendica\Core\L10n; use Friendica\Core\PConfig\Capability\IManagePersonalConfigValues; use Friendica\Core\Renderer; +use Friendica\Module\Response; use Friendica\Security\TwoFactor\Model\RecoveryCode; use Friendica\Module\BaseSettings; use Friendica\Module\Security\Login; +use Friendica\Util\Profiler; +use Psr\Log\LoggerInterface; /** * // Page 3: 2FA enabled but not verified, show recovery codes @@ -38,15 +41,12 @@ class Recovery extends BaseSettings { /** @var IManagePersonalConfigValues */ protected $pConfig; - /** @var BaseURL */ - protected $baseUrl; - public function __construct(IManagePersonalConfigValues $pConfig, BaseURL $baseUrl, L10n $l10n, array $parameters = []) + public function __construct(L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, IManagePersonalConfigValues $pConfig, array $server, array $parameters = []) { - parent::__construct($l10n, $parameters); + parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters); $this->pConfig = $pConfig; - $this->baseUrl = $baseUrl; if (!local_user()) { return; @@ -64,7 +64,7 @@ class Recovery extends BaseSettings } } - public function post() + protected function post(array $request = [], array $post = []) { if (!local_user()) { return; @@ -81,7 +81,7 @@ class Recovery extends BaseSettings } } - public function content(): string + protected function content(array $request = []): string { if (!local_user()) { return Login::form('settings/2fa/recovery'); diff --git a/src/Module/Settings/TwoFactor/Trusted.php b/src/Module/Settings/TwoFactor/Trusted.php index 844cd4dff..1507d5fc5 100644 --- a/src/Module/Settings/TwoFactor/Trusted.php +++ b/src/Module/Settings/TwoFactor/Trusted.php @@ -2,14 +2,17 @@ namespace Friendica\Module\Settings\TwoFactor; -use Friendica\App\BaseURL; +use Friendica\App; use Friendica\Core\L10n; use Friendica\Core\PConfig\Capability\IManagePersonalConfigValues; use Friendica\Core\Renderer; use Friendica\Module\BaseSettings; +use Friendica\Module\Response; use Friendica\Security\TwoFactor; use Friendica\Util\DateTimeFormat; +use Friendica\Util\Profiler; use Friendica\Util\Temporal; +use Psr\Log\LoggerInterface; use UAParser\Parser; /** @@ -19,17 +22,14 @@ class Trusted extends BaseSettings { /** @var IManagePersonalConfigValues */ protected $pConfig; - /** @var BaseURL */ - protected $baseUrl; /** @var TwoFactor\Repository\TrustedBrowser */ protected $trustedBrowserRepo; - public function __construct(IManagePersonalConfigValues $pConfig, BaseURL $baseUrl, TwoFactor\Repository\TrustedBrowser $trustedBrowserRepo, L10n $l10n, array $parameters = []) + public function __construct(L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, IManagePersonalConfigValues $pConfig, TwoFactor\Repository\TrustedBrowser $trustedBrowserRepo, array $server, array $parameters = []) { - parent::__construct($l10n, $parameters); + parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters); $this->pConfig = $pConfig; - $this->baseUrl = $baseUrl; $this->trustedBrowserRepo = $trustedBrowserRepo; if (!local_user()) { @@ -48,7 +48,7 @@ class Trusted extends BaseSettings } } - public function post() + protected function post(array $request = [], array $post = []) { if (!local_user()) { return; @@ -78,7 +78,7 @@ class Trusted extends BaseSettings } - public function content(): string + protected function content(array $request = []): string { parent::content(); diff --git a/src/Module/Settings/TwoFactor/Verify.php b/src/Module/Settings/TwoFactor/Verify.php index 93fdde920..3c1853d7f 100644 --- a/src/Module/Settings/TwoFactor/Verify.php +++ b/src/Module/Settings/TwoFactor/Verify.php @@ -25,14 +25,17 @@ use BaconQrCode\Renderer\Image\SvgImageBackEnd; use BaconQrCode\Renderer\ImageRenderer; use BaconQrCode\Renderer\RendererStyle\RendererStyle; use BaconQrCode\Writer; -use Friendica\App\BaseURL; +use Friendica\App; use Friendica\Core\L10n; use Friendica\Core\PConfig\Capability\IManagePersonalConfigValues; use Friendica\Core\Renderer; use Friendica\Core\Session; use Friendica\Module\BaseSettings; +use Friendica\Module\Response; use Friendica\Module\Security\Login; +use Friendica\Util\Profiler; use PragmaRX\Google2FA\Google2FA; +use Psr\Log\LoggerInterface; /** * // Page 4: 2FA enabled but not verified, QR code and verification @@ -43,15 +46,12 @@ class Verify extends BaseSettings { /** @var IManagePersonalConfigValues */ protected $pConfig; - /** @var BaseURL */ - protected $baseUrl; - public function __construct(IManagePersonalConfigValues $pConfig, BaseURL $baseUrl, L10n $l10n, array $parameters = []) + public function __construct(L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, IManagePersonalConfigValues $pConfig, array $server, array $parameters = []) { - parent::__construct($l10n, $parameters); + parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters); $this->pConfig = $pConfig; - $this->baseUrl = $baseUrl; if (!local_user()) { return; @@ -70,7 +70,7 @@ class Verify extends BaseSettings } } - public function post() + protected function post(array $request = [], array $post = []) { if (!local_user()) { return; @@ -96,7 +96,7 @@ class Verify extends BaseSettings } } - public function content(): string + protected function content(array $request = []): string { if (!local_user()) { return Login::form('settings/2fa/verify'); diff --git a/src/Module/Settings/UserExport.php b/src/Module/Settings/UserExport.php index b5d79c4af..431cbfe10 100644 --- a/src/Module/Settings/UserExport.php +++ b/src/Module/Settings/UserExport.php @@ -51,7 +51,7 @@ class UserExport extends BaseSettings * @throws HTTPException\ForbiddenException * @throws HTTPException\InternalServerErrorException */ - public function content(): string + protected function content(array $request = []): string { if (!local_user()) { throw new HTTPException\ForbiddenException(DI::l10n()->t('Permission denied.')); @@ -85,7 +85,7 @@ class UserExport extends BaseSettings * * @throws HTTPException\ForbiddenException */ - public function rawContent() + protected function rawContent(array $request = []) { if (!DI::app()->isLoggedIn()) { throw new HTTPException\ForbiddenException(DI::l10n()->t('Permission denied.')); diff --git a/src/Module/Smilies.php b/src/Module/Smilies.php index ded798005..ae368cd71 100644 --- a/src/Module/Smilies.php +++ b/src/Module/Smilies.php @@ -33,7 +33,7 @@ use Friendica\DI; */ class Smilies extends BaseModule { - public function rawContent() + protected function rawContent(array $request = []) { if (!empty(DI::args()->getArgv()[1]) && (DI::args()->getArgv()[1] === "json")) { $smilies = Content\Smilies::getList(); @@ -45,7 +45,7 @@ class Smilies extends BaseModule } } - public function content(): string + protected function content(array $request = []): string { $smilies = Content\Smilies::getList(); $count = count($smilies['texts'] ?? []); diff --git a/src/Module/Statistics.php b/src/Module/Statistics.php index f4a1334d2..823b399a5 100644 --- a/src/Module/Statistics.php +++ b/src/Module/Statistics.php @@ -21,25 +21,24 @@ namespace Friendica\Module; +use Friendica\App; use Friendica\BaseModule; use Friendica\Core\Addon; use Friendica\Core\Config\Capability\IManageConfigValues; use Friendica\Core\L10n; use Friendica\Network\HTTPException\NotFoundException; +use Friendica\Util\Profiler; use Psr\Log\LoggerInterface; class Statistics extends BaseModule { /** @var IManageConfigValues */ protected $config; - /** @var LoggerInterface */ - protected $logger; - public function __construct(IManageConfigValues $config, LoggerInterface $logger, L10n $l10n, array $parameters = []) + public function __construct(L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, IManageConfigValues $config, Response $response, array $server, array $parameters = []) { - parent::__construct($l10n, $parameters); + parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters); - $this->logger = $logger; $this->config = $config; if (!$this->config->get("system", "nodeinfo")) { @@ -47,7 +46,7 @@ class Statistics extends BaseModule } } - public function rawContent() + protected function rawContent(array $request = []) { $registration_open = intval($this->config->get('config', 'register_policy')) !== Register::CLOSED diff --git a/src/Module/Theme.php b/src/Module/Theme.php index 6c164b5ba..a57751cea 100644 --- a/src/Module/Theme.php +++ b/src/Module/Theme.php @@ -30,7 +30,7 @@ use Friendica\Util\Strings; */ class Theme extends BaseModule { - public function rawContent() + protected function rawContent(array $request = []) { header('Content-Type: text/css'); diff --git a/src/Module/ThemeDetails.php b/src/Module/ThemeDetails.php index 5b931e117..82d2ff186 100644 --- a/src/Module/ThemeDetails.php +++ b/src/Module/ThemeDetails.php @@ -29,7 +29,7 @@ use Friendica\Core\Theme; */ class ThemeDetails extends BaseModule { - public function rawContent() + protected function rawContent(array $request = []) { if (!empty($_REQUEST['theme'])) { $theme = $_REQUEST['theme']; diff --git a/src/Module/ToggleMobile.php b/src/Module/ToggleMobile.php index a0fb2f88f..5817394ce 100644 --- a/src/Module/ToggleMobile.php +++ b/src/Module/ToggleMobile.php @@ -29,7 +29,7 @@ use Friendica\DI; */ class ToggleMobile extends BaseModule { - public function content(): string + protected function content(array $request = []): string { $a = DI::app(); diff --git a/src/Module/Tos.php b/src/Module/Tos.php index 1b7162753..78e4df69c 100644 --- a/src/Module/Tos.php +++ b/src/Module/Tos.php @@ -21,12 +21,14 @@ namespace Friendica\Module; -use Friendica\App\BaseURL; +use Friendica\App; use Friendica\BaseModule; use Friendica\Core\Config\Capability\IManageConfigValues; use Friendica\Core\L10n; use Friendica\Core\Renderer; use Friendica\Content\Text\BBCode; +use Friendica\Util\Profiler; +use Psr\Log\LoggerInterface; class Tos extends BaseModule { @@ -38,8 +40,6 @@ class Tos extends BaseModule /** @var IManageConfigValues */ protected $config; - /** @var BaseURL */ - protected $baseUrl; /** * constructor for the module, initializing the text variables @@ -48,12 +48,11 @@ class Tos extends BaseModule * be properties of the class, however cannot be set directly as the property * cannot depend on a function result when declaring the variable. **/ - public function __construct(IManageConfigValues $config, BaseURL $baseUrl, L10n $l10n, array $parameters = []) + public function __construct(L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, IManageConfigValues $config, array $server, array $parameters = []) { - parent::__construct($l10n, $parameters); + parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters); $this->config = $config; - $this->baseUrl = $baseUrl; $this->privacy_operate = $this->t('At the time of registration, and for providing communications between the user account and their contacts, the user has to provide a display name (pen name), an username (nickname) and a working email address. The names will be accessible on the profile page of the account by any visitor of the page, even if other profile details are not displayed. The email address will only be used to send the user notifications about interactions, but wont be visibly displayed. The listing of an account in the node\'s user directory or the global user directory is optional and can be controlled in the user settings, it is not necessary for communication.'); $this->privacy_distribute = $this->t('This data is required for communication and is passed on to the nodes of the communication partners and is stored there. Users can enter additional private data that may be transmitted to the communication partners accounts.'); @@ -76,7 +75,7 @@ class Tos extends BaseModule * @return string * @throws \Friendica\Network\HTTPException\InternalServerErrorException */ - public function content(): string + protected function content(array $request = []): string { if (strlen($this->config->get('system', 'singleuser'))) { $this->baseUrl->redirect('profile/' . $this->config->get('system', 'singleuser')); diff --git a/src/Module/Update/Community.php b/src/Module/Update/Community.php index 07ed5a610..9a1ffd771 100644 --- a/src/Module/Update/Community.php +++ b/src/Module/Update/Community.php @@ -33,7 +33,7 @@ use Friendica\Module\Conversation\Community as CommunityModule; */ class Community extends CommunityModule { - public function rawContent() + protected function rawContent(array $request = []) { $this->parseRequest(); diff --git a/src/Module/Update/Network.php b/src/Module/Update/Network.php index 3652b1126..073df2381 100644 --- a/src/Module/Update/Network.php +++ b/src/Module/Update/Network.php @@ -9,7 +9,7 @@ use Friendica\Module\Conversation\Network as NetworkModule; class Network extends NetworkModule { - public function rawContent() + protected function rawContent(array $request = []) { if (!isset($_GET['p']) || !isset($_GET['item'])) { exit(); diff --git a/src/Module/Update/Profile.php b/src/Module/Update/Profile.php index b06aea804..691d9d955 100644 --- a/src/Module/Update/Profile.php +++ b/src/Module/Update/Profile.php @@ -35,7 +35,7 @@ use Friendica\Util\DateTimeFormat; class Profile extends BaseModule { - public function rawContent() + protected function rawContent(array $request = []) { $a = DI::app(); @@ -93,7 +93,7 @@ class Profile extends BaseModule ); if (!DBA::isResult($items_stmt)) { - return ''; + return; } // Set a time stamp for this page. We will make use of it when we diff --git a/src/Module/Welcome.php b/src/Module/Welcome.php index 92845cdaf..9144541cb 100644 --- a/src/Module/Welcome.php +++ b/src/Module/Welcome.php @@ -30,7 +30,7 @@ use Friendica\DI; */ class Welcome extends BaseModule { - public function content(): string + protected function content(array $request = []): string { $config = DI::config(); diff --git a/src/Module/WellKnown/HostMeta.php b/src/Module/WellKnown/HostMeta.php index a65b4db1a..485004d70 100644 --- a/src/Module/WellKnown/HostMeta.php +++ b/src/Module/WellKnown/HostMeta.php @@ -33,7 +33,7 @@ use Friendica\Util\Crypto; */ class HostMeta extends BaseModule { - public function rawContent() + protected function rawContent(array $request = []) { $config = DI::config(); diff --git a/src/Module/WellKnown/NodeInfo.php b/src/Module/WellKnown/NodeInfo.php index a41979280..403c26f21 100644 --- a/src/Module/WellKnown/NodeInfo.php +++ b/src/Module/WellKnown/NodeInfo.php @@ -30,7 +30,7 @@ use Friendica\DI; */ class NodeInfo extends BaseModule { - public function rawContent() + protected function rawContent(array $request = []) { self::printWellKnown(); } diff --git a/src/Module/WellKnown/SecurityTxt.php b/src/Module/WellKnown/SecurityTxt.php index 73a627c2e..1455db130 100644 --- a/src/Module/WellKnown/SecurityTxt.php +++ b/src/Module/WellKnown/SecurityTxt.php @@ -29,7 +29,7 @@ use Friendica\BaseModule; */ class SecurityTxt extends BaseModule { - public function rawContent() + protected function rawContent(array $request = []) { $name = 'security.txt'; $fp = fopen($name, 'rt'); diff --git a/src/Module/WellKnown/XSocialRelay.php b/src/Module/WellKnown/XSocialRelay.php index c40182523..dc29f089a 100644 --- a/src/Module/WellKnown/XSocialRelay.php +++ b/src/Module/WellKnown/XSocialRelay.php @@ -32,7 +32,7 @@ use Friendica\Protocol\Relay; */ class XSocialRelay extends BaseModule { - public function rawContent() + protected function rawContent(array $request = []) { $config = DI::config(); diff --git a/src/Module/Xrd.php b/src/Module/Xrd.php index 4a8e32e8e..5d3205b7a 100644 --- a/src/Module/Xrd.php +++ b/src/Module/Xrd.php @@ -36,7 +36,7 @@ use Friendica\Protocol\Salmon; */ class Xrd extends BaseModule { - public function rawContent() + protected function rawContent(array $request = []) { // @TODO: Replace with parameter from router if (DI::args()->getArgv()[0] == 'xrd') { diff --git a/src/Security/Authentication.php b/src/Security/Authentication.php index 0b2fc9f9c..736f6b3b1 100644 --- a/src/Security/Authentication.php +++ b/src/Security/Authentication.php @@ -369,7 +369,7 @@ class Authentication if ($login_initial) { Hook::callAll('logged_in', $user_record); - if (DI::module()->getName() !== 'home' && $this->session->exists('return_path')) { + if (DI::args()->getModuleName() !== 'home' && $this->session->exists('return_path')) { $this->baseUrl->redirect($this->session->get('return_path')); } } diff --git a/static/dependencies.config.php b/static/dependencies.config.php index 28d26b4e7..fe1b486d5 100644 --- a/static/dependencies.config.php +++ b/static/dependencies.config.php @@ -181,12 +181,6 @@ return [ ['determine', [$_SERVER, $_GET], Dice::CHAIN_CALL], ], ], - App\ModuleController::class => [ - 'instanceOf' => App\ModuleController::class, - 'call' => [ - ['determineName', [], Dice::CHAIN_CALL], - ], - ], \Friendica\Core\System::class => [ 'constructParams' => [ [Dice::INSTANCE => '$basepath'], @@ -196,6 +190,7 @@ return [ 'constructParams' => [ $_SERVER, __DIR__ . '/routes.config.php', + [Dice::INSTANCE => Dice::SELF], null ], ], diff --git a/tests/Util/ApiResponseDouble.php b/tests/Util/ApiResponseDouble.php deleted file mode 100644 index cc1402c7a..000000000 --- a/tests/Util/ApiResponseDouble.php +++ /dev/null @@ -1,73 +0,0 @@ -. - * - */ - -namespace Friendica\Test\Util; - -use Friendica\Module\Api\ApiResponse; - -class ApiResponseDouble extends ApiResponse -{ - /** - * The header list - * - * @var string[] - */ - protected static $header = []; - - /** - * The printed output - * - * @var string - */ - protected static $output = ''; - - /** - * @return string[] - */ - public static function getHeader(): array - { - return static::$header; - } - - /** - * @return string - */ - public static function getOutput(): string - { - return static::$output; - } - - public static function reset() - { - self::$output = ''; - self::$header = []; - } - - protected function setHeader(string $header) - { - static::$header[] = $header; - } - - protected function printOutput(string $output) - { - static::$output .= $output; - } -} diff --git a/tests/src/App/ModeTest.php b/tests/src/App/ModeTest.php index 80e45d308..1dc08aff8 100644 --- a/tests/src/App/ModeTest.php +++ b/tests/src/App/ModeTest.php @@ -22,8 +22,8 @@ namespace Friendica\Test\src\App; use Detection\MobileDetect; +use Friendica\App\Arguments; use Friendica\App\Mode; -use Friendica\App\ModuleController; use Friendica\Core\Config\ValueObject\Cache; use Friendica\Database\Database; use Friendica\Test\MockedTest; @@ -204,10 +204,10 @@ class ModeTest extends MockedTest public function testIsBackendNotIsBackend() { $server = []; - $module = new ModuleController(); + $args = new Arguments(); $mobileDetect = new MobileDetect(); - $mode = (new Mode())->determineRunMode(true, $module, $server, $mobileDetect); + $mode = (new Mode())->determineRunMode(true, $server, $args, $mobileDetect); self::assertTrue($mode->isBackend()); } @@ -218,10 +218,10 @@ class ModeTest extends MockedTest public function testIsBackendButIndex() { $server = []; - $module = new ModuleController(ModuleController::DEFAULT, null, true); + $args = new Arguments('', '', Mode::BACKEND_MODULES[0]); $mobileDetect = new MobileDetect(); - $mode = (new Mode())->determineRunMode(false, $module, $server, $mobileDetect); + $mode = (new Mode())->determineRunMode(false, $server, $args, $mobileDetect); self::assertTrue($mode->isBackend()); } @@ -232,10 +232,10 @@ class ModeTest extends MockedTest public function testIsNotBackend() { $server = []; - $module = new ModuleController(ModuleController::DEFAULT, null, false); + $args = new Arguments('', '', Arguments::DEFAULT_MODULE); $mobileDetect = new MobileDetect(); - $mode = (new Mode())->determineRunMode(false, $module, $server, $mobileDetect); + $mode = (new Mode())->determineRunMode(false, $server, $args, $mobileDetect); self::assertFalse($mode->isBackend()); } @@ -250,10 +250,10 @@ class ModeTest extends MockedTest 'HTTP_X_REQUESTED_WITH' => 'xmlhttprequest', ]; - $module = new ModuleController(ModuleController::DEFAULT, null, false); + $args = new Arguments('', '', Arguments::DEFAULT_MODULE); $mobileDetect = new MobileDetect(); - $mode = (new Mode())->determineRunMode(true, $module, $server, $mobileDetect); + $mode = (new Mode())->determineRunMode(true, $server, $args, $mobileDetect); self::assertTrue($mode->isAjax()); } @@ -264,10 +264,10 @@ class ModeTest extends MockedTest public function testIsNotAjax() { $server = []; - $module = new ModuleController(ModuleController::DEFAULT, null, false); + $args = new Arguments('', '', Arguments::DEFAULT_MODULE); $mobileDetect = new MobileDetect(); - $mode = (new Mode())->determineRunMode(true, $module, $server, $mobileDetect); + $mode = (new Mode())->determineRunMode(true, $server, $args, $mobileDetect); self::assertFalse($mode->isAjax()); } @@ -278,12 +278,12 @@ class ModeTest extends MockedTest public function testIsMobileIsTablet() { $server = []; - $module = new ModuleController(ModuleController::DEFAULT, null, false); + $args = new Arguments('', '', Arguments::DEFAULT_MODULE); $mobileDetect = Mockery::mock(MobileDetect::class); $mobileDetect->shouldReceive('isMobile')->andReturn(true); $mobileDetect->shouldReceive('isTablet')->andReturn(true); - $mode = (new Mode())->determineRunMode(true, $module, $server, $mobileDetect); + $mode = (new Mode())->determineRunMode(true, $server, $args, $mobileDetect); self::assertTrue($mode->isMobile()); self::assertTrue($mode->isTablet()); @@ -296,12 +296,12 @@ class ModeTest extends MockedTest public function testIsNotMobileIsNotTablet() { $server = []; - $module = new ModuleController(ModuleController::DEFAULT, null, false); + $args = new Arguments('', '', Arguments::DEFAULT_MODULE); $mobileDetect = Mockery::mock(MobileDetect::class); $mobileDetect->shouldReceive('isMobile')->andReturn(false); $mobileDetect->shouldReceive('isTablet')->andReturn(false); - $mode = (new Mode())->determineRunMode(true, $module, $server, $mobileDetect); + $mode = (new Mode())->determineRunMode(true, $server, $args, $mobileDetect); self::assertFalse($mode->isMobile()); self::assertFalse($mode->isTablet()); diff --git a/tests/src/App/ModuleControllerTest.php b/tests/src/App/ModuleControllerTest.php deleted file mode 100644 index 4e3983add..000000000 --- a/tests/src/App/ModuleControllerTest.php +++ /dev/null @@ -1,219 +0,0 @@ -. - * - */ - -namespace Friendica\Test\src\App; - -use Dice\Dice; -use Friendica\App; -use Friendica\Core\Cache\Capability\ICanCache; -use Friendica\Core\Config\Capability\IManageConfigValues; -use Friendica\Core\L10n; -use Friendica\Core\Lock\Capability\ICanLock; -use Friendica\LegacyModule; -use Friendica\Module\HTTPException\PageNotFound; -use Friendica\Module\WellKnown\HostMeta; -use Friendica\Test\DatabaseTest; -use Mockery; - -class ModuleControllerTest extends DatabaseTest -{ - private function assertModule(array $assert, App\ModuleController $module) - { - self::assertEquals($assert['isBackend'], $module->isBackend()); - self::assertEquals($assert['name'], $module->getName()); - self::assertEquals($assert['class'], $module->getModule()); - } - - /** - * Test the default module mode - */ - public function testDefault() - { - $module = new App\ModuleController(); - - $defaultClass = App\ModuleController::DEFAULT_CLASS; - - self::assertModule([ - 'isBackend' => false, - 'name' => App\ModuleController::DEFAULT, - 'class' => null, - ], $module); - } - - public function dataModuleName() - { - $defaultClass = App\ModuleController::DEFAULT_CLASS; - - return [ - 'default' => [ - 'assert' => [ - 'isBackend' => false, - 'name' => 'network', - 'class' => new $defaultClass(), - ], - 'args' => new App\Arguments('network/data/in', - 'network/data/in', - ['network', 'data', 'in'], - 3), - ], - 'withStrikeAndPoint' => [ - 'assert' => [ - 'isBackend' => false, - 'name' => 'with_strike_and_point', - 'class' => new $defaultClass(), - ], - 'args' => new App\Arguments('with-strike.and-point/data/in', - 'with-strike.and-point/data/in', - ['with-strike.and-point', 'data', 'in'], - 3), - ], - 'withNothing' => [ - 'assert' => [ - 'isBackend' => false, - 'name' => App\ModuleController::DEFAULT, - 'class' => new $defaultClass(), - ], - 'args' => new App\Arguments(), - ], - 'withIndex' => [ - 'assert' => [ - 'isBackend' => false, - 'name' => App\ModuleController::DEFAULT, - 'class' => new $defaultClass(), - ], - 'args' => new App\Arguments(), - ], - 'withBackendMod' => [ - 'assert' => [ - 'isBackend' => true, - 'name' => App\ModuleController::BACKEND_MODULES[0], - 'class' => new $defaultClass(), - ], - 'args' => new App\Arguments(App\ModuleController::BACKEND_MODULES[0] . '/data/in', - App\ModuleController::BACKEND_MODULES[0] . '/data/in', - [App\ModuleController::BACKEND_MODULES[0], 'data', 'in'], - 3), - ], - 'withFirefoxApp' => [ - 'assert' => [ - 'isBackend' => false, - 'name' => 'login', - 'class' => new $defaultClass(), - ], - 'args' => new App\Arguments('users/sign_in', - 'users/sign_in', - ['users', 'sign_in'], - 3), - ], - ]; - } - - /** - * Test the module name and backend determination - * - * @dataProvider dataModuleName - */ - public function testModuleName(array $assert, App\Arguments $args) - { - $module = (new App\ModuleController())->determineName($args); - - self::assertModule($assert, $module); - } - - public function dataModuleClass() - { - return [ - 'default' => [ - 'assert' => App\ModuleController::DEFAULT_CLASS, - 'name' => App\ModuleController::DEFAULT, - 'command' => App\ModuleController::DEFAULT, - 'privAdd' => false, - 'args' => [Mockery::mock(L10n::class)], - ], - 'legacy' => [ - 'assert' => LegacyModule::class, - 'name' => 'display', - 'command' => 'display/test/it', - 'privAdd' => false, - 'args' => [Mockery::mock(L10n::class), __DIR__ . '/../../datasets/legacy/legacy.php'], - ], - 'new' => [ - 'assert' => HostMeta::class, - 'not_required', - 'command' => '.well-known/host-meta', - 'privAdd' => false, - 'args' => [Mockery::mock(L10n::class)], - ], - '404' => [ - 'assert' => PageNotFound::class, - 'name' => 'invalid', - 'command' => 'invalid', - 'privAdd' => false, - 'args' => [Mockery::mock(L10n::class)], - ] - ]; - } - - /** - * Test the determination of the module class - * - * @dataProvider dataModuleClass - */ - public function testModuleClass($assert, string $name, string $command, bool $privAdd, array $args) - { - $config = Mockery::mock(IManageConfigValues::class); - $config->shouldReceive('get')->with('config', 'private_addons', false)->andReturn($privAdd)->atMost()->once(); - - $l10n = Mockery::mock(L10n::class); - $l10n->shouldReceive('t')->andReturnUsing(function ($args) { return $args; }); - - $cache = Mockery::mock(ICanCache::class); - $cache->shouldReceive('get')->with('routerDispatchData')->andReturn('')->atMost()->once(); - $cache->shouldReceive('get')->with('lastRoutesFileModifiedTime')->andReturn('')->atMost()->once(); - $cache->shouldReceive('set')->withAnyArgs()->andReturn(false)->atMost()->twice(); - - $lock = Mockery::mock(ICanLock::class); - $lock->shouldReceive('acquire')->andReturn(true); - $lock->shouldReceive('isLocked')->andReturn(false); - - $router = (new App\Router([], __DIR__ . '/../../../static/routes.config.php', $l10n, $cache, $lock)); - - $dice = Mockery::mock(Dice::class); - - $dice->shouldReceive('create')->andReturn(new $assert(...$args)); - - $module = (new App\ModuleController($name))->determineClass(new App\Arguments('', $command), $router, $config, $dice); - - self::assertEquals($assert, $module->getModule()->getClassName()); - } - - /** - * Test that modules are immutable - */ - public function testImmutable() - { - $module = new App\ModuleController(); - - $moduleNew = $module->determineName(new App\Arguments()); - - self::assertNotSame($moduleNew, $module); - } -} diff --git a/tests/src/App/RouterTest.php b/tests/src/App/RouterTest.php index f74ea423f..374094517 100644 --- a/tests/src/App/RouterTest.php +++ b/tests/src/App/RouterTest.php @@ -21,13 +21,12 @@ namespace Friendica\Test\src\App; -use Friendica\App\Router; +use Dice\Dice; +use Friendica\App\Arguments; use Friendica\Core\Cache\Capability\ICanCache; +use Friendica\Core\Config\Capability\IManageConfigValues; use Friendica\Core\L10n; use Friendica\Core\Lock\Capability\ICanLock; -use Friendica\Module; -use Friendica\Network\HTTPException\MethodNotAllowedException; -use Friendica\Network\HTTPException\NotFoundException; use Mockery; use Mockery\MockInterface; use PHPUnit\Framework\TestCase; @@ -44,11 +43,26 @@ class RouterTest extends TestCase * @var ICanLock */ private $lock; + /** + * @var IManageConfigValues + */ + private $config; + /** + * @var Dice + */ + private $dice; + /** + * @var Arguments + */ + private $arguments; - protected function setUp() : void + protected function setUp(): void { parent::setUp(); + self::markTestIncomplete('Router tests need refactoring!'); + + /* $this->l10n = Mockery::mock(L10n::class); $this->l10n->shouldReceive('t')->andReturnUsing(function ($args) { return $args; }); @@ -59,180 +73,17 @@ class RouterTest extends TestCase $this->lock = Mockery::mock(ICanLock::class); $this->lock->shouldReceive('acquire')->andReturn(true); $this->lock->shouldReceive('isLocked')->andReturn(false); + + $this->config = Mockery::mock(IManageConfigValues::class); + + $this->dice = new Dice(); + + $this->arguments = Mockery::mock(Arguments::class); + */ } - public function testGetModuleClass() + public function test() { - $router = new Router(['REQUEST_METHOD' => Router::GET], '', $this->l10n, $this->cache, $this->lock); - $routeCollector = $router->getRouteCollector(); - $routeCollector->addRoute([Router::GET], '/', 'IndexModuleClassName'); - $routeCollector->addRoute([Router::GET], '/test', 'TestModuleClassName'); - $routeCollector->addRoute([Router::GET, Router::POST], '/testgetpost', 'TestGetPostModuleClassName'); - $routeCollector->addRoute([Router::GET], '/test/sub', 'TestSubModuleClassName'); - $routeCollector->addRoute([Router::GET], '/optional[/option]', 'OptionalModuleClassName'); - $routeCollector->addRoute([Router::GET], '/variable/{var}', 'VariableModuleClassName'); - $routeCollector->addRoute([Router::GET], '/optionalvariable[/{option}]', 'OptionalVariableModuleClassName'); - - self::assertEquals('IndexModuleClassName', $router->getModuleClass('/')); - self::assertEquals('TestModuleClassName', $router->getModuleClass('/test')); - self::assertEquals('TestGetPostModuleClassName', $router->getModuleClass('/testgetpost')); - self::assertEquals('TestSubModuleClassName', $router->getModuleClass('/test/sub')); - self::assertEquals('OptionalModuleClassName', $router->getModuleClass('/optional')); - self::assertEquals('OptionalModuleClassName', $router->getModuleClass('/optional/option')); - self::assertEquals('VariableModuleClassName', $router->getModuleClass('/variable/123abc')); - self::assertEquals('OptionalVariableModuleClassName', $router->getModuleClass('/optionalvariable')); - self::assertEquals('OptionalVariableModuleClassName', $router->getModuleClass('/optionalvariable/123abc')); - } - - public function testPostModuleClass() - { - $router = new Router(['REQUEST_METHOD' => Router::POST], '', $this->l10n, $this->cache, $this->lock); - - $routeCollector = $router->getRouteCollector(); - $routeCollector->addRoute([Router::POST], '/', 'IndexModuleClassName'); - $routeCollector->addRoute([Router::POST], '/test', 'TestModuleClassName'); - $routeCollector->addRoute([Router::GET, Router::POST], '/testgetpost', 'TestGetPostModuleClassName'); - $routeCollector->addRoute([Router::POST], '/test/sub', 'TestSubModuleClassName'); - $routeCollector->addRoute([Router::POST], '/optional[/option]', 'OptionalModuleClassName'); - $routeCollector->addRoute([Router::POST], '/variable/{var}', 'VariableModuleClassName'); - $routeCollector->addRoute([Router::POST], '/optionalvariable[/{option}]', 'OptionalVariableModuleClassName'); - - self::assertEquals('IndexModuleClassName', $router->getModuleClass('/')); - self::assertEquals('TestModuleClassName', $router->getModuleClass('/test')); - self::assertEquals('TestGetPostModuleClassName', $router->getModuleClass('/testgetpost')); - self::assertEquals('TestSubModuleClassName', $router->getModuleClass('/test/sub')); - self::assertEquals('OptionalModuleClassName', $router->getModuleClass('/optional')); - self::assertEquals('OptionalModuleClassName', $router->getModuleClass('/optional/option')); - self::assertEquals('VariableModuleClassName', $router->getModuleClass('/variable/123abc')); - self::assertEquals('OptionalVariableModuleClassName', $router->getModuleClass('/optionalvariable')); - self::assertEquals('OptionalVariableModuleClassName', $router->getModuleClass('/optionalvariable/123abc')); - } - - public function testGetModuleClassNotFound() - { - $this->expectException(NotFoundException::class); - - $router = new Router(['REQUEST_METHOD' => Router::GET], '', $this->l10n, $this->cache, $this->lock); - - $router->getModuleClass('/unsupported'); - } - - public function testGetModuleClassNotFoundTypo() - { - $this->expectException(NotFoundException::class); - - $router = new Router(['REQUEST_METHOD' => Router::GET], '', $this->l10n, $this->cache, $this->lock); - - $routeCollector = $router->getRouteCollector(); - $routeCollector->addRoute([Router::GET], '/test', 'TestModuleClassName'); - - $router->getModuleClass('/tes'); - } - - public function testGetModuleClassNotFoundOptional() - { - $this->expectException(NotFoundException::class); - - $router = new Router(['REQUEST_METHOD' => Router::GET], '', $this->l10n, $this->cache, $this->lock); - - $routeCollector = $router->getRouteCollector(); - $routeCollector->addRoute([Router::GET], '/optional[/option]', 'OptionalModuleClassName'); - - $router->getModuleClass('/optional/opt'); - } - - public function testGetModuleClassNotFoundVariable() - { - $this->expectException(NotFoundException::class); - - $router = new Router(['REQUEST_METHOD' => Router::GET], '', $this->l10n, $this->cache, $this->lock); - - $routeCollector = $router->getRouteCollector(); - $routeCollector->addRoute([Router::GET], '/variable/{var}', 'VariableModuleClassName'); - - $router->getModuleClass('/variable'); - } - - public function testGetModuleClassMethodNotAllowed() - { - $this->expectException(MethodNotAllowedException::class); - - $router = new Router(['REQUEST_METHOD' => Router::POST], '', $this->l10n, $this->cache, $this->lock); - - $routeCollector = $router->getRouteCollector(); - $routeCollector->addRoute([Router::GET], '/test', 'TestModuleClassName'); - - $router->getModuleClass('/test'); - } - - public function testPostModuleClassMethodNotAllowed() - { - $this->expectException(MethodNotAllowedException::class); - - $router = new Router(['REQUEST_METHOD' => Router::GET], '', $this->l10n, $this->cache, $this->lock); - - $routeCollector = $router->getRouteCollector(); - $routeCollector->addRoute([Router::POST], '/test', 'TestModuleClassName'); - - $router->getModuleClass('/test'); - } - - public function dataRoutes() - { - return [ - 'default' => [ - 'routes' => [ - '/' => [Module\Home::class, [Router::GET]], - '/group' => [ - '/route' => [Module\Friendica::class, [Router::GET]], - ], - - - '/group2' => [ - '/group3' => [ - '/route' => [Module\Xrd::class, [Router::GET]], - ], - ], - '/post' => [ - '/it' => [Module\WellKnown\NodeInfo::class, [Router::POST]], - ], - '/double' => [Module\Profile\Index::class, [Router::GET, Router::POST]] - ], - ], - ]; - } - - /** - * @dataProvider dataRoutes - */ - public function testGetRoutes(array $routes) - { - $router = (new Router( - ['REQUEST_METHOD' => Router::GET], - '', - $this->l10n, - $this->cache, - $this->lock - ))->loadRoutes($routes); - - self::assertEquals(Module\Home::class, $router->getModuleClass('/')); - self::assertEquals(Module\Friendica::class, $router->getModuleClass('/group/route')); - self::assertEquals(Module\Xrd::class, $router->getModuleClass('/group2/group3/route')); - self::assertEquals(Module\Profile\Index::class, $router->getModuleClass('/double')); - } - - /** - * @dataProvider dataRoutes - */ - public function testPostRouter(array $routes) - { - $router = (new Router([ - 'REQUEST_METHOD' => Router::POST - ], '', $this->l10n, $this->cache, $this->lock))->loadRoutes($routes); - - // Don't find GET - self::assertEquals(Module\WellKnown\NodeInfo::class, $router->getModuleClass('/post/it')); - self::assertEquals(Module\Profile\Index::class, $router->getModuleClass('/double')); } } diff --git a/tests/src/Module/Api/ApiResponseTest.php b/tests/src/Module/Api/ApiResponseTest.php index 524c9ebd1..99e3a8d5d 100644 --- a/tests/src/Module/Api/ApiResponseTest.php +++ b/tests/src/Module/Api/ApiResponseTest.php @@ -6,19 +6,12 @@ use Friendica\App\Arguments; use Friendica\App\BaseURL; use Friendica\Core\L10n; use Friendica\Factory\Api\Twitter\User; +use Friendica\Module\Api\ApiResponse; use Friendica\Test\MockedTest; -use Friendica\Test\Util\ApiResponseDouble; use Psr\Log\NullLogger; class ApiResponseTest extends MockedTest { - protected function tearDown(): void - { - ApiResponseDouble::reset(); - - parent::tearDown(); - } - public function testErrorWithJson() { $l10n = \Mockery::mock(L10n::class); @@ -27,10 +20,10 @@ class ApiResponseTest extends MockedTest $baseUrl = \Mockery::mock(BaseURL::class); $twitterUser = \Mockery::mock(User::class); - $response = new ApiResponseDouble($l10n, $args, new NullLogger(), $baseUrl, $twitterUser); + $response = new ApiResponse($l10n, $args, new NullLogger(), $baseUrl, $twitterUser); $response->error(200, 'OK', 'error_message', 'json'); - self::assertEquals('{"error":"error_message","code":"200 OK","request":""}', ApiResponseDouble::getOutput()); + self::assertEquals('{"error":"error_message","code":"200 OK","request":""}', $response->getContent()); } public function testErrorWithXml() @@ -41,9 +34,10 @@ class ApiResponseTest extends MockedTest $baseUrl = \Mockery::mock(BaseURL::class); $twitterUser = \Mockery::mock(User::class); - $response = new ApiResponseDouble($l10n, $args, new NullLogger(), $baseUrl, $twitterUser); + $response = new ApiResponse($l10n, $args, new NullLogger(), $baseUrl, $twitterUser); $response->error(200, 'OK', 'error_message', 'xml'); + self::assertEquals(['Content-type' => 'text/xml', 'HTTP/1.1 200 OK'], $response->getHeaders()); self::assertEquals('' . "\n" . '200 OK' . "\n" . ' ' . "\n" . '' . "\n", - ApiResponseDouble::getOutput()); + $response->getContent()); } public function testErrorWithRss() @@ -63,9 +57,10 @@ class ApiResponseTest extends MockedTest $baseUrl = \Mockery::mock(BaseURL::class); $twitterUser = \Mockery::mock(User::class); - $response = new ApiResponseDouble($l10n, $args, new NullLogger(), $baseUrl, $twitterUser); + $response = new ApiResponse($l10n, $args, new NullLogger(), $baseUrl, $twitterUser); $response->error(200, 'OK', 'error_message', 'rss'); + self::assertEquals(['Content-type' => 'application/rss+xml', 'HTTP/1.1 200 OK'], $response->getHeaders()); self::assertEquals( '' . "\n" . '200 OK' . "\n" . ' ' . "\n" . '' . "\n", - ApiResponseDouble::getOutput()); + $response->getContent()); } public function testErrorWithAtom() @@ -86,9 +81,10 @@ class ApiResponseTest extends MockedTest $baseUrl = \Mockery::mock(BaseURL::class); $twitterUser = \Mockery::mock(User::class); - $response = new ApiResponseDouble($l10n, $args, new NullLogger(), $baseUrl, $twitterUser); + $response = new ApiResponse($l10n, $args, new NullLogger(), $baseUrl, $twitterUser); $response->error(200, 'OK', 'error_message', 'atom'); + self::assertEquals(['Content-type' => 'application/atom+xml', 'HTTP/1.1 200 OK'], $response->getHeaders()); self::assertEquals( '' . "\n" . '200 OK' . "\n" . ' ' . "\n" . '' . "\n", - ApiResponseDouble::getOutput()); + $response->getContent()); } public function testUnsupported() @@ -112,9 +108,9 @@ class ApiResponseTest extends MockedTest $baseUrl = \Mockery::mock(BaseURL::class); $twitterUser = \Mockery::mock(User::class); - $response = new ApiResponseDouble($l10n, $args, new NullLogger(), $baseUrl, $twitterUser); + $response = new ApiResponse($l10n, $args, new NullLogger(), $baseUrl, $twitterUser); $response->unsupported(); - self::assertEquals('{"error":"API endpoint %s %s is not implemented","error_description":"The API endpoint is currently not implemented but might be in the future."}', ApiResponseDouble::getOutput()); + self::assertEquals('{"error":"API endpoint %s %s is not implemented","error_description":"The API endpoint is currently not implemented but might be in the future."}', $response->getContent()); } } diff --git a/tests/src/Module/Api/ApiTest.php b/tests/src/Module/Api/ApiTest.php index e168c2655..c530ace2e 100644 --- a/tests/src/Module/Api/ApiTest.php +++ b/tests/src/Module/Api/ApiTest.php @@ -25,10 +25,8 @@ use Friendica\Core\Addon; use Friendica\Core\Hook; use Friendica\Database\Database; use Friendica\DI; -use Friendica\Module\Api\ApiResponse; use Friendica\Security\Authentication; use Friendica\Test\FixtureTest; -use Friendica\Test\Util\ApiResponseDouble; use Friendica\Test\Util\AuthenticationDouble; abstract class ApiTest extends FixtureTest @@ -53,20 +51,12 @@ abstract class ApiTest extends FixtureTest parent::setUp(); // TODO: Change the autogenerated stub $this->dice = $this->dice - ->addRule(Authentication::class, ['instanceOf' => AuthenticationDouble::class, 'shared' => true]) - ->addRule(ApiResponse::class, ['instanceOf' => ApiResponseDouble::class, 'shared' => true]); + ->addRule(Authentication::class, ['instanceOf' => AuthenticationDouble::class, 'shared' => true]); DI::init($this->dice); $this->installAuthTest(); } - protected function tearDown(): void - { - ApiResponseDouble::reset(); - - parent::tearDown(); - } - /** * installs auththest. * diff --git a/tests/src/Module/Api/Friendica/NotificationTest.php b/tests/src/Module/Api/Friendica/NotificationTest.php index 125e7d63d..ef93de3ef 100644 --- a/tests/src/Module/Api/Friendica/NotificationTest.php +++ b/tests/src/Module/Api/Friendica/NotificationTest.php @@ -21,11 +21,10 @@ namespace Friendica\Test\src\Module\Api\Friendica; +use Friendica\Capabilities\ICanCreateResponses; use Friendica\DI; use Friendica\Module\Api\Friendica\Notification; -use Friendica\Network\HTTPException\BadRequestException; use Friendica\Test\src\Module\Api\ApiTest; -use Friendica\Test\Util\ApiResponseDouble; use Friendica\Util\DateTimeFormat; use Friendica\Util\Temporal; @@ -67,19 +66,21 @@ class NotificationTest extends ApiTest XML; - $notification = new Notification(DI::l10n(), ['extension' => 'xml']); - $notification->rawContent(); + $notification = new Notification(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [], ['extension' => 'xml']); + $response = $notification->run(); - self::assertXmlStringEqualsXmlString($assertXml, ApiResponseDouble::getOutput()); + print_r($response->getHeaders()); + + self::assertXmlStringEqualsXmlString($assertXml, (string)$response->getBody()); + self::assertEquals(['Content-type' => ['text/xml'], ICanCreateResponses::X_HEADER => ['xml']], $response->getHeaders()); } public function testWithJsonResult() { - $notification = new Notification(DI::l10n(),['parameter' => 'json']); - $notification->rawContent(); + $notification = new Notification(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [], ['extension' => 'json']); + $response = $notification->run(); - $result = json_encode(ApiResponseDouble::getOutput()); - - self::assertJson($result); + self::assertJson($response->getBody()); + self::assertEquals(['Content-type' => ['application/json'], ICanCreateResponses::X_HEADER => ['json']], $response->getHeaders()); } } diff --git a/tests/src/Module/Api/Friendica/Photo/DeleteTest.php b/tests/src/Module/Api/Friendica/Photo/DeleteTest.php index 095811011..42e3f77c0 100644 --- a/tests/src/Module/Api/Friendica/Photo/DeleteTest.php +++ b/tests/src/Module/Api/Friendica/Photo/DeleteTest.php @@ -31,7 +31,7 @@ class DeleteTest extends ApiTest public function testEmpty() { $this->expectException(BadRequestException::class); - (new Delete(DI::l10n()))->rawContent(); + (new Delete(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), []))->run(); } public function testWithoutAuthenticatedUser() @@ -42,7 +42,7 @@ class DeleteTest extends ApiTest public function testWrong() { $this->expectException(BadRequestException::class); - (new Delete(DI::l10n(), ['photo_id' => 1]))->rawContent(); + (new Delete(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), []))->run(['photo_id' => 1]); } public function testWithCorrectPhotoId() diff --git a/tests/src/Module/Api/Friendica/Photoalbum/DeleteTest.php b/tests/src/Module/Api/Friendica/Photoalbum/DeleteTest.php index aabd7e581..118257c55 100644 --- a/tests/src/Module/Api/Friendica/Photoalbum/DeleteTest.php +++ b/tests/src/Module/Api/Friendica/Photoalbum/DeleteTest.php @@ -31,13 +31,14 @@ class DeleteTest extends ApiTest public function testEmpty() { $this->expectException(BadRequestException::class); - (new Delete(DI::l10n()))->rawContent(); + (new Delete(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), []))->run(); + } public function testWrong() { $this->expectException(BadRequestException::class); - (new Delete(DI::l10n(), ['album' => 'album_name']))->rawContent(); + (new Delete(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), []))->run(['album' => 'album_name']); } public function testValid() diff --git a/tests/src/Module/Api/Friendica/Photoalbum/UpdateTest.php b/tests/src/Module/Api/Friendica/Photoalbum/UpdateTest.php index 51414302f..464845745 100644 --- a/tests/src/Module/Api/Friendica/Photoalbum/UpdateTest.php +++ b/tests/src/Module/Api/Friendica/Photoalbum/UpdateTest.php @@ -31,19 +31,19 @@ class UpdateTest extends ApiTest public function testEmpty() { $this->expectException(BadRequestException::class); - (new Update(DI::l10n()))->rawContent(); + (new Update(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), []))->run(); } public function testTooFewArgs() { $this->expectException(BadRequestException::class); - (new Update(DI::l10n(), ['album' => 'album_name']))->rawContent(); + (new Update(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), []))->run(['album' => 'album_name']); } public function testWrongUpdate() { $this->expectException(BadRequestException::class); - (new Update(DI::l10n(), ['album' => 'album_name', 'album_new' => 'album_name']))->rawContent(); + (new Update(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), []))->run(['album' => 'album_name', 'album_new' => 'album_name']); } public function testWithoutAuthenticatedUser() diff --git a/tests/src/Module/Api/GnuSocial/GnuSocial/VersionTest.php b/tests/src/Module/Api/GnuSocial/GnuSocial/VersionTest.php index 448f6ce14..0f6531831 100644 --- a/tests/src/Module/Api/GnuSocial/GnuSocial/VersionTest.php +++ b/tests/src/Module/Api/GnuSocial/GnuSocial/VersionTest.php @@ -2,20 +2,19 @@ namespace Friendica\Test\src\Module\Api\GnuSocial\GnuSocial; +use Friendica\Capabilities\ICanCreateResponses; use Friendica\DI; use Friendica\Module\Api\GNUSocial\GNUSocial\Version; use Friendica\Test\src\Module\Api\ApiTest; -use Friendica\Test\Util\ApiResponseDouble; class VersionTest extends ApiTest { public function test() { - $version = new Version(DI::l10n(), ['extension' => 'json']); - $version->rawContent(); + $version = new Version(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [], ['extension' => 'json']); + $response = $version->run(); - $result = json_decode(ApiResponseDouble::getOutput()); - - self::assertEquals('0.9.7', $result); + self::assertEquals(['Content-type' => ['application/json'], ICanCreateResponses::X_HEADER => ['json']], $response->getHeaders()); + self::assertEquals('"0.9.7"', $response->getBody()); } } diff --git a/tests/src/Module/Api/GnuSocial/Help/TestTest.php b/tests/src/Module/Api/GnuSocial/Help/TestTest.php index 40d8e9750..5aa428681 100644 --- a/tests/src/Module/Api/GnuSocial/Help/TestTest.php +++ b/tests/src/Module/Api/GnuSocial/Help/TestTest.php @@ -2,26 +2,28 @@ namespace Friendica\Test\src\Module\Api\GnuSocial\Help; +use Friendica\Capabilities\ICanCreateResponses; use Friendica\DI; use Friendica\Module\Api\GNUSocial\Help\Test; use Friendica\Test\src\Module\Api\ApiTest; -use Friendica\Test\Util\ApiResponseDouble; class TestTest extends ApiTest { public function testJson() { - $test = new Test(DI::l10n(), ['extension' => 'json']); - $test->rawContent(); + $test = new Test(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [], ['extension' => 'json']); + $response = $test->run(); - self::assertEquals('"ok"', ApiResponseDouble::getOutput()); + self::assertEquals(['Content-type' => ['application/json'], ICanCreateResponses::X_HEADER => ['json']], $response->getHeaders()); + self::assertEquals('"ok"', $response->getBody()); } public function testXml() { - $test = new Test(DI::l10n(), ['extension' => 'xml']); - $test->rawContent(); + $test = new Test(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [], ['extension' => 'xml']); + $response = $test->run(); - self::assertxml(ApiResponseDouble::getOutput(), 'ok'); + self::assertEquals(['Content-type' => ['text/xml'], ICanCreateResponses::X_HEADER => ['xml']], $response->getHeaders()); + self::assertxml($response->getBody(), 'ok'); } } diff --git a/tests/src/Module/Api/Twitter/Account/RateLimitStatusTest.php b/tests/src/Module/Api/Twitter/Account/RateLimitStatusTest.php index 93d76933b..64becb75c 100644 --- a/tests/src/Module/Api/Twitter/Account/RateLimitStatusTest.php +++ b/tests/src/Module/Api/Twitter/Account/RateLimitStatusTest.php @@ -2,20 +2,21 @@ namespace Friendica\Test\src\Module\Api\Twitter\Account; +use Friendica\Capabilities\ICanCreateResponses; use Friendica\DI; use Friendica\Module\Api\Twitter\Account\RateLimitStatus; use Friendica\Test\src\Module\Api\ApiTest; -use Friendica\Test\Util\ApiResponseDouble; class RateLimitStatusTest extends ApiTest { public function testWithJson() { - $rateLimitStatus = new RateLimitStatus(DI::l10n(), ['extension' => 'json']); - $rateLimitStatus->rawContent(); + $rateLimitStatus = new RateLimitStatus(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [], ['extension' => 'json']); + $response = $rateLimitStatus->run(); - $result = json_decode(ApiResponseDouble::getOutput()); + $result = json_decode($response->getBody()); + self::assertEquals(['Content-type' => ['application/json'], ICanCreateResponses::X_HEADER => ['json']], $response->getHeaders()); self::assertEquals(150, $result->remaining_hits); self::assertEquals(150, $result->hourly_limit); self::assertIsInt($result->reset_time_in_seconds); @@ -23,9 +24,10 @@ class RateLimitStatusTest extends ApiTest public function testWithXml() { - $rateLimitStatus = new RateLimitStatus(DI::l10n(),['extension' => 'xml']); - $rateLimitStatus->rawContent(); + $rateLimitStatus = new RateLimitStatus(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [], ['extension' => 'xml']); + $response = $rateLimitStatus->run(); - self::assertXml(ApiResponseDouble::getOutput(), 'hash'); + self::assertEquals(['Content-type' => ['text/xml'], ICanCreateResponses::X_HEADER => ['xml']], $response->getHeaders()); + self::assertXml($response->getBody(), 'hash'); } } diff --git a/tests/src/Module/Api/Twitter/SavedSearchesTest.php b/tests/src/Module/Api/Twitter/SavedSearchesTest.php index 8e066d4ba..14973b391 100644 --- a/tests/src/Module/Api/Twitter/SavedSearchesTest.php +++ b/tests/src/Module/Api/Twitter/SavedSearchesTest.php @@ -2,20 +2,21 @@ namespace Friendica\Test\src\Module\Api\Twitter; +use Friendica\Capabilities\ICanCreateResponses; use Friendica\DI; use Friendica\Module\Api\Twitter\SavedSearches; use Friendica\Test\src\Module\Api\ApiTest; -use Friendica\Test\Util\ApiResponseDouble; class SavedSearchesTest extends ApiTest { public function test() { - $savedSearch = new SavedSearches(DI::l10n(), ['extension' => 'json']); - $savedSearch->rawContent(); + $savedSearch = new SavedSearches(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [], ['extension' => 'json']); + $response = $savedSearch->run(); - $result = json_decode(ApiResponseDouble::getOutput()); + $result = json_decode($response->getBody()); + self::assertEquals(['Content-type' => ['application/json'], ICanCreateResponses::X_HEADER => ['json']], $response->getHeaders()); self::assertEquals(1, $result[0]->id); self::assertEquals(1, $result[0]->id_str); self::assertEquals('Saved search', $result[0]->name); diff --git a/tests/src/Module/NodeInfoTest.php b/tests/src/Module/NodeInfoTest.php new file mode 100644 index 000000000..53a2926f9 --- /dev/null +++ b/tests/src/Module/NodeInfoTest.php @@ -0,0 +1,81 @@ +run(); + + self::assertJson($response->getBody()); + self::assertEquals(['Content-type' => ['application/json'], ICanCreateResponses::X_HEADER => ['json']], $response->getHeaders()); + + $json = json_decode($response->getBody()); + + self::assertEquals('1.0', $json->version); + + self::assertEquals('friendica', $json->software->name); + self::assertEquals(FRIENDICA_VERSION . '-' . DB_UPDATE_VERSION, $json->software->version); + + self::assertIsArray($json->protocols->inbound); + self::assertIsArray($json->protocols->outbound); + self::assertIsArray($json->services->inbound); + self::assertIsArray($json->services->outbound); + } + + public function testNodeInfo120() + { + $response = new Response(); + + $nodeinfo = new NodeInfo120(DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), $response, DI::config(), []); + $response = $nodeinfo->run(); + + self::assertJson($response->getBody()); + self::assertEquals(['Content-type' => ['application/json; charset=utf-8'], ICanCreateResponses::X_HEADER => ['json']], $response->getHeaders()); + + $json = json_decode($response->getBody()); + + self::assertEquals('2.0', $json->version); + + self::assertEquals('friendica', $json->software->name); + self::assertEquals(FRIENDICA_VERSION . '-' . DB_UPDATE_VERSION, $json->software->version); + + self::assertIsArray($json->protocols); + self::assertIsArray($json->services->inbound); + self::assertIsArray($json->services->outbound); + } + + public function testNodeInfo210() + { + $response = new Response(); + + $nodeinfo = new NodeInfo210(DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), $response, DI::config(), []); + $response = $nodeinfo->run(); + + self::assertJson($response->getBody()); + self::assertEquals(['Content-type' => ['application/json; charset=utf-8'], ICanCreateResponses::X_HEADER => ['json']], $response->getHeaders()); + + $json = json_decode($response->getBody()); + + self::assertEquals('1.0', $json->version); + + self::assertEquals('friendica', $json->server->software); + self::assertEquals(FRIENDICA_VERSION . '-' . DB_UPDATE_VERSION, $json->server->version); + + self::assertIsArray($json->protocols); + self::assertIsArray($json->services->inbound); + self::assertIsArray($json->services->outbound); + } +} diff --git a/view/lang/C/messages.po b/view/lang/C/messages.po index 4500b3eea..71dab5ef3 100644 --- a/view/lang/C/messages.po +++ b/view/lang/C/messages.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: 2021.12-dev\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2021-11-26 09:54-0500\n" +"POT-Creation-Date: 2021-11-27 12:46+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -18,21 +18,21 @@ msgstr "" "Content-Transfer-Encoding: 8bit\n" -#: include/api.php:770 src/Module/BaseApi.php:259 +#: include/api.php:771 src/Module/BaseApi.php:275 #, php-format msgid "Daily posting limit of %d post reached. The post was rejected." msgid_plural "Daily posting limit of %d posts reached. The post was rejected." msgstr[0] "" msgstr[1] "" -#: include/api.php:784 src/Module/BaseApi.php:275 +#: include/api.php:785 src/Module/BaseApi.php:291 #, php-format msgid "Weekly posting limit of %d post reached. The post was rejected." msgid_plural "Weekly posting limit of %d posts reached. The post was rejected." msgstr[0] "" msgstr[1] "" -#: include/api.php:798 src/Module/BaseApi.php:291 +#: include/api.php:799 src/Module/BaseApi.php:307 #, php-format msgid "Monthly posting limit of %d post reached. The post was rejected." msgstr "" @@ -51,7 +51,7 @@ msgstr "" #: src/Module/Profile/Common.php:41 src/Module/Profile/Common.php:52 #: src/Module/Profile/Contacts.php:40 src/Module/Profile/Contacts.php:50 #: src/Module/Profile/Media.php:38 src/Module/Profile/Status.php:58 -#: src/Module/Register.php:263 src/Module/RemoteFollow.php:58 +#: src/Module/Register.php:266 src/Module/RemoteFollow.php:58 msgid "User not found." msgstr "" @@ -76,7 +76,7 @@ msgstr "" msgid "Previous" msgstr "" -#: mod/cal.php:245 mod/events.php:381 src/Module/Install.php:215 +#: mod/cal.php:245 mod/events.php:381 src/Module/Install.php:214 msgid "Next" msgstr "" @@ -106,7 +106,7 @@ msgstr "" #: mod/cal.php:265 src/Console/User.php:182 src/Model/User.php:659 #: src/Module/Admin/Users/Active.php:73 src/Module/Admin/Users/Blocked.php:74 #: src/Module/Admin/Users/Index.php:80 src/Module/Admin/Users/Pending.php:71 -#: src/Module/Api/Twitter/ContactEndpoint.php:72 +#: src/Module/Api/Twitter/ContactEndpoint.php:76 msgid "User not found" msgstr "" @@ -145,18 +145,18 @@ msgstr "" #: mod/unfollow.php:50 mod/unfollow.php:82 mod/wall_attach.php:68 #: mod/wall_attach.php:71 mod/wall_upload.php:90 mod/wall_upload.php:93 #: mod/wallmessage.php:36 mod/wallmessage.php:55 mod/wallmessage.php:89 -#: mod/wallmessage.php:109 src/Module/Attach.php:55 src/Module/BaseApi.php:61 -#: src/Module/BaseApi.php:70 src/Module/BaseApi.php:79 -#: src/Module/BaseApi.php:88 src/Module/BaseNotifications.php:94 +#: mod/wallmessage.php:109 src/Module/Attach.php:55 src/Module/BaseApi.php:77 +#: src/Module/BaseApi.php:86 src/Module/BaseApi.php:95 +#: src/Module/BaseApi.php:104 src/Module/BaseNotifications.php:97 #: src/Module/Contact/Advanced.php:60 src/Module/Delegation.php:118 -#: src/Module/FollowConfirm.php:17 src/Module/FriendSuggest.php:56 +#: src/Module/FollowConfirm.php:18 src/Module/FriendSuggest.php:56 #: src/Module/Group.php:42 src/Module/Group.php:85 src/Module/Invite.php:41 #: src/Module/Invite.php:130 src/Module/Notifications/Notification.php:48 #: src/Module/Notifications/Notification.php:79 #: src/Module/Profile/Common.php:56 src/Module/Profile/Contacts.php:56 #: src/Module/Profile/Schedule.php:39 src/Module/Profile/Schedule.php:56 -#: src/Module/Register.php:73 src/Module/Register.php:86 -#: src/Module/Register.php:202 src/Module/Register.php:241 +#: src/Module/Register.php:76 src/Module/Register.php:89 +#: src/Module/Register.php:205 src/Module/Register.php:244 #: src/Module/Search/Directory.php:37 src/Module/Settings/Delegation.php:42 #: src/Module/Settings/Delegation.php:70 src/Module/Settings/Display.php:42 #: src/Module/Settings/Display.php:120 @@ -178,7 +178,7 @@ msgid "Edit post" msgstr "" #: mod/editpost.php:91 mod/notes.php:56 src/Content/Text/HTML.php:875 -#: src/Module/Admin/Storage.php:142 src/Module/Filer/SaveTag.php:76 +#: src/Module/Admin/Storage.php:142 src/Module/Filer/SaveTag.php:73 msgid "Save" msgstr "" @@ -288,7 +288,7 @@ msgstr "" #: mod/editpost.php:130 mod/fbrowser.php:100 mod/fbrowser.php:127 #: mod/follow.php:144 mod/photos.php:1010 mod/photos.php:1111 mod/tagrm.php:35 #: mod/tagrm.php:127 mod/unfollow.php:97 src/Content/Conversation.php:373 -#: src/Module/Contact/Revoke.php:114 src/Module/RemoteFollow.php:128 +#: src/Module/Contact/Revoke.php:110 src/Module/RemoteFollow.php:127 msgid "Cancel" msgstr "" @@ -378,12 +378,12 @@ msgstr "" #: src/Module/Admin/Blocklist/Server/Index.php:69 #: src/Module/Admin/Blocklist/Server/Index.php:96 #: src/Module/Admin/Item/Delete.php:70 src/Module/Debug/Probe.php:59 -#: src/Module/Install.php:208 src/Module/Install.php:241 -#: src/Module/Install.php:246 src/Module/Install.php:265 -#: src/Module/Install.php:276 src/Module/Install.php:281 -#: src/Module/Install.php:287 src/Module/Install.php:292 -#: src/Module/Install.php:306 src/Module/Install.php:321 -#: src/Module/Install.php:348 src/Module/Register.php:144 +#: src/Module/Install.php:207 src/Module/Install.php:240 +#: src/Module/Install.php:245 src/Module/Install.php:264 +#: src/Module/Install.php:275 src/Module/Install.php:280 +#: src/Module/Install.php:286 src/Module/Install.php:291 +#: src/Module/Install.php:305 src/Module/Install.php:320 +#: src/Module/Install.php:347 src/Module/Register.php:147 #: src/Module/Security/TwoFactor/Verify.php:100 #: src/Module/Settings/TwoFactor/Index.php:133 #: src/Module/Settings/TwoFactor/Verify.php:153 @@ -406,7 +406,7 @@ msgstr "" #: mod/events.php:508 src/Content/Widget/VCard.php:98 src/Model/Event.php:80 #: src/Model/Event.php:107 src/Model/Event.php:466 src/Model/Event.php:915 #: src/Model/Profile.php:368 src/Module/Contact/Profile.php:376 -#: src/Module/Directory.php:147 src/Module/Notifications/Introductions.php:181 +#: src/Module/Directory.php:147 src/Module/Notifications/Introductions.php:185 #: src/Module/Profile/Profile.php:194 msgid "Location:" msgstr "" @@ -427,9 +427,9 @@ msgstr "" #: src/Module/Debug/ActivityPubConversion.php:141 #: src/Module/Debug/Babel.php:313 src/Module/Debug/Localtime.php:64 #: src/Module/Debug/Probe.php:54 src/Module/Debug/WebFinger.php:51 -#: src/Module/Delegation.php:147 src/Module/FriendSuggest.php:145 -#: src/Module/Install.php:253 src/Module/Install.php:295 -#: src/Module/Install.php:332 src/Module/Invite.php:177 +#: src/Module/Delegation.php:147 src/Module/FriendSuggest.php:144 +#: src/Module/Install.php:252 src/Module/Install.php:294 +#: src/Module/Install.php:331 src/Module/Invite.php:177 #: src/Module/Item/Compose.php:150 src/Module/Profile/Profile.php:247 #: src/Module/Settings/Profile/Index.php:222 src/Object/Post.php:963 #: view/theme/duepuntozero/config.php:69 view/theme/frio/config.php:160 @@ -464,7 +464,7 @@ msgstr "" msgid "Files" msgstr "" -#: mod/follow.php:74 mod/unfollow.php:96 src/Module/RemoteFollow.php:127 +#: mod/follow.php:74 mod/unfollow.php:96 src/Module/RemoteFollow.php:126 msgid "Submit Request" msgstr "" @@ -490,7 +490,7 @@ msgstr "" msgid "Connect/Follow" msgstr "" -#: mod/follow.php:139 src/Module/RemoteFollow.php:126 +#: mod/follow.php:139 src/Module/RemoteFollow.php:125 msgid "Please answer the following:" msgstr "" @@ -501,13 +501,13 @@ msgstr "" #: mod/follow.php:141 mod/unfollow.php:100 #: src/Module/Admin/Blocklist/Contact.php:116 #: src/Module/Contact/Profile.php:372 -#: src/Module/Notifications/Introductions.php:123 -#: src/Module/Notifications/Introductions.php:192 +#: src/Module/Notifications/Introductions.php:127 +#: src/Module/Notifications/Introductions.php:196 msgid "Profile URL" msgstr "" #: mod/follow.php:142 src/Module/Contact/Profile.php:384 -#: src/Module/Notifications/Introductions.php:185 +#: src/Module/Notifications/Introductions.php:189 #: src/Module/Profile/Profile.php:207 msgid "Tags:" msgstr "" @@ -726,8 +726,8 @@ msgstr "" msgid "Message collection failure." msgstr "" -#: mod/message.php:120 src/Module/Notifications/Introductions.php:129 -#: src/Module/Notifications/Introductions.php:164 +#: mod/message.php:120 src/Module/Notifications/Introductions.php:133 +#: src/Module/Notifications/Introductions.php:168 #: src/Module/Notifications/Notification.php:57 msgid "Discard" msgstr "" @@ -889,7 +889,7 @@ msgstr "" msgid "Upload New Photos" msgstr "" -#: mod/photos.php:129 src/Module/BaseSettings.php:37 +#: mod/photos.php:129 src/Module/BaseSettings.php:35 msgid "everybody" msgstr "" @@ -1154,7 +1154,7 @@ msgstr "" #: src/Module/Contact/Posts.php:74 src/Module/Contact/Posts.php:79 #: src/Module/Contact/Posts.php:84 src/Module/Contact/Profile.php:148 #: src/Module/Contact/Profile.php:153 src/Module/Contact/Profile.php:158 -#: src/Module/FriendSuggest.php:71 src/Module/FriendSuggest.php:109 +#: src/Module/FriendSuggest.php:70 src/Module/FriendSuggest.php:108 #: src/Module/Group.php:99 src/Module/Group.php:108 msgid "Contact not found." msgstr "" @@ -1340,7 +1340,7 @@ msgstr "" msgid "None" msgstr "" -#: mod/settings.php:535 src/Module/BaseSettings.php:80 +#: mod/settings.php:535 src/Module/BaseSettings.php:78 msgid "Social Networks" msgstr "" @@ -1616,7 +1616,7 @@ msgstr "" msgid "Password Settings" msgstr "" -#: mod/settings.php:710 src/Module/Register.php:158 +#: mod/settings.php:710 src/Module/Register.php:161 msgid "New Password:" msgstr "" @@ -1626,7 +1626,7 @@ msgid "" "spaces, accentuated letters and colon (:)." msgstr "" -#: mod/settings.php:711 src/Module/Register.php:159 +#: mod/settings.php:711 src/Module/Register.php:162 msgid "Confirm:" msgstr "" @@ -2014,13 +2014,13 @@ msgstr "" msgid "User imports on closed servers can only be done by an administrator." msgstr "" -#: mod/uimport.php:55 src/Module/Register.php:95 +#: mod/uimport.php:55 src/Module/Register.php:98 msgid "" "This site has exceeded the number of allowed daily account registrations. " "Please try again tomorrow." msgstr "" -#: mod/uimport.php:62 src/Module/Register.php:169 +#: mod/uimport.php:62 src/Module/Register.php:172 msgid "Import" msgstr "" @@ -2128,14 +2128,10 @@ msgid "" "your site allow private mail from unknown senders." msgstr "" -#: src/App.php:470 +#: src/App.php:463 msgid "No system theme config value set." msgstr "" -#: src/App/ModuleController.php:233 -msgid "You must be logged in to use addons. " -msgstr "" - #: src/App/Page.php:250 msgid "Delete this item?" msgstr "" @@ -2150,40 +2146,44 @@ msgstr "" msgid "toggle mobile" msgstr "" -#: src/App/Router.php:241 +#: src/App/Router.php:276 #, php-format msgid "Method not allowed for this module. Allowed method(s): %s" msgstr "" -#: src/App/Router.php:243 src/Module/HTTPException/PageNotFound.php:32 +#: src/App/Router.php:278 src/Module/HTTPException/PageNotFound.php:33 msgid "Page not found." msgstr "" -#: src/BaseModule.php:178 +#: src/App/Router.php:305 +msgid "You must be logged in to use addons. " +msgstr "" + +#: src/BaseModule.php:299 msgid "" "The form security token was not correct. This probably happened because the " "form has been opened for too long (>3 hours) before submitting it." msgstr "" -#: src/BaseModule.php:205 +#: src/BaseModule.php:326 msgid "All contacts" msgstr "" -#: src/BaseModule.php:210 src/Content/Widget.php:231 src/Core/ACL.php:193 +#: src/BaseModule.php:331 src/Content/Widget.php:231 src/Core/ACL.php:193 #: src/Module/Contact.php:367 src/Module/PermissionTooltip.php:79 #: src/Module/PermissionTooltip.php:101 msgid "Followers" msgstr "" -#: src/BaseModule.php:215 src/Content/Widget.php:232 src/Module/Contact.php:368 +#: src/BaseModule.php:336 src/Content/Widget.php:232 src/Module/Contact.php:368 msgid "Following" msgstr "" -#: src/BaseModule.php:220 src/Content/Widget.php:233 src/Module/Contact.php:369 +#: src/BaseModule.php:341 src/Content/Widget.php:233 src/Module/Contact.php:369 msgid "Mutual friends" msgstr "" -#: src/BaseModule.php:228 +#: src/BaseModule.php:349 msgid "Common" msgstr "" @@ -2505,7 +2505,7 @@ msgstr "" msgid "Tag term:" msgstr "" -#: src/Content/Conversation.php:310 src/Module/Filer/SaveTag.php:75 +#: src/Content/Conversation.php:310 src/Module/Filer/SaveTag.php:72 msgid "Save to Folder:" msgstr "" @@ -2779,8 +2779,8 @@ msgstr "" #: src/Content/Item.php:450 src/Module/Contact.php:399 #: src/Module/Contact/Profile.php:356 src/Module/Contact/Profile.php:464 -#: src/Module/Notifications/Introductions.php:128 -#: src/Module/Notifications/Introductions.php:200 +#: src/Module/Notifications/Introductions.php:132 +#: src/Module/Notifications/Introductions.php:204 #: src/Module/Notifications/Notification.php:61 msgid "Ignore" msgstr "" @@ -2838,7 +2838,7 @@ msgid "Your posts and conversations" msgstr "" #: src/Content/Nav.php:191 src/Module/BaseProfile.php:48 -#: src/Module/BaseSettings.php:57 src/Module/Contact.php:457 +#: src/Module/BaseSettings.php:55 src/Module/Contact.php:457 #: src/Module/Contact/Profile.php:389 src/Module/Profile/Profile.php:241 #: src/Module/Welcome.php:57 view/theme/frio/theme.php:226 msgid "Profile" @@ -2878,7 +2878,7 @@ msgstr "" msgid "Home" msgstr "" -#: src/Content/Nav.php:216 src/Module/Register.php:164 +#: src/Content/Nav.php:216 src/Module/Register.php:167 #: src/Module/Security/Login.php:105 msgid "Register" msgstr "" @@ -2962,8 +2962,8 @@ msgid "Information about this friendica instance" msgstr "" #: src/Content/Nav.php:266 src/Module/Admin/Tos.php:76 -#: src/Module/BaseAdmin.php:96 src/Module/Register.php:172 -#: src/Module/Tos.php:88 +#: src/Module/BaseAdmin.php:96 src/Module/Register.php:175 +#: src/Module/Tos.php:87 msgid "Terms of Service" msgstr "" @@ -2987,8 +2987,8 @@ msgstr "" msgid "Friend Requests" msgstr "" -#: src/Content/Nav.php:278 src/Module/BaseNotifications.php:147 -#: src/Module/Notifications/Introductions.php:69 +#: src/Content/Nav.php:278 src/Module/BaseNotifications.php:148 +#: src/Module/Notifications/Introductions.php:73 msgid "Notifications" msgstr "" @@ -3021,7 +3021,7 @@ msgid "Manage other pages" msgstr "" #: src/Content/Nav.php:292 src/Module/Admin/Addons/Details.php:114 -#: src/Module/Admin/Themes/Details.php:93 src/Module/BaseSettings.php:124 +#: src/Module/Admin/Themes/Details.php:93 src/Module/BaseSettings.php:122 #: src/Module/Welcome.php:52 view/theme/frio/theme.php:235 msgid "Settings" msgstr "" @@ -3306,7 +3306,7 @@ msgid "Matrix:" msgstr "" #: src/Content/Widget/VCard.php:101 src/Model/Profile.php:466 -#: src/Module/Notifications/Introductions.php:195 +#: src/Module/Notifications/Introductions.php:199 msgid "Network:" msgstr "" @@ -3373,8 +3373,8 @@ msgid "" "or mysql." msgstr "" -#: src/Core/Installer.php:203 src/Module/Install.php:214 -#: src/Module/Install.php:373 +#: src/Core/Installer.php:203 src/Module/Install.php:213 +#: src/Module/Install.php:372 msgid "Please see the file \"doc/INSTALL.md\"." msgstr "" @@ -4059,7 +4059,7 @@ msgstr "" msgid "Internal Server Error" msgstr "" -#: src/LegacyModule.php:60 +#: src/LegacyModule.php:63 #, php-format msgid "Legacy module file not found: %s" msgstr "" @@ -4069,8 +4069,8 @@ msgid "UnFollow" msgstr "" #: src/Model/Contact.php:1061 src/Module/Admin/Users/Pending.php:107 -#: src/Module/Notifications/Introductions.php:126 -#: src/Module/Notifications/Introductions.php:198 +#: src/Module/Notifications/Introductions.php:130 +#: src/Module/Notifications/Introductions.php:202 msgid "Approve" msgstr "" @@ -4307,7 +4307,7 @@ msgid "Homepage:" msgstr "" #: src/Model/Profile.php:372 src/Module/Contact/Profile.php:382 -#: src/Module/Notifications/Introductions.php:183 +#: src/Module/Notifications/Introductions.php:187 msgid "About:" msgstr "" @@ -4727,7 +4727,7 @@ msgid "Administration" msgstr "" #: src/Module/Admin/Addons/Details.php:112 src/Module/Admin/Addons/Index.php:68 -#: src/Module/BaseAdmin.php:93 src/Module/BaseSettings.php:87 +#: src/Module/BaseAdmin.php:93 src/Module/BaseSettings.php:85 msgid "Addons" msgstr "" @@ -5309,7 +5309,7 @@ msgid "Search in logs" msgstr "" #: src/Module/Admin/Logs/View.php:88 -#: src/Module/Notifications/Notifications.php:140 +#: src/Module/Notifications/Notifications.php:139 msgid "Show all" msgstr "" @@ -5454,15 +5454,15 @@ msgstr "" msgid "Open" msgstr "" -#: src/Module/Admin/Site.php:475 src/Module/Install.php:223 +#: src/Module/Admin/Site.php:475 src/Module/Install.php:222 msgid "No SSL policy, links will track page SSL state" msgstr "" -#: src/Module/Admin/Site.php:476 src/Module/Install.php:224 +#: src/Module/Admin/Site.php:476 src/Module/Install.php:223 msgid "Force all links to use SSL" msgstr "" -#: src/Module/Admin/Site.php:477 src/Module/Install.php:225 +#: src/Module/Admin/Site.php:477 src/Module/Install.php:224 msgid "Self-signed certificate, use SSL for local links only (discouraged)" msgstr "" @@ -5502,7 +5502,7 @@ msgstr "" msgid "Republish users to directory" msgstr "" -#: src/Module/Admin/Site.php:503 src/Module/Register.php:148 +#: src/Module/Admin/Site.php:503 src/Module/Register.php:151 msgid "Registration" msgstr "" @@ -5635,11 +5635,11 @@ msgstr "" msgid "Theme for mobile devices" msgstr "" -#: src/Module/Admin/Site.php:531 src/Module/Install.php:233 +#: src/Module/Admin/Site.php:531 src/Module/Install.php:232 msgid "SSL link policy" msgstr "" -#: src/Module/Admin/Site.php:531 src/Module/Install.php:235 +#: src/Module/Admin/Site.php:531 src/Module/Install.php:234 msgid "Determines whether generated links should be forced to use SSL" msgstr "" @@ -6804,12 +6804,12 @@ msgstr "" msgid "Deny" msgstr "" -#: src/Module/Api/ApiResponse.php:266 +#: src/Module/Api/ApiResponse.php:243 #, php-format msgid "API endpoint %s %s is not implemented" msgstr "" -#: src/Module/Api/ApiResponse.php:267 +#: src/Module/Api/ApiResponse.php:244 msgid "" "The API endpoint is currently not implemented but might be in the future." msgstr "" @@ -6849,15 +6849,15 @@ msgstr "" msgid "Posts from %s can't be unshared" msgstr "" -#: src/Module/Api/Twitter/ContactEndpoint.php:64 +#: src/Module/Api/Twitter/ContactEndpoint.php:68 msgid "Contact not found" msgstr "" -#: src/Module/Apps.php:51 +#: src/Module/Apps.php:54 msgid "No installed applications." msgstr "" -#: src/Module/Apps.php:56 +#: src/Module/Apps.php:59 msgid "Applications" msgstr "" @@ -6887,7 +6887,7 @@ msgstr "" msgid "Configuration" msgstr "" -#: src/Module/BaseAdmin.php:95 src/Module/BaseSettings.php:65 +#: src/Module/BaseAdmin.php:95 src/Module/BaseSettings.php:63 msgid "Additional features" msgstr "" @@ -6951,8 +6951,8 @@ msgstr "" msgid "User registrations waiting for confirmation" msgstr "" -#: src/Module/BaseApi.php:258 src/Module/BaseApi.php:274 -#: src/Module/BaseApi.php:290 +#: src/Module/BaseApi.php:274 src/Module/BaseApi.php:290 +#: src/Module/BaseApi.php:306 msgid "Too Many Requests" msgstr "" @@ -6986,32 +6986,32 @@ msgstr "" msgid "Forum Search - %s" msgstr "" -#: src/Module/BaseSettings.php:43 +#: src/Module/BaseSettings.php:41 msgid "Account" msgstr "" -#: src/Module/BaseSettings.php:50 src/Module/Security/TwoFactor/Verify.php:95 +#: src/Module/BaseSettings.php:48 src/Module/Security/TwoFactor/Verify.php:95 #: src/Module/Settings/TwoFactor/Index.php:110 msgid "Two-factor authentication" msgstr "" -#: src/Module/BaseSettings.php:73 +#: src/Module/BaseSettings.php:71 msgid "Display" msgstr "" -#: src/Module/BaseSettings.php:94 src/Module/Settings/Delegation.php:171 +#: src/Module/BaseSettings.php:92 src/Module/Settings/Delegation.php:171 msgid "Manage Accounts" msgstr "" -#: src/Module/BaseSettings.php:101 +#: src/Module/BaseSettings.php:99 msgid "Connected apps" msgstr "" -#: src/Module/BaseSettings.php:108 src/Module/Settings/UserExport.php:75 +#: src/Module/BaseSettings.php:106 src/Module/Settings/UserExport.php:75 msgid "Export personal data" msgstr "" -#: src/Module/BaseSettings.php:115 +#: src/Module/BaseSettings.php:113 msgid "Remove account" msgstr "" @@ -7444,7 +7444,7 @@ msgid "Awaiting connection acknowledge" msgstr "" #: src/Module/Contact/Profile.php:364 -#: src/Module/Notifications/Introductions.php:186 +#: src/Module/Notifications/Introductions.php:190 msgid "Hide this contact from others" msgstr "" @@ -7498,7 +7498,7 @@ msgstr "" msgid "Toggle Ignored status" msgstr "" -#: src/Module/Contact/Profile.php:473 src/Module/Contact/Revoke.php:111 +#: src/Module/Contact/Profile.php:473 src/Module/Contact/Revoke.php:107 msgid "Revoke Follow" msgstr "" @@ -7506,42 +7506,42 @@ msgstr "" msgid "Revoke the follow from this contact" msgstr "" -#: src/Module/Contact/Revoke.php:63 +#: src/Module/Contact/Revoke.php:59 msgid "Unknown contact." msgstr "" -#: src/Module/Contact/Revoke.php:73 src/Module/Group.php:112 +#: src/Module/Contact/Revoke.php:69 src/Module/Group.php:112 msgid "Contact is deleted." msgstr "" -#: src/Module/Contact/Revoke.php:77 +#: src/Module/Contact/Revoke.php:73 msgid "Contact is being deleted." msgstr "" -#: src/Module/Contact/Revoke.php:91 +#: src/Module/Contact/Revoke.php:87 msgid "Follow was successfully revoked." msgstr "" -#: src/Module/Contact/Revoke.php:93 +#: src/Module/Contact/Revoke.php:89 msgid "" "Follow was successfully revoked, however the remote contact won't be aware " "of this revokation." msgstr "" -#: src/Module/Contact/Revoke.php:95 +#: src/Module/Contact/Revoke.php:91 msgid "" "Unable to revoke follow, please try again later or contact the administrator." msgstr "" -#: src/Module/Contact/Revoke.php:112 +#: src/Module/Contact/Revoke.php:108 msgid "" "Do you really want to revoke this contact's follow? This cannot be undone " "and they will have to manually follow you back again." msgstr "" -#: src/Module/Contact/Revoke.php:113 -#: src/Module/Notifications/Introductions.php:138 -#: src/Module/OAuth/Acknowledge.php:47 src/Module/Register.php:126 +#: src/Module/Contact/Revoke.php:109 +#: src/Module/Notifications/Introductions.php:142 +#: src/Module/OAuth/Acknowledge.php:47 src/Module/Register.php:129 msgid "Yes" msgstr "" @@ -7841,12 +7841,12 @@ msgstr "" msgid "Twitter Source / Tweet URL (requires API key)" msgstr "" -#: src/Module/Debug/Feed.php:47 src/Module/Filer/SaveTag.php:49 +#: src/Module/Debug/Feed.php:50 src/Module/Filer/SaveTag.php:46 #: src/Module/Settings/Profile/Index.php:141 msgid "You must be logged in to use this module" msgstr "" -#: src/Module/Debug/Feed.php:72 +#: src/Module/Debug/Feed.php:75 msgid "Source URL" msgstr "" @@ -7945,23 +7945,23 @@ msgstr "" msgid "Item was not deleted" msgstr "" -#: src/Module/Filer/SaveTag.php:75 +#: src/Module/Filer/SaveTag.php:72 msgid "- select -" msgstr "" -#: src/Module/FriendSuggest.php:82 +#: src/Module/FriendSuggest.php:81 msgid "Suggested contact not found." msgstr "" -#: src/Module/FriendSuggest.php:100 +#: src/Module/FriendSuggest.php:99 msgid "Friend suggestion sent." msgstr "" -#: src/Module/FriendSuggest.php:137 +#: src/Module/FriendSuggest.php:136 msgid "Suggest Friends" msgstr "" -#: src/Module/FriendSuggest.php:140 +#: src/Module/FriendSuggest.php:139 #, php-format msgid "Suggest a friend for %s" msgstr "" @@ -8106,155 +8106,155 @@ msgstr "" msgid "Welcome to %s" msgstr "" -#: src/Module/Install.php:196 +#: src/Module/Install.php:195 msgid "Friendica Communications Server - Setup" msgstr "" -#: src/Module/Install.php:207 +#: src/Module/Install.php:206 msgid "System check" msgstr "" -#: src/Module/Install.php:209 src/Module/Install.php:266 -#: src/Module/Install.php:349 +#: src/Module/Install.php:208 src/Module/Install.php:265 +#: src/Module/Install.php:348 msgid "Requirement not satisfied" msgstr "" -#: src/Module/Install.php:210 +#: src/Module/Install.php:209 msgid "Optional requirement not satisfied" msgstr "" -#: src/Module/Install.php:211 +#: src/Module/Install.php:210 msgid "OK" msgstr "" -#: src/Module/Install.php:216 +#: src/Module/Install.php:215 msgid "Check again" msgstr "" -#: src/Module/Install.php:231 +#: src/Module/Install.php:230 msgid "Base settings" msgstr "" -#: src/Module/Install.php:238 +#: src/Module/Install.php:237 msgid "Host name" msgstr "" -#: src/Module/Install.php:240 +#: src/Module/Install.php:239 msgid "" "Overwrite this field in case the determinated hostname isn't right, " "otherweise leave it as is." msgstr "" -#: src/Module/Install.php:243 +#: src/Module/Install.php:242 msgid "Base path to installation" msgstr "" -#: src/Module/Install.php:245 +#: src/Module/Install.php:244 msgid "" "If the system cannot detect the correct path to your installation, enter the " "correct path here. This setting should only be set if you are using a " "restricted system and symbolic links to your webroot." msgstr "" -#: src/Module/Install.php:248 +#: src/Module/Install.php:247 msgid "Sub path of the URL" msgstr "" -#: src/Module/Install.php:250 +#: src/Module/Install.php:249 msgid "" "Overwrite this field in case the sub path determination isn't right, " "otherwise leave it as is. Leaving this field blank means the installation is " "at the base URL without sub path." msgstr "" -#: src/Module/Install.php:261 +#: src/Module/Install.php:260 msgid "Database connection" msgstr "" -#: src/Module/Install.php:262 +#: src/Module/Install.php:261 msgid "" "In order to install Friendica we need to know how to connect to your " "database." msgstr "" -#: src/Module/Install.php:263 +#: src/Module/Install.php:262 msgid "" "Please contact your hosting provider or site administrator if you have " "questions about these settings." msgstr "" -#: src/Module/Install.php:264 +#: src/Module/Install.php:263 msgid "" "The database you specify below should already exist. If it does not, please " "create it before continuing." msgstr "" -#: src/Module/Install.php:273 +#: src/Module/Install.php:272 msgid "Database Server Name" msgstr "" -#: src/Module/Install.php:278 +#: src/Module/Install.php:277 msgid "Database Login Name" msgstr "" -#: src/Module/Install.php:284 +#: src/Module/Install.php:283 msgid "Database Login Password" msgstr "" -#: src/Module/Install.php:286 +#: src/Module/Install.php:285 msgid "For security reasons the password must not be empty" msgstr "" -#: src/Module/Install.php:289 +#: src/Module/Install.php:288 msgid "Database Name" msgstr "" -#: src/Module/Install.php:293 src/Module/Install.php:323 +#: src/Module/Install.php:292 src/Module/Install.php:322 msgid "Please select a default timezone for your website" msgstr "" -#: src/Module/Install.php:308 +#: src/Module/Install.php:307 msgid "Site settings" msgstr "" -#: src/Module/Install.php:318 +#: src/Module/Install.php:317 msgid "Site administrator email address" msgstr "" -#: src/Module/Install.php:320 +#: src/Module/Install.php:319 msgid "" "Your account email address must match this in order to use the web admin " "panel." msgstr "" -#: src/Module/Install.php:327 +#: src/Module/Install.php:326 msgid "System Language:" msgstr "" -#: src/Module/Install.php:329 +#: src/Module/Install.php:328 msgid "" "Set the default language for your Friendica installation interface and to " "send emails." msgstr "" -#: src/Module/Install.php:341 +#: src/Module/Install.php:340 msgid "Your Friendica site database has been installed." msgstr "" -#: src/Module/Install.php:351 +#: src/Module/Install.php:350 msgid "Installation finished" msgstr "" -#: src/Module/Install.php:371 +#: src/Module/Install.php:370 msgid "

What next

" msgstr "" -#: src/Module/Install.php:372 +#: src/Module/Install.php:371 msgid "" "IMPORTANT: You will need to [manually] setup a scheduled task for the worker." msgstr "" -#: src/Module/Install.php:375 +#: src/Module/Install.php:374 #, php-format msgid "" "Go to your new Friendica node registration page " @@ -8419,64 +8419,64 @@ msgstr "" msgid "A Decentralized Social Network" msgstr "" -#: src/Module/Notifications/Introductions.php:93 +#: src/Module/Notifications/Introductions.php:97 msgid "Show Ignored Requests" msgstr "" -#: src/Module/Notifications/Introductions.php:93 +#: src/Module/Notifications/Introductions.php:97 msgid "Hide Ignored Requests" msgstr "" -#: src/Module/Notifications/Introductions.php:109 -#: src/Module/Notifications/Introductions.php:172 +#: src/Module/Notifications/Introductions.php:113 +#: src/Module/Notifications/Introductions.php:176 msgid "Notification type:" msgstr "" -#: src/Module/Notifications/Introductions.php:112 +#: src/Module/Notifications/Introductions.php:116 msgid "Suggested by:" msgstr "" -#: src/Module/Notifications/Introductions.php:137 +#: src/Module/Notifications/Introductions.php:141 msgid "Claims to be known to you: " msgstr "" -#: src/Module/Notifications/Introductions.php:138 -#: src/Module/OAuth/Acknowledge.php:48 src/Module/Register.php:127 +#: src/Module/Notifications/Introductions.php:142 +#: src/Module/OAuth/Acknowledge.php:48 src/Module/Register.php:130 msgid "No" msgstr "" -#: src/Module/Notifications/Introductions.php:146 +#: src/Module/Notifications/Introductions.php:150 msgid "Shall your connection be bidirectional or not?" msgstr "" -#: src/Module/Notifications/Introductions.php:147 +#: src/Module/Notifications/Introductions.php:151 #, php-format msgid "" "Accepting %s as a friend allows %s to subscribe to your posts, and you will " "also receive updates from them in your news feed." msgstr "" -#: src/Module/Notifications/Introductions.php:148 +#: src/Module/Notifications/Introductions.php:152 #, php-format msgid "" "Accepting %s as a subscriber allows them to subscribe to your posts, but you " "will not receive updates from them in your news feed." msgstr "" -#: src/Module/Notifications/Introductions.php:150 +#: src/Module/Notifications/Introductions.php:154 msgid "Friend" msgstr "" -#: src/Module/Notifications/Introductions.php:151 +#: src/Module/Notifications/Introductions.php:155 msgid "Subscriber" msgstr "" -#: src/Module/Notifications/Introductions.php:210 +#: src/Module/Notifications/Introductions.php:214 msgid "No introductions." msgstr "" -#: src/Module/Notifications/Introductions.php:211 -#: src/Module/Notifications/Notifications.php:135 +#: src/Module/Notifications/Introductions.php:215 +#: src/Module/Notifications/Notifications.php:134 #, php-format msgid "No more %s notifications." msgstr "" @@ -8485,23 +8485,23 @@ msgstr "" msgid "You must be logged in to show this page." msgstr "" -#: src/Module/Notifications/Notifications.php:66 +#: src/Module/Notifications/Notifications.php:65 msgid "Network Notifications" msgstr "" -#: src/Module/Notifications/Notifications.php:72 +#: src/Module/Notifications/Notifications.php:71 msgid "System Notifications" msgstr "" -#: src/Module/Notifications/Notifications.php:78 +#: src/Module/Notifications/Notifications.php:77 msgid "Personal Notifications" msgstr "" -#: src/Module/Notifications/Notifications.php:84 +#: src/Module/Notifications/Notifications.php:83 msgid "Home Notifications" msgstr "" -#: src/Module/Notifications/Notifications.php:140 +#: src/Module/Notifications/Notifications.php:139 msgid "Show unread" msgstr "" @@ -8657,163 +8657,163 @@ msgstr "" msgid "Remove post" msgstr "" -#: src/Module/Register.php:80 +#: src/Module/Register.php:83 msgid "Only parent users can create additional accounts." msgstr "" -#: src/Module/Register.php:112 +#: src/Module/Register.php:115 msgid "" "You may (optionally) fill in this form via OpenID by supplying your OpenID " "and clicking \"Register\"." msgstr "" -#: src/Module/Register.php:113 +#: src/Module/Register.php:116 msgid "" "If you are not familiar with OpenID, please leave that field blank and fill " "in the rest of the items." msgstr "" -#: src/Module/Register.php:114 +#: src/Module/Register.php:117 msgid "Your OpenID (optional): " msgstr "" -#: src/Module/Register.php:123 +#: src/Module/Register.php:126 msgid "Include your profile in member directory?" msgstr "" -#: src/Module/Register.php:144 +#: src/Module/Register.php:147 msgid "Note for the admin" msgstr "" -#: src/Module/Register.php:144 +#: src/Module/Register.php:147 msgid "Leave a message for the admin, why you want to join this node" msgstr "" -#: src/Module/Register.php:145 +#: src/Module/Register.php:148 msgid "Membership on this site is by invitation only." msgstr "" -#: src/Module/Register.php:146 +#: src/Module/Register.php:149 msgid "Your invitation code: " msgstr "" -#: src/Module/Register.php:154 +#: src/Module/Register.php:157 msgid "Your Full Name (e.g. Joe Smith, real or real-looking): " msgstr "" -#: src/Module/Register.php:155 +#: src/Module/Register.php:158 msgid "" "Your Email Address: (Initial information will be send there, so this has to " "be an existing address.)" msgstr "" -#: src/Module/Register.php:156 +#: src/Module/Register.php:159 msgid "Please repeat your e-mail address:" msgstr "" -#: src/Module/Register.php:158 +#: src/Module/Register.php:161 msgid "Leave empty for an auto generated password." msgstr "" -#: src/Module/Register.php:160 +#: src/Module/Register.php:163 #, php-format msgid "" "Choose a profile nickname. This must begin with a text character. Your " "profile address on this site will then be \"nickname@%s\"." msgstr "" -#: src/Module/Register.php:161 +#: src/Module/Register.php:164 msgid "Choose a nickname: " msgstr "" -#: src/Module/Register.php:170 +#: src/Module/Register.php:173 msgid "Import your profile to this friendica instance" msgstr "" -#: src/Module/Register.php:177 +#: src/Module/Register.php:180 msgid "Note: This node explicitly contains adult content" msgstr "" -#: src/Module/Register.php:179 src/Module/Settings/Delegation.php:155 +#: src/Module/Register.php:182 src/Module/Settings/Delegation.php:155 msgid "Parent Password:" msgstr "" -#: src/Module/Register.php:179 src/Module/Settings/Delegation.php:155 +#: src/Module/Register.php:182 src/Module/Settings/Delegation.php:155 msgid "" "Please enter the password of the parent account to legitimize your request." msgstr "" -#: src/Module/Register.php:208 +#: src/Module/Register.php:211 msgid "Password doesn't match." msgstr "" -#: src/Module/Register.php:214 +#: src/Module/Register.php:217 msgid "Please enter your password." msgstr "" -#: src/Module/Register.php:256 +#: src/Module/Register.php:259 msgid "You have entered too much information." msgstr "" -#: src/Module/Register.php:279 +#: src/Module/Register.php:282 msgid "Please enter the identical mail address in the second field." msgstr "" -#: src/Module/Register.php:306 +#: src/Module/Register.php:309 msgid "The additional account was created." msgstr "" -#: src/Module/Register.php:331 +#: src/Module/Register.php:334 msgid "" "Registration successful. Please check your email for further instructions." msgstr "" -#: src/Module/Register.php:335 +#: src/Module/Register.php:338 #, php-format msgid "" "Failed to send email message. Here your accout details:
login: %s
" "password: %s

You can change your password after login." msgstr "" -#: src/Module/Register.php:341 +#: src/Module/Register.php:344 msgid "Registration successful." msgstr "" -#: src/Module/Register.php:346 src/Module/Register.php:353 +#: src/Module/Register.php:349 src/Module/Register.php:356 msgid "Your registration can not be processed." msgstr "" -#: src/Module/Register.php:352 +#: src/Module/Register.php:355 msgid "You have to leave a request note for the admin." msgstr "" -#: src/Module/Register.php:398 +#: src/Module/Register.php:401 msgid "Your registration is pending approval by the site owner." msgstr "" -#: src/Module/RemoteFollow.php:72 +#: src/Module/RemoteFollow.php:71 msgid "Profile unavailable." msgstr "" -#: src/Module/RemoteFollow.php:78 +#: src/Module/RemoteFollow.php:77 msgid "Invalid locator" msgstr "" -#: src/Module/RemoteFollow.php:85 +#: src/Module/RemoteFollow.php:84 msgid "The provided profile link doesn't seem to be valid" msgstr "" -#: src/Module/RemoteFollow.php:90 +#: src/Module/RemoteFollow.php:89 msgid "" "Remote subscription can't be done for your network. Please subscribe " "directly on your system." msgstr "" -#: src/Module/RemoteFollow.php:122 +#: src/Module/RemoteFollow.php:121 msgid "Friend/Connection Request" msgstr "" -#: src/Module/RemoteFollow.php:123 +#: src/Module/RemoteFollow.php:122 #, php-format msgid "" "Enter your Webfinger address (user@domain.tld) or profile URL here. If this " @@ -8821,14 +8821,14 @@ msgid "" "or %s directly on your system." msgstr "" -#: src/Module/RemoteFollow.php:124 +#: src/Module/RemoteFollow.php:123 #, php-format msgid "" "If you are not yet a member of the free social web, follow " "this link to find a public Friendica node and join us today." msgstr "" -#: src/Module/RemoteFollow.php:125 +#: src/Module/RemoteFollow.php:124 msgid "Your Webfinger address or profile URL:" msgstr "" @@ -8845,15 +8845,15 @@ msgstr "" msgid "Items tagged with: %s" msgstr "" -#: src/Module/Search/Saved.php:62 +#: src/Module/Search/Saved.php:58 msgid "Search term was not saved." msgstr "" -#: src/Module/Search/Saved.php:65 +#: src/Module/Search/Saved.php:61 msgid "Search term already saved." msgstr "" -#: src/Module/Search/Saved.php:71 +#: src/Module/Search/Saved.php:67 msgid "Search term was not removed." msgstr "" @@ -9718,7 +9718,7 @@ msgstr "" msgid "Exception thrown in %s:%d" msgstr "" -#: src/Module/Tos.php:58 src/Module/Tos.php:92 +#: src/Module/Tos.php:57 src/Module/Tos.php:91 msgid "" "At the time of registration, and for providing communications between the " "user account and their contacts, the user has to provide a display name (pen " @@ -9731,14 +9731,14 @@ msgid "" "settings, it is not necessary for communication." msgstr "" -#: src/Module/Tos.php:59 src/Module/Tos.php:93 +#: src/Module/Tos.php:58 src/Module/Tos.php:92 msgid "" "This data is required for communication and is passed on to the nodes of the " "communication partners and is stored there. Users can enter additional " "private data that may be transmitted to the communication partners accounts." msgstr "" -#: src/Module/Tos.php:60 src/Module/Tos.php:94 +#: src/Module/Tos.php:59 src/Module/Tos.php:93 #, php-format msgid "" "At any point in time a logged in user can export their account data from the " @@ -9748,7 +9748,7 @@ msgid "" "data will also be requested from the nodes of the communication partners." msgstr "" -#: src/Module/Tos.php:63 src/Module/Tos.php:91 +#: src/Module/Tos.php:62 src/Module/Tos.php:90 msgid "Privacy Statement" msgstr "" diff --git a/view/templates/contact_edit.tpl b/view/templates/contact_edit.tpl index 84384c479..18a16ddfc 100644 --- a/view/templates/contact_edit.tpl +++ b/view/templates/contact_edit.tpl @@ -65,7 +65,7 @@
- {{include file="field_checkbox.tpl" field=$notify}} + {{include file="field_checkbox.tpl" field=$notify_new_posts}} {{if $fetch_further_information}} {{include file="field_select.tpl" field=$fetch_further_information}} {{if $fetch_further_information.2 == 2 || $fetch_further_information.2 == 3}} {{include file="field_textarea.tpl" field=$ffi_keyword_denylist}} {{/if}} diff --git a/view/theme/frio/php/default.php b/view/theme/frio/php/default.php index d474a4d78..63291745f 100644 --- a/view/theme/frio/php/default.php +++ b/view/theme/frio/php/default.php @@ -77,7 +77,7 @@ $is_singleuser_class = $is_singleuser ? "is-singleuser" : "is-not-singleuser"; ?> - "> + "> t('Skip to main content'); ?> - {{include file="field_checkbox.tpl" field=$notify}} + {{include file="field_checkbox.tpl" field=$notify_new_posts}} {{if $fetch_further_information}} {{include file="field_select.tpl" field=$fetch_further_information}} {{if $fetch_further_information.2 == 2 || $fetch_further_information.2 == 3}} {{include file="field_textarea.tpl" field=$ffi_keyword_denylist}} {{/if}} diff --git a/view/theme/vier/templates/contact_edit.tpl b/view/theme/vier/templates/contact_edit.tpl index 32552942e..6bf958a23 100644 --- a/view/theme/vier/templates/contact_edit.tpl +++ b/view/theme/vier/templates/contact_edit.tpl @@ -66,7 +66,7 @@
- {{include file="field_checkbox.tpl" field=$notify}} + {{include file="field_checkbox.tpl" field=$notify_new_posts}} {{if $fetch_further_information}} {{include file="field_select.tpl" field=$fetch_further_information}} {{if $fetch_further_information.2 == 2 || $fetch_further_information.2 == 3}} {{include file="field_textarea.tpl" field=$ffi_keyword_denylist}} {{/if}}