Merge pull request #11005 from nupplaphil/feat/module_di
Introduce PSR-7 `ResponseInterface` for Modules executions
This commit is contained in:
commit
5aad46c7fb
289 changed files with 1648 additions and 1886 deletions
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
);
|
||||
|
|
|
|||
|
|
@ -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());
|
||||
|
|
|
|||
33
src/App.php
33
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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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';
|
||||
|
|
|
|||
|
|
@ -1,321 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* @copyright Copyright (C) 2010-2021, the Friendica project
|
||||
*
|
||||
* @license GNU AGPL version 3 or any later version
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
|
@ -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 </body> 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();
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
61
src/Capabilities/ICanCreateResponses.php
Normal file
61
src/Capabilities/ICanCreateResponses.php
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
<?php
|
||||
|
||||
namespace Friendica\Capabilities;
|
||||
|
||||
use Friendica\Network\HTTPException\InternalServerErrorException;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
|
||||
interface ICanCreateResponses
|
||||
{
|
||||
/**
|
||||
* This constant helps to find the specific return type of responses inside the headers array
|
||||
*/
|
||||
const X_HEADER = 'X-RESPONSE-TYPE';
|
||||
|
||||
const TYPE_HTML = 'html';
|
||||
const TYPE_XML = 'xml';
|
||||
const TYPE_JSON = 'json';
|
||||
const TYPE_ATOM = 'atom';
|
||||
const TYPE_RSS = 'rss';
|
||||
|
||||
const ALLOWED_TYPES = [
|
||||
self::TYPE_HTML,
|
||||
self::TYPE_XML,
|
||||
self::TYPE_JSON,
|
||||
self::TYPE_ATOM,
|
||||
self::TYPE_RSS
|
||||
];
|
||||
|
||||
/**
|
||||
* Adds a header entry to the module response
|
||||
*
|
||||
* @param string $header
|
||||
* @param string|null $key
|
||||
*/
|
||||
public function setHeader(string $header, ?string $key = null): void;
|
||||
|
||||
/**
|
||||
* Adds output content to the module response
|
||||
*
|
||||
* @param mixed $content
|
||||
*/
|
||||
public function addContent($content): void;
|
||||
|
||||
/**
|
||||
* Sets the response type of the current request
|
||||
*
|
||||
* @param string $type
|
||||
* @param string|null $content_type (optional) overrides the direct content_type, otherwise set the default one
|
||||
*
|
||||
* @throws InternalServerErrorException
|
||||
*/
|
||||
public function setType(string $type, ?string $content_type = null): void;
|
||||
|
||||
/**
|
||||
* Creates a PSR-7 compliant interface
|
||||
* @see https://www.php-fig.org/psr/psr-7/
|
||||
*
|
||||
* @return ResponseInterface
|
||||
*/
|
||||
public function generate(): ResponseInterface;
|
||||
}
|
||||
|
|
@ -2,59 +2,21 @@
|
|||
|
||||
namespace Friendica\Capabilities;
|
||||
|
||||
use Friendica\Network\HTTPException;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
|
||||
/**
|
||||
* This interface provides the capability to handle requests from clients and returns the desired outcome
|
||||
*/
|
||||
interface ICanHandleRequests
|
||||
{
|
||||
/**
|
||||
* Module GET method to display raw content from technical endpoints
|
||||
* @param array $post The $_POST content (in case of POST)
|
||||
* @param array $request The $_REQUEST content (in case of GET, POST)
|
||||
*
|
||||
* Extend this method if the module is supposed to return communication data,
|
||||
* e.g. from protocol implementations.
|
||||
*/
|
||||
public function rawContent();
|
||||
|
||||
/**
|
||||
* Module GET method to display any content
|
||||
* @return ResponseInterface responding to the request handling
|
||||
*
|
||||
* 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.
|
||||
* @throws HTTPException\InternalServerErrorException
|
||||
*/
|
||||
public function content(): string;
|
||||
|
||||
/**
|
||||
* 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();
|
||||
|
||||
/**
|
||||
* Module PATCH method to process submitted data
|
||||
*
|
||||
* Extend this method if the module is supposed to process PATCH requests.
|
||||
* Doesn't display any content
|
||||
*/
|
||||
public 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
|
||||
*/
|
||||
public function post();
|
||||
|
||||
/**
|
||||
* Module PUT method to process submitted data
|
||||
*
|
||||
* Extend this method if the module is supposed to process PUT requests.
|
||||
* Doesn't display any content
|
||||
*/
|
||||
public function put();
|
||||
|
||||
public function getClassName(): string;
|
||||
public function run(array $post = [], array $request = []): ResponseInterface;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -182,7 +182,7 @@ class Nav
|
|||
if (Session::isAuthenticated()) {
|
||||
$nav['logout'] = ['logout', DI::l10n()->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')];
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -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 '';
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ use Friendica\BaseModule;
|
|||
*/
|
||||
class AccountManagementControlDocument extends BaseModule
|
||||
{
|
||||
public function rawContent()
|
||||
protected function rawContent(array $request = [])
|
||||
{
|
||||
$output = [
|
||||
'version' => 1,
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ use Friendica\Util\Network;
|
|||
*/
|
||||
class Inbox extends BaseModule
|
||||
{
|
||||
public function rawContent()
|
||||
protected function rawContent(array $request = [])
|
||||
{
|
||||
$postdata = Network::postdata();
|
||||
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ use Friendica\Module\BaseAdmin;
|
|||
|
||||
class Index extends BaseAdmin
|
||||
{
|
||||
public function content(): string
|
||||
protected function content(array $request = []): string
|
||||
{
|
||||
parent::content();
|
||||
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ use Friendica\Module\BaseAdmin;
|
|||
|
||||
class DBSync extends BaseAdmin
|
||||
{
|
||||
public function content(): string
|
||||
protected function content(array $request = []): string
|
||||
{
|
||||
parent::content();
|
||||
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ use Friendica\Module\BaseAdmin;
|
|||
|
||||
class Federation extends BaseAdmin
|
||||
{
|
||||
public function content(): string
|
||||
protected function content(array $request = []): string
|
||||
{
|
||||
parent::content();
|
||||
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ use Friendica\Module\BaseAdmin;
|
|||
class Source extends BaseAdmin
|
||||
|
||||
{
|
||||
public function content(): string
|
||||
protected function content(array $request = []): string
|
||||
{
|
||||
parent::content();
|
||||
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ class View extends BaseAdmin
|
|||
{
|
||||
const LIMIT = 500;
|
||||
|
||||
public function content(): string
|
||||
protected function content(array $request = []): string
|
||||
{
|
||||
parent::content();
|
||||
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ use Friendica\Module\BaseAdmin;
|
|||
|
||||
class PhpInfo extends BaseAdmin
|
||||
{
|
||||
public function rawContent()
|
||||
protected function rawContent(array $request = [])
|
||||
{
|
||||
self::checkAdminAccess();
|
||||
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ use Friendica\Util\DateTimeFormat;
|
|||
*/
|
||||
class Queue extends BaseAdmin
|
||||
{
|
||||
public function content(): string
|
||||
protected function content(array $request = []): string
|
||||
{
|
||||
parent::content();
|
||||
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ use Friendica\Util\DateTimeFormat;
|
|||
|
||||
class Summary extends BaseAdmin
|
||||
{
|
||||
public function content(): string
|
||||
protected function content(array $request = []): string
|
||||
{
|
||||
parent::content();
|
||||
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ use Friendica\Util\Strings;
|
|||
|
||||
class Details extends BaseAdmin
|
||||
{
|
||||
public function content(): string
|
||||
protected function content(array $request = []): string
|
||||
{
|
||||
parent::content();
|
||||
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ use Friendica\Util\Strings;
|
|||
|
||||
class Index extends BaseAdmin
|
||||
{
|
||||
public function content(): string
|
||||
protected function content(array $request = []): string
|
||||
{
|
||||
parent::content();
|
||||
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ class Accounts extends BaseApi
|
|||
/**
|
||||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||
*/
|
||||
public function rawContent()
|
||||
protected function rawContent(array $request = [])
|
||||
{
|
||||
$uid = self::getCurrentUserID();
|
||||
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ class Statuses extends BaseApi
|
|||
/**
|
||||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||
*/
|
||||
public function rawContent()
|
||||
protected function rawContent(array $request = [])
|
||||
{
|
||||
$uid = self::getCurrentUserID();
|
||||
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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' => '',
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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());
|
||||
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ class Endorsements extends BaseApi
|
|||
/**
|
||||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||
*/
|
||||
public function rawContent()
|
||||
protected function rawContent(array $request = [])
|
||||
{
|
||||
System::jsonExit([]);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ class Peers extends BaseApi
|
|||
/**
|
||||
* @throws HTTPException\InternalServerErrorException
|
||||
*/
|
||||
public function rawContent()
|
||||
protected function rawContent(array $request = [])
|
||||
{
|
||||
$return = [];
|
||||
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ class Rules extends BaseApi
|
|||
/**
|
||||
* @throws HTTPException\InternalServerErrorException
|
||||
*/
|
||||
public function rawContent()
|
||||
protected function rawContent(array $request = [])
|
||||
{
|
||||
$rules = [];
|
||||
$id = 0;
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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']);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ class Card extends BaseApi
|
|||
/**
|
||||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||
*/
|
||||
public function rawContent()
|
||||
protected function rawContent(array $request = [])
|
||||
{
|
||||
$uid = self::getCurrentUserID();
|
||||
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ class Context extends BaseApi
|
|||
/**
|
||||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||
*/
|
||||
public function rawContent()
|
||||
protected function rawContent(array $request = [])
|
||||
{
|
||||
$uid = self::getCurrentUserID();
|
||||
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ class FavouritedBy extends BaseApi
|
|||
/**
|
||||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||
*/
|
||||
public function rawContent()
|
||||
protected function rawContent(array $request = [])
|
||||
{
|
||||
$uid = self::getCurrentUserID();
|
||||
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ class RebloggedBy extends BaseApi
|
|||
/**
|
||||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||
*/
|
||||
public function rawContent()
|
||||
protected function rawContent(array $request = [])
|
||||
{
|
||||
$uid = self::getCurrentUserID();
|
||||
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ class PublicTimeline extends BaseApi
|
|||
/**
|
||||
* @throws HTTPException\InternalServerErrorException
|
||||
*/
|
||||
public function rawContent()
|
||||
protected function rawContent(array $request = [])
|
||||
{
|
||||
$uid = self::getCurrentUserID();
|
||||
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
||||
|
|
|
|||
|
|
@ -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'])) {
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ abstract class BaseAdmin extends BaseModule
|
|||
}
|
||||
}
|
||||
|
||||
public function content(): string
|
||||
protected function content(array $request = []): string
|
||||
{
|
||||
self::checkAdminAccess(true);
|
||||
|
||||
|
|
|
|||
|
|
@ -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.'));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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') {
|
||||
|
|
|
|||
|
|
@ -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 '';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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';
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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'];
|
||||
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
||||
|
|
|
|||
|
|
@ -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']);
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ use Friendica\Util\Strings;
|
|||
*/
|
||||
class Hovercard extends BaseModule
|
||||
{
|
||||
public function rawContent()
|
||||
protected function rawContent(array $request = [])
|
||||
{
|
||||
$contact_url = $_REQUEST['url'] ?? '';
|
||||
|
||||
|
|
|
|||
|
|
@ -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'];
|
||||
|
||||
|
|
|
|||
|
|
@ -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.'));
|
||||
|
|
|
|||
|
|
@ -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']);
|
||||
|
|
|
|||
|
|
@ -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 <strong>may</strong> 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),
|
||||
|
|
|
|||
|
|
@ -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']);
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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');
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
||||
|
|
|
|||
|
|
@ -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'] ?? '';
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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'])) {
|
||||
|
|
|
|||
|
|
@ -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.'));
|
||||
|
|
|
|||
|
|
@ -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';
|
||||
|
||||
|
|
|
|||
|
|
@ -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.'));
|
||||
|
|
|
|||
|
|
@ -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.'));
|
||||
|
|
|
|||
|
|
@ -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.'));
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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'] ?? ''));
|
||||
|
||||
|
|
|
|||
|
|
@ -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.'));
|
||||
|
|
|
|||
|
|
@ -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']);
|
||||
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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.'));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ use Friendica\Util\Strings;
|
|||
*/
|
||||
class Hashtag extends BaseModule
|
||||
{
|
||||
public function content(): string
|
||||
protected function content(array $request = []): string
|
||||
{
|
||||
$result = [];
|
||||
|
||||
|
|
|
|||
|
|
@ -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');
|
||||
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
||||
|
|
|
|||
|
|
@ -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.'));
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ use Friendica\Network\HTTPException;
|
|||
*/
|
||||
class Follow extends BaseModule
|
||||
{
|
||||
public function rawContent()
|
||||
protected function rawContent(array $request = [])
|
||||
{
|
||||
$l10n = DI::l10n();
|
||||
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ use Friendica\Network\HTTPException;
|
|||
*/
|
||||
class Ignore extends BaseModule
|
||||
{
|
||||
public function rawContent()
|
||||
protected function rawContent(array $request = [])
|
||||
{
|
||||
$l10n = DI::l10n();
|
||||
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ use Friendica\Network\HTTPException;
|
|||
*/
|
||||
class Pin extends BaseModule
|
||||
{
|
||||
public function rawContent()
|
||||
protected function rawContent(array $request = [])
|
||||
{
|
||||
$l10n = DI::l10n();
|
||||
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ use Friendica\Network\HTTPException;
|
|||
*/
|
||||
class Star extends BaseModule
|
||||
{
|
||||
public function rawContent()
|
||||
protected function rawContent(array $request = [])
|
||||
{
|
||||
$l10n = DI::l10n();
|
||||
|
||||
|
|
|
|||
|
|
@ -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');
|
||||
|
||||
|
|
|
|||
|
|
@ -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');
|
||||
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ use Friendica\DI;
|
|||
|
||||
class Manifest extends BaseModule
|
||||
{
|
||||
public function rawContent()
|
||||
protected function rawContent(array $request = [])
|
||||
{
|
||||
$config = DI::config();
|
||||
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ use Friendica\Model\User;
|
|||
*/
|
||||
class NoScrape extends BaseModule
|
||||
{
|
||||
public function rawContent()
|
||||
protected function rawContent(array $request = [])
|
||||
{
|
||||
$a = DI::app();
|
||||
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue