Merge remote-tracking branch 'upstream/develop' into api4
This commit is contained in:
commit
b67c10812a
|
@ -566,7 +566,6 @@ Here is a complete list of all hook callbacks with file locations (as of 24-Sep-
|
||||||
Hook::callAll($a->module.'_mod_init', $placeholder);
|
Hook::callAll($a->module.'_mod_init', $placeholder);
|
||||||
Hook::callAll($a->module.'_mod_init', $placeholder);
|
Hook::callAll($a->module.'_mod_init', $placeholder);
|
||||||
Hook::callAll($a->module.'_mod_post', $_POST);
|
Hook::callAll($a->module.'_mod_post', $_POST);
|
||||||
Hook::callAll($a->module.'_mod_afterpost', $placeholder);
|
|
||||||
Hook::callAll($a->module.'_mod_content', $arr);
|
Hook::callAll($a->module.'_mod_content', $arr);
|
||||||
Hook::callAll($a->module.'_mod_aftercontent', $arr);
|
Hook::callAll($a->module.'_mod_aftercontent', $arr);
|
||||||
Hook::callAll('page_end', DI::page()['content']);
|
Hook::callAll('page_end', DI::page()['content']);
|
||||||
|
|
|
@ -202,7 +202,6 @@ Eine komplette Liste aller Hook-Callbacks mit den zugehörigen Dateien (am 01-Ap
|
||||||
Hook::callAll($a->module.'_mod_init', $placeholder);
|
Hook::callAll($a->module.'_mod_init', $placeholder);
|
||||||
Hook::callAll($a->module.'_mod_init', $placeholder);
|
Hook::callAll($a->module.'_mod_init', $placeholder);
|
||||||
Hook::callAll($a->module.'_mod_post', $_POST);
|
Hook::callAll($a->module.'_mod_post', $_POST);
|
||||||
Hook::callAll($a->module.'_mod_afterpost', $placeholder);
|
|
||||||
Hook::callAll($a->module.'_mod_content', $arr);
|
Hook::callAll($a->module.'_mod_content', $arr);
|
||||||
Hook::callAll($a->module.'_mod_aftercontent', $arr);
|
Hook::callAll($a->module.'_mod_aftercontent', $arr);
|
||||||
Hook::callAll('page_end', DI::page()['content']);
|
Hook::callAll('page_end', DI::page()['content']);
|
||||||
|
|
|
@ -41,10 +41,11 @@ $a = \Friendica\DI::app();
|
||||||
\Friendica\DI::mode()->setExecutor(\Friendica\App\Mode::INDEX);
|
\Friendica\DI::mode()->setExecutor(\Friendica\App\Mode::INDEX);
|
||||||
|
|
||||||
$a->runFrontend(
|
$a->runFrontend(
|
||||||
$dice->create(\Friendica\App\Module::class),
|
$dice->create(\Friendica\App\ModuleController::class),
|
||||||
$dice->create(\Friendica\App\Router::class),
|
$dice->create(\Friendica\App\Router::class),
|
||||||
$dice->create(\Friendica\Core\PConfig\Capability\IManagePersonalConfigValues::class),
|
$dice->create(\Friendica\Core\PConfig\Capability\IManagePersonalConfigValues::class),
|
||||||
$dice->create(\Friendica\Security\Authentication::class),
|
$dice->create(\Friendica\Security\Authentication::class),
|
||||||
$dice->create(\Friendica\App\Page::class),
|
$dice->create(\Friendica\App\Page::class),
|
||||||
|
$dice,
|
||||||
$start_time
|
$start_time
|
||||||
);
|
);
|
||||||
|
|
|
@ -40,7 +40,7 @@ use Friendica\Protocol\DFRN;
|
||||||
function display_init(App $a)
|
function display_init(App $a)
|
||||||
{
|
{
|
||||||
if (ActivityPub::isRequest()) {
|
if (ActivityPub::isRequest()) {
|
||||||
Objects::rawContent(['guid' => DI::args()->getArgv()[1] ?? null]);
|
(new Objects(['guid' => DI::args()->getArgv()[1] ?? null]))->rawContent();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DI::config()->get('system', 'block_public') && !Session::isAuthenticated()) {
|
if (DI::config()->get('system', 'block_public') && !Session::isAuthenticated()) {
|
||||||
|
|
|
@ -122,7 +122,7 @@ function unfollow_process(string $url)
|
||||||
|
|
||||||
$owner = User::getOwnerDataById($uid);
|
$owner = User::getOwnerDataById($uid);
|
||||||
if (!$owner) {
|
if (!$owner) {
|
||||||
\Friendica\Module\Security\Logout::init();
|
(new \Friendica\Module\Security\Logout())->init();
|
||||||
// NOTREACHED
|
// NOTREACHED
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
15
src/App.php
15
src/App.php
|
@ -21,10 +21,11 @@
|
||||||
|
|
||||||
namespace Friendica;
|
namespace Friendica;
|
||||||
|
|
||||||
|
use Dice\Dice;
|
||||||
use Exception;
|
use Exception;
|
||||||
use Friendica\App\Arguments;
|
use Friendica\App\Arguments;
|
||||||
use Friendica\App\BaseURL;
|
use Friendica\App\BaseURL;
|
||||||
use Friendica\App\Module;
|
use Friendica\App\ModuleController;
|
||||||
use Friendica\Core\Config\Factory\Config;
|
use Friendica\Core\Config\Factory\Config;
|
||||||
use Friendica\Module\Maintenance;
|
use Friendica\Module\Maintenance;
|
||||||
use Friendica\Security\Authentication;
|
use Friendica\Security\Authentication;
|
||||||
|
@ -566,16 +567,16 @@ class App
|
||||||
*
|
*
|
||||||
* This probably should change to limit the size of this monster method.
|
* This probably should change to limit the size of this monster method.
|
||||||
*
|
*
|
||||||
* @param App\Module $module The determined module
|
* @param App\ModuleController $module The determined module
|
||||||
* @param App\Router $router
|
* @param App\Router $router
|
||||||
* @param IManagePersonalConfigValues $pconfig
|
* @param IManagePersonalConfigValues $pconfig
|
||||||
* @param Authentication $auth The Authentication backend of the node
|
* @param Authentication $auth The Authentication backend of the node
|
||||||
* @param App\Page $page The Friendica page printing container
|
* @param App\Page $page The Friendica page printing container
|
||||||
*
|
*
|
||||||
* @throws HTTPException\InternalServerErrorException
|
* @throws HTTPException\InternalServerErrorException
|
||||||
* @throws \ImagickException
|
* @throws \ImagickException
|
||||||
*/
|
*/
|
||||||
public function runFrontend(App\Module $module, App\Router $router, IManagePersonalConfigValues $pconfig, Authentication $auth, App\Page $page, float $start_time)
|
public function runFrontend(App\ModuleController $module, App\Router $router, IManagePersonalConfigValues $pconfig, Authentication $auth, App\Page $page, Dice $dice, float $start_time)
|
||||||
{
|
{
|
||||||
$this->profiler->set($start_time, 'start');
|
$this->profiler->set($start_time, 'start');
|
||||||
$this->profiler->set(microtime(true), 'classinit');
|
$this->profiler->set(microtime(true), 'classinit');
|
||||||
|
@ -702,11 +703,11 @@ class App
|
||||||
$page['page_title'] = $moduleName;
|
$page['page_title'] = $moduleName;
|
||||||
|
|
||||||
if (!$this->mode->isInstall() && !$this->mode->has(App\Mode::MAINTENANCEDISABLED)) {
|
if (!$this->mode->isInstall() && !$this->mode->has(App\Mode::MAINTENANCEDISABLED)) {
|
||||||
$module = new Module('maintenance', Maintenance::class);
|
$module = new ModuleController('maintenance', new Maintenance());
|
||||||
} else {
|
} else {
|
||||||
// determine the module class and save it to the module instance
|
// 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)
|
// @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);
|
$module = $module->determineClass($this->args, $router, $this->config, $dice);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Let the module run it's internal process (init, get, post, ...)
|
// Let the module run it's internal process (init, get, post, ...)
|
||||||
|
|
|
@ -139,14 +139,14 @@ class Mode
|
||||||
/**
|
/**
|
||||||
* Checks if the site is called via a backend process
|
* 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 bool $isBackend True, if the call is from a backend script (daemon, worker, ...)
|
||||||
* @param Module $module The pre-loaded module (just name, not class!)
|
* @param ModuleController $module The pre-loaded module (just name, not class!)
|
||||||
* @param array $server The $_SERVER variable
|
* @param array $server The $_SERVER variable
|
||||||
* @param MobileDetect $mobileDetect The mobile detection library
|
* @param MobileDetect $mobileDetect The mobile detection library
|
||||||
*
|
*
|
||||||
* @return Mode returns the determined mode
|
* @return Mode returns the determined mode
|
||||||
*/
|
*/
|
||||||
public function determineRunMode(bool $isBackend, Module $module, array $server, MobileDetect $mobileDetect)
|
public function determineRunMode(bool $isBackend, ModuleController $module, array $server, MobileDetect $mobileDetect)
|
||||||
{
|
{
|
||||||
foreach (self::BACKEND_CONTENT_TYPES as $type) {
|
foreach (self::BACKEND_CONTENT_TYPES as $type) {
|
||||||
if (strpos(strtolower($server['HTTP_ACCEPT'] ?? ''), $type) !== false) {
|
if (strpos(strtolower($server['HTTP_ACCEPT'] ?? ''), $type) !== false) {
|
||||||
|
|
|
@ -21,8 +21,9 @@
|
||||||
|
|
||||||
namespace Friendica\App;
|
namespace Friendica\App;
|
||||||
|
|
||||||
|
use Dice\Dice;
|
||||||
use Friendica\App;
|
use Friendica\App;
|
||||||
use Friendica\BaseModule;
|
use Friendica\Capabilities\ICanHandleRequests;
|
||||||
use Friendica\Core;
|
use Friendica\Core;
|
||||||
use Friendica\Core\Config\Capability\IManageConfigValues;
|
use Friendica\Core\Config\Capability\IManageConfigValues;
|
||||||
use Friendica\LegacyModule;
|
use Friendica\LegacyModule;
|
||||||
|
@ -38,7 +39,7 @@ use Psr\Log\LoggerInterface;
|
||||||
/**
|
/**
|
||||||
* Holds the common context of the current, loaded module
|
* Holds the common context of the current, loaded module
|
||||||
*/
|
*/
|
||||||
class Module
|
class ModuleController
|
||||||
{
|
{
|
||||||
const DEFAULT = 'home';
|
const DEFAULT = 'home';
|
||||||
const DEFAULT_CLASS = Home::class;
|
const DEFAULT_CLASS = Home::class;
|
||||||
|
@ -77,18 +78,13 @@ class Module
|
||||||
/**
|
/**
|
||||||
* @var string The module name
|
* @var string The module name
|
||||||
*/
|
*/
|
||||||
|
private $moduleName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var ICanHandleRequests The module object
|
||||||
|
*/
|
||||||
private $module;
|
private $module;
|
||||||
|
|
||||||
/**
|
|
||||||
* @var BaseModule The module class
|
|
||||||
*/
|
|
||||||
private $module_class;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var array The module parameters
|
|
||||||
*/
|
|
||||||
private $module_parameters;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var bool true, if the module is a backend module
|
* @var bool true, if the module is a backend module
|
||||||
*/
|
*/
|
||||||
|
@ -103,40 +99,33 @@ class Module
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getName()
|
public function getName()
|
||||||
|
{
|
||||||
|
return $this->moduleName;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return ICanHandleRequests The base module object
|
||||||
|
*/
|
||||||
|
public function getModule(): ICanHandleRequests
|
||||||
{
|
{
|
||||||
return $this->module;
|
return $this->module;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return string The base class name
|
|
||||||
*/
|
|
||||||
public function getClassName()
|
|
||||||
{
|
|
||||||
return $this->module_class;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return array The module parameters extracted from the route
|
|
||||||
*/
|
|
||||||
public function getParameters()
|
|
||||||
{
|
|
||||||
return $this->module_parameters;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return bool True, if the current module is a backend module
|
* @return bool True, if the current module is a backend module
|
||||||
* @see Module::BACKEND_MODULES for a list
|
* @see ModuleController::BACKEND_MODULES for a list
|
||||||
*/
|
*/
|
||||||
public function isBackend()
|
public function isBackend()
|
||||||
{
|
{
|
||||||
return $this->isBackend;
|
return $this->isBackend;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function __construct(string $module = self::DEFAULT, string $moduleClass = self::DEFAULT_CLASS, array $moduleParameters = [], bool $isBackend = false, bool $printNotAllowedAddon = false)
|
public function __construct(string $moduleName = self::DEFAULT, ICanHandleRequests $module = null, bool $isBackend = false, bool $printNotAllowedAddon = false)
|
||||||
{
|
{
|
||||||
$this->module = $module;
|
$defaultClass = static::DEFAULT_CLASS;
|
||||||
$this->module_class = $moduleClass;
|
|
||||||
$this->module_parameters = $moduleParameters;
|
$this->moduleName = $moduleName;
|
||||||
|
$this->module = $module ?? new $defaultClass();
|
||||||
$this->isBackend = $isBackend;
|
$this->isBackend = $isBackend;
|
||||||
$this->printNotAllowedAddon = $printNotAllowedAddon;
|
$this->printNotAllowedAddon = $printNotAllowedAddon;
|
||||||
}
|
}
|
||||||
|
@ -146,9 +135,9 @@ class Module
|
||||||
*
|
*
|
||||||
* @param Arguments $args The Friendica arguments
|
* @param Arguments $args The Friendica arguments
|
||||||
*
|
*
|
||||||
* @return Module The module with the determined module
|
* @return ModuleController The module with the determined module
|
||||||
*/
|
*/
|
||||||
public function determineModule(Arguments $args)
|
public function determineName(Arguments $args)
|
||||||
{
|
{
|
||||||
if ($args->getArgc() > 0) {
|
if ($args->getArgc() > 0) {
|
||||||
$module = str_replace('.', '_', $args->get(0));
|
$module = str_replace('.', '_', $args->get(0));
|
||||||
|
@ -162,27 +151,28 @@ class Module
|
||||||
$module = "login";
|
$module = "login";
|
||||||
}
|
}
|
||||||
|
|
||||||
$isBackend = in_array($module, Module::BACKEND_MODULES);;
|
$isBackend = in_array($module, ModuleController::BACKEND_MODULES);
|
||||||
|
|
||||||
return new Module($module, $this->module_class, [], $isBackend, $this->printNotAllowedAddon);
|
return new ModuleController($module, null, $isBackend, $this->printNotAllowedAddon);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determine the class of the current module
|
* Determine the class of the current module
|
||||||
*
|
*
|
||||||
* @param Arguments $args The Friendica execution arguments
|
* @param Arguments $args The Friendica execution arguments
|
||||||
* @param Router $router The Friendica routing instance
|
* @param Router $router The Friendica routing instance
|
||||||
* @param IManageConfigValues $config The Friendica Configuration
|
* @param IManageConfigValues $config The Friendica Configuration
|
||||||
|
* @param Dice $dice The Dependency Injection container
|
||||||
*
|
*
|
||||||
* @return Module The determined module of this call
|
* @return ModuleController The determined module of this call
|
||||||
*
|
*
|
||||||
* @throws \Exception
|
* @throws \Exception
|
||||||
*/
|
*/
|
||||||
public function determineClass(Arguments $args, Router $router, IManageConfigValues $config)
|
public function determineClass(Arguments $args, Router $router, IManageConfigValues $config, Dice $dice)
|
||||||
{
|
{
|
||||||
$printNotAllowedAddon = false;
|
$printNotAllowedAddon = false;
|
||||||
|
|
||||||
$module_class = null;
|
$module_class = null;
|
||||||
$module_parameters = [];
|
$module_parameters = [];
|
||||||
/**
|
/**
|
||||||
* ROUTING
|
* ROUTING
|
||||||
|
@ -191,22 +181,22 @@ class Module
|
||||||
* post() and/or content() static methods can be respectively called to produce a data change or an output.
|
* post() and/or content() static methods can be respectively called to produce a data change or an output.
|
||||||
**/
|
**/
|
||||||
try {
|
try {
|
||||||
$module_class = $router->getModuleClass($args->getCommand());
|
$module_class = $router->getModuleClass($args->getCommand());
|
||||||
$module_parameters = $router->getModuleParameters();
|
$module_parameters[] = $router->getModuleParameters();
|
||||||
} catch (MethodNotAllowedException $e) {
|
} catch (MethodNotAllowedException $e) {
|
||||||
$module_class = MethodNotAllowed::class;
|
$module_class = MethodNotAllowed::class;
|
||||||
} catch (NotFoundException $e) {
|
} catch (NotFoundException $e) {
|
||||||
// Then we try addon-provided modules that we wrap in the LegacyModule class
|
// Then we try addon-provided modules that we wrap in the LegacyModule class
|
||||||
if (Core\Addon::isEnabled($this->module) && file_exists("addon/{$this->module}/{$this->module}.php")) {
|
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
|
//Check if module is an app and if public access to apps is allowed or not
|
||||||
$privateapps = $config->get('config', 'private_addons', false);
|
$privateapps = $config->get('config', 'private_addons', false);
|
||||||
if ((!local_user()) && Core\Hook::isAddonApp($this->module) && $privateapps) {
|
if ((!local_user()) && Core\Hook::isAddonApp($this->moduleName) && $privateapps) {
|
||||||
$printNotAllowedAddon = true;
|
$printNotAllowedAddon = true;
|
||||||
} else {
|
} else {
|
||||||
include_once "addon/{$this->module}/{$this->module}.php";
|
include_once "addon/{$this->moduleName}/{$this->moduleName}.php";
|
||||||
if (function_exists($this->module . '_module')) {
|
if (function_exists($this->moduleName . '_module')) {
|
||||||
LegacyModule::setModuleFile("addon/{$this->module}/{$this->module}.php");
|
$module_parameters[] = "addon/{$this->moduleName}/{$this->moduleName}.php";
|
||||||
$module_class = LegacyModule::class;
|
$module_class = LegacyModule::class;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -214,15 +204,18 @@ class Module
|
||||||
/* Finally, we look for a 'standard' program module in the 'mod' directory
|
/* Finally, we look for a 'standard' program module in the 'mod' directory
|
||||||
* We emulate a Module class through the LegacyModule class
|
* We emulate a Module class through the LegacyModule class
|
||||||
*/
|
*/
|
||||||
if (!$module_class && file_exists("mod/{$this->module}.php")) {
|
if (!$module_class && file_exists("mod/{$this->moduleName}.php")) {
|
||||||
LegacyModule::setModuleFile("mod/{$this->module}.php");
|
$module_parameters[] = "mod/{$this->moduleName}.php";
|
||||||
$module_class = LegacyModule::class;
|
$module_class = LegacyModule::class;
|
||||||
}
|
}
|
||||||
|
|
||||||
$module_class = $module_class ?: PageNotFound::class;
|
$module_class = $module_class ?: PageNotFound::class;
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Module($this->module, $module_class, $module_parameters, $this->isBackend, $printNotAllowedAddon);
|
/** @var ICanHandleRequests $module */
|
||||||
|
$module = $dice->create($module_class, $module_parameters);
|
||||||
|
|
||||||
|
return new ModuleController($this->moduleName, $module, $this->isBackend, $printNotAllowedAddon);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -251,7 +244,7 @@ class Module
|
||||||
*
|
*
|
||||||
* Otherwise we are going to emit a 404 not found.
|
* Otherwise we are going to emit a 404 not found.
|
||||||
*/
|
*/
|
||||||
if ($this->module_class === PageNotFound::class) {
|
if ($this->module === PageNotFound::class) {
|
||||||
$queryString = $server['QUERY_STRING'];
|
$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.
|
// 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) {
|
if (!empty($queryString) && preg_match('/{[0-9]}/', $queryString) !== 0) {
|
||||||
|
@ -302,34 +295,31 @@ class Module
|
||||||
$profiler->set(microtime(true), 'ready');
|
$profiler->set(microtime(true), 'ready');
|
||||||
$timestamp = microtime(true);
|
$timestamp = microtime(true);
|
||||||
|
|
||||||
Core\Hook::callAll($this->module . '_mod_init', $placeholder);
|
Core\Hook::callAll($this->moduleName . '_mod_init', $placeholder);
|
||||||
|
|
||||||
call_user_func([$this->module_class, 'init'], $this->module_parameters);
|
$this->module->init();
|
||||||
|
|
||||||
$profiler->set(microtime(true) - $timestamp, 'init');
|
$profiler->set(microtime(true) - $timestamp, 'init');
|
||||||
|
|
||||||
if ($server['REQUEST_METHOD'] === Router::DELETE) {
|
if ($server['REQUEST_METHOD'] === Router::DELETE) {
|
||||||
call_user_func([$this->module_class, 'delete'], $this->module_parameters);
|
$this->module->delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($server['REQUEST_METHOD'] === Router::PATCH) {
|
if ($server['REQUEST_METHOD'] === Router::PATCH) {
|
||||||
call_user_func([$this->module_class, 'patch'], $this->module_parameters);
|
$this->module->patch();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($server['REQUEST_METHOD'] === Router::POST) {
|
if ($server['REQUEST_METHOD'] === Router::POST) {
|
||||||
Core\Hook::callAll($this->module . '_mod_post', $post);
|
Core\Hook::callAll($this->moduleName . '_mod_post', $post);
|
||||||
call_user_func([$this->module_class, 'post'], $this->module_parameters);
|
$this->module->post();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($server['REQUEST_METHOD'] === Router::PUT) {
|
if ($server['REQUEST_METHOD'] === Router::PUT) {
|
||||||
call_user_func([$this->module_class, 'put'], $this->module_parameters);
|
$this->module->put();
|
||||||
}
|
}
|
||||||
|
|
||||||
Core\Hook::callAll($this->module . '_mod_afterpost', $placeholder);
|
|
||||||
call_user_func([$this->module_class, 'afterpost'], $this->module_parameters);
|
|
||||||
|
|
||||||
// "rawContent" is especially meant for technical endpoints.
|
// "rawContent" is especially meant for technical endpoints.
|
||||||
// This endpoint doesn't need any theme initialization or other comparable stuff.
|
// This endpoint doesn't need any theme initialization or other comparable stuff.
|
||||||
call_user_func([$this->module_class, 'rawContent'], $this->module_parameters);
|
$this->module->rawContent();
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -191,14 +191,14 @@ class Page implements ArrayAccess
|
||||||
* - head.tpl template
|
* - head.tpl template
|
||||||
*
|
*
|
||||||
* @param App $app The Friendica App instance
|
* @param App $app The Friendica App instance
|
||||||
* @param Module $module The loaded Friendica module
|
* @param ModuleController $module The loaded Friendica module
|
||||||
* @param L10n $l10n The l10n language instance
|
* @param L10n $l10n The l10n language instance
|
||||||
* @param IManageConfigValues $config The Friendica configuration
|
* @param IManageConfigValues $config The Friendica configuration
|
||||||
* @param IManagePersonalConfigValues $pConfig The Friendica personal configuration (for user)
|
* @param IManagePersonalConfigValues $pConfig The Friendica personal configuration (for user)
|
||||||
*
|
*
|
||||||
* @throws HTTPException\InternalServerErrorException
|
* @throws HTTPException\InternalServerErrorException
|
||||||
*/
|
*/
|
||||||
private function initHead(App $app, Module $module, L10n $l10n, IManageConfigValues $config, IManagePersonalConfigValues $pConfig)
|
private function initHead(App $app, ModuleController $module, L10n $l10n, IManageConfigValues $config, IManagePersonalConfigValues $pConfig)
|
||||||
{
|
{
|
||||||
$interval = ((local_user()) ? $pConfig->get(local_user(), 'system', 'update_interval') : 40000);
|
$interval = ((local_user()) ? $pConfig->get(local_user(), 'system', 'update_interval') : 40000);
|
||||||
|
|
||||||
|
@ -337,26 +337,24 @@ class Page implements ArrayAccess
|
||||||
* - module content
|
* - module content
|
||||||
* - hooks for content
|
* - hooks for content
|
||||||
*
|
*
|
||||||
* @param Module $module The module
|
* @param ModuleController $module The module
|
||||||
* @param Mode $mode The Friendica execution mode
|
* @param Mode $mode The Friendica execution mode
|
||||||
*
|
*
|
||||||
* @throws HTTPException\InternalServerErrorException
|
* @throws HTTPException\InternalServerErrorException
|
||||||
*/
|
*/
|
||||||
private function initContent(Module $module, Mode $mode)
|
private function initContent(ModuleController $module, Mode $mode)
|
||||||
{
|
{
|
||||||
$content = '';
|
$content = '';
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$moduleClass = $module->getClassName();
|
$moduleClass = $module->getModule();
|
||||||
|
|
||||||
$arr = ['content' => $content];
|
$arr = ['content' => $content];
|
||||||
Hook::callAll($moduleClass . '_mod_content', $arr);
|
Hook::callAll($moduleClass->getClassName() . '_mod_content', $arr);
|
||||||
$content = $arr['content'];
|
$content = $arr['content'];
|
||||||
$arr = ['content' => call_user_func([$moduleClass, 'content'], $module->getParameters())];
|
$content .= $module->getModule()->content();
|
||||||
Hook::callAll($moduleClass . '_mod_aftercontent', $arr);
|
|
||||||
$content .= $arr['content'];
|
|
||||||
} catch (HTTPException $e) {
|
} catch (HTTPException $e) {
|
||||||
$content = ModuleHTTPException::content($e);
|
$content = (new ModuleHTTPException())->content($e);
|
||||||
}
|
}
|
||||||
|
|
||||||
// initialise content region
|
// initialise content region
|
||||||
|
@ -392,14 +390,14 @@ class Page implements ArrayAccess
|
||||||
* @param App $app The Friendica App
|
* @param App $app The Friendica App
|
||||||
* @param BaseURL $baseURL The Friendica Base URL
|
* @param BaseURL $baseURL The Friendica Base URL
|
||||||
* @param Mode $mode The current node mode
|
* @param Mode $mode The current node mode
|
||||||
* @param Module $module The loaded Friendica module
|
* @param ModuleController $module The loaded Friendica module
|
||||||
* @param L10n $l10n The l10n language class
|
* @param L10n $l10n The l10n language class
|
||||||
* @param IManageConfigValues $config The Configuration of this node
|
* @param IManageConfigValues $config The Configuration of this node
|
||||||
* @param IManagePersonalConfigValues $pconfig The personal/user configuration
|
* @param IManagePersonalConfigValues $pconfig The personal/user configuration
|
||||||
*
|
*
|
||||||
* @throws HTTPException\InternalServerErrorException
|
* @throws HTTPException\InternalServerErrorException
|
||||||
*/
|
*/
|
||||||
public function run(App $app, BaseURL $baseURL, Mode $mode, Module $module, L10n $l10n, Profiler $profiler, IManageConfigValues $config, IManagePersonalConfigValues $pconfig)
|
public function run(App $app, BaseURL $baseURL, Mode $mode, ModuleController $module, L10n $l10n, Profiler $profiler, IManageConfigValues $config, IManagePersonalConfigValues $pconfig)
|
||||||
{
|
{
|
||||||
$moduleName = $module->getName();
|
$moduleName = $module->getName();
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
|
|
||||||
namespace Friendica;
|
namespace Friendica;
|
||||||
|
|
||||||
|
use Friendica\Capabilities\ICanHandleRequests;
|
||||||
use Friendica\Core\Logger;
|
use Friendica\Core\Logger;
|
||||||
use Friendica\Model\User;
|
use Friendica\Model\User;
|
||||||
|
|
||||||
|
@ -33,94 +34,73 @@ use Friendica\Model\User;
|
||||||
*
|
*
|
||||||
* @author Hypolite Petovan <hypolite@mrpetovan.com>
|
* @author Hypolite Petovan <hypolite@mrpetovan.com>
|
||||||
*/
|
*/
|
||||||
abstract class BaseModule
|
abstract class BaseModule implements ICanHandleRequests
|
||||||
{
|
{
|
||||||
|
/** @var array */
|
||||||
|
protected $parameters = [];
|
||||||
|
|
||||||
|
public function __construct(array $parameters = [])
|
||||||
|
{
|
||||||
|
$this->parameters = $parameters;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialization method common to both content() and post()
|
* {@inheritDoc}
|
||||||
*
|
|
||||||
* Extend this method if you need to do any shared processing before both
|
|
||||||
* content() or post()
|
|
||||||
*/
|
*/
|
||||||
public static function init(array $parameters = [])
|
public function init()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Module GET method to display raw content from technical endpoints
|
* {@inheritDoc}
|
||||||
*
|
|
||||||
* Extend this method if the module is supposed to return communication data,
|
|
||||||
* e.g. from protocol implementations.
|
|
||||||
*/
|
*/
|
||||||
public static function rawContent(array $parameters = [])
|
public function rawContent()
|
||||||
{
|
{
|
||||||
// echo '';
|
// echo '';
|
||||||
// exit;
|
// exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Module GET method to display any content
|
* {@inheritDoc}
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
*/
|
||||||
public static function content(array $parameters = [])
|
public function content(): string
|
||||||
{
|
{
|
||||||
$o = '';
|
return '';
|
||||||
|
|
||||||
return $o;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Module DELETE method to process submitted data
|
* {@inheritDoc}
|
||||||
*
|
|
||||||
* Extend this method if the module is supposed to process DELETE requests.
|
|
||||||
* Doesn't display any content
|
|
||||||
*/
|
*/
|
||||||
public static function delete(array $parameters = [])
|
public function delete()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Module PATCH method to process submitted data
|
* {@inheritDoc}
|
||||||
*
|
|
||||||
* Extend this method if the module is supposed to process PATCH requests.
|
|
||||||
* Doesn't display any content
|
|
||||||
*/
|
*/
|
||||||
public static function patch(array $parameters = [])
|
public function patch()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Module POST method to process submitted data
|
* {@inheritDoc}
|
||||||
*
|
|
||||||
* Extend this method if the module is supposed to process POST requests.
|
|
||||||
* Doesn't display any content
|
|
||||||
*/
|
*/
|
||||||
public static function post(array $parameters = [])
|
public function post()
|
||||||
{
|
{
|
||||||
// DI::baseurl()->redirect('module');
|
// DI::baseurl()->redirect('module');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called after post()
|
* {@inheritDoc}
|
||||||
*
|
|
||||||
* Unknown purpose
|
|
||||||
*/
|
*/
|
||||||
public static function afterpost(array $parameters = [])
|
public function put()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** Gets the name of the current class */
|
||||||
* Module PUT method to process submitted data
|
public function getClassName(): string
|
||||||
*
|
|
||||||
* Extend this method if the module is supposed to process PUT requests.
|
|
||||||
* Doesn't display any content
|
|
||||||
*/
|
|
||||||
public static function put(array $parameters = [])
|
|
||||||
{
|
{
|
||||||
|
return static::class;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -0,0 +1,68 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Friendica\Capabilities;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This interface provides the capability to handle requests from clients and returns the desired outcome
|
||||||
|
*/
|
||||||
|
interface ICanHandleRequests
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Initialization method common to both content() and post()
|
||||||
|
*
|
||||||
|
* Extend this method if you need to do any shared processing before either
|
||||||
|
* content() or post()
|
||||||
|
*/
|
||||||
|
public function init();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
public function rawContent();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
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;
|
||||||
|
}
|
|
@ -99,11 +99,11 @@ abstract class DI
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return App\Module
|
* @return App\ModuleController
|
||||||
*/
|
*/
|
||||||
public static function module()
|
public static function module()
|
||||||
{
|
{
|
||||||
return self::$dice->create(App\Module::class);
|
return self::$dice->create(App\ModuleController::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -35,7 +35,14 @@ class LegacyModule extends BaseModule
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private static $moduleName = '';
|
private $moduleName = '';
|
||||||
|
|
||||||
|
public function __construct(string $file_path = '', array $parameters = [])
|
||||||
|
{
|
||||||
|
parent::__construct($parameters);
|
||||||
|
|
||||||
|
$this->setModuleFile($file_path);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The only method that needs to be called, with the module/addon file name.
|
* The only method that needs to be called, with the module/addon file name.
|
||||||
|
@ -43,35 +50,30 @@ class LegacyModule extends BaseModule
|
||||||
* @param string $file_path
|
* @param string $file_path
|
||||||
* @throws \Exception
|
* @throws \Exception
|
||||||
*/
|
*/
|
||||||
public static function setModuleFile($file_path)
|
private function setModuleFile($file_path)
|
||||||
{
|
{
|
||||||
if (!is_readable($file_path)) {
|
if (!is_readable($file_path)) {
|
||||||
throw new \Exception(DI::l10n()->t('Legacy module file not found: %s', $file_path));
|
throw new \Exception(DI::l10n()->t('Legacy module file not found: %s', $file_path));
|
||||||
}
|
}
|
||||||
|
|
||||||
self::$moduleName = basename($file_path, '.php');
|
$this->moduleName = basename($file_path, '.php');
|
||||||
|
|
||||||
require_once $file_path;
|
require_once $file_path;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function init(array $parameters = [])
|
public function init()
|
||||||
{
|
{
|
||||||
self::runModuleFunction('init', $parameters);
|
$this->runModuleFunction('init');
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function content(array $parameters = [])
|
public function content(): string
|
||||||
{
|
{
|
||||||
return self::runModuleFunction('content', $parameters);
|
return $this->runModuleFunction('content');
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function post(array $parameters = [])
|
public function post()
|
||||||
{
|
{
|
||||||
self::runModuleFunction('post', $parameters);
|
$this->runModuleFunction('post');
|
||||||
}
|
|
||||||
|
|
||||||
public static function afterpost(array $parameters = [])
|
|
||||||
{
|
|
||||||
self::runModuleFunction('afterpost', $parameters);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -81,15 +83,15 @@ class LegacyModule extends BaseModule
|
||||||
* @return string
|
* @return string
|
||||||
* @throws \Exception
|
* @throws \Exception
|
||||||
*/
|
*/
|
||||||
private static function runModuleFunction($function_suffix, array $parameters = [])
|
private function runModuleFunction(string $function_suffix)
|
||||||
{
|
{
|
||||||
$function_name = static::$moduleName . '_' . $function_suffix;
|
$function_name = $this->moduleName . '_' . $function_suffix;
|
||||||
|
|
||||||
if (\function_exists($function_name)) {
|
if (\function_exists($function_name)) {
|
||||||
$a = DI::app();
|
$a = DI::app();
|
||||||
return $function_name($a);
|
return $function_name($a);
|
||||||
} else {
|
} else {
|
||||||
return parent::{$function_suffix}($parameters);
|
return parent::{$function_suffix}();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,7 @@ use Friendica\BaseModule;
|
||||||
*/
|
*/
|
||||||
class AccountManagementControlDocument extends BaseModule
|
class AccountManagementControlDocument extends BaseModule
|
||||||
{
|
{
|
||||||
public static function rawContent(array $parameters = [])
|
public function rawContent()
|
||||||
{
|
{
|
||||||
$output = [
|
$output = [
|
||||||
'version' => 1,
|
'version' => 1,
|
||||||
|
|
|
@ -24,22 +24,25 @@ namespace Friendica\Module;
|
||||||
use Friendica\BaseModule;
|
use Friendica\BaseModule;
|
||||||
use Friendica\Core\System;
|
use Friendica\Core\System;
|
||||||
use Friendica\Model\Contact;
|
use Friendica\Model\Contact;
|
||||||
|
use Friendica\Network\HTTPException\NotFoundException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Redirects to another URL based on the parameter 'addr'
|
* Redirects to another URL based on the parameter 'addr'
|
||||||
*/
|
*/
|
||||||
class Acctlink extends BaseModule
|
class Acctlink extends BaseModule
|
||||||
{
|
{
|
||||||
public static function content(array $parameters = [])
|
public function rawContent()
|
||||||
{
|
{
|
||||||
$addr = trim($_GET['addr'] ?? '');
|
$addr = trim($_GET['addr'] ?? '');
|
||||||
|
if (!$addr) {
|
||||||
if ($addr) {
|
throw new NotFoundException('Parameter "addr" is missing or empty');
|
||||||
$url = Contact::getByURL($addr)['url'] ?? '';
|
|
||||||
if ($url) {
|
|
||||||
System::externalRedirect($url['url']);
|
|
||||||
exit();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$contact = Contact::getByURL($addr, null, ['url']) ?? '';
|
||||||
|
if (!$contact) {
|
||||||
|
throw new NotFoundException('Contact not found');
|
||||||
|
}
|
||||||
|
|
||||||
|
System::externalRedirect($contact['url']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,14 +31,14 @@ use Friendica\Protocol\ActivityPub;
|
||||||
*/
|
*/
|
||||||
class Followers extends BaseModule
|
class Followers extends BaseModule
|
||||||
{
|
{
|
||||||
public static function rawContent(array $parameters = [])
|
public function rawContent()
|
||||||
{
|
{
|
||||||
if (empty($parameters['nickname'])) {
|
if (empty($this->parameters['nickname'])) {
|
||||||
throw new \Friendica\Network\HTTPException\NotFoundException();
|
throw new \Friendica\Network\HTTPException\NotFoundException();
|
||||||
}
|
}
|
||||||
|
|
||||||
// @TODO: Replace with parameter from router
|
// @TODO: Replace with parameter from router
|
||||||
$owner = User::getOwnerDataByNick($parameters['nickname']);
|
$owner = User::getOwnerDataByNick($this->parameters['nickname']);
|
||||||
if (empty($owner)) {
|
if (empty($owner)) {
|
||||||
throw new \Friendica\Network\HTTPException\NotFoundException();
|
throw new \Friendica\Network\HTTPException\NotFoundException();
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,13 +31,13 @@ use Friendica\Protocol\ActivityPub;
|
||||||
*/
|
*/
|
||||||
class Following extends BaseModule
|
class Following extends BaseModule
|
||||||
{
|
{
|
||||||
public static function rawContent(array $parameters = [])
|
public function rawContent()
|
||||||
{
|
{
|
||||||
if (empty($parameters['nickname'])) {
|
if (empty($this->parameters['nickname'])) {
|
||||||
throw new \Friendica\Network\HTTPException\NotFoundException();
|
throw new \Friendica\Network\HTTPException\NotFoundException();
|
||||||
}
|
}
|
||||||
|
|
||||||
$owner = User::getOwnerDataByNick($parameters['nickname']);
|
$owner = User::getOwnerDataByNick($this->parameters['nickname']);
|
||||||
if (empty($owner)) {
|
if (empty($owner)) {
|
||||||
throw new \Friendica\Network\HTTPException\NotFoundException();
|
throw new \Friendica\Network\HTTPException\NotFoundException();
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,7 @@ use Friendica\Util\Network;
|
||||||
*/
|
*/
|
||||||
class Inbox extends BaseModule
|
class Inbox extends BaseModule
|
||||||
{
|
{
|
||||||
public static function rawContent(array $parameters = [])
|
public function rawContent()
|
||||||
{
|
{
|
||||||
$postdata = Network::postdata();
|
$postdata = Network::postdata();
|
||||||
|
|
||||||
|
@ -50,12 +50,12 @@ class Inbox extends BaseModule
|
||||||
$filename = 'failed-activitypub';
|
$filename = 'failed-activitypub';
|
||||||
}
|
}
|
||||||
$tempfile = tempnam(System::getTempPath(), $filename);
|
$tempfile = tempnam(System::getTempPath(), $filename);
|
||||||
file_put_contents($tempfile, json_encode(['parameters' => $parameters, 'header' => $_SERVER, 'body' => $postdata], JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE));
|
file_put_contents($tempfile, json_encode(['parameters' => $this->parameters, 'header' => $_SERVER, 'body' => $postdata], JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE));
|
||||||
Logger::notice('Incoming message stored', ['file' => $tempfile]);
|
Logger::notice('Incoming message stored', ['file' => $tempfile]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($parameters['nickname'])) {
|
if (!empty($this->parameters['nickname'])) {
|
||||||
$user = DBA::selectFirst('user', ['uid'], ['nickname' => $parameters['nickname']]);
|
$user = DBA::selectFirst('user', ['uid'], ['nickname' => $this->parameters['nickname']]);
|
||||||
if (!DBA::isResult($user)) {
|
if (!DBA::isResult($user)) {
|
||||||
throw new \Friendica\Network\HTTPException\NotFoundException();
|
throw new \Friendica\Network\HTTPException\NotFoundException();
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,9 +41,9 @@ use Friendica\Util\Strings;
|
||||||
*/
|
*/
|
||||||
class Objects extends BaseModule
|
class Objects extends BaseModule
|
||||||
{
|
{
|
||||||
public static function rawContent(array $parameters = [])
|
public function rawContent()
|
||||||
{
|
{
|
||||||
if (empty($parameters['guid'])) {
|
if (empty($this->parameters['guid'])) {
|
||||||
throw new HTTPException\BadRequestException();
|
throw new HTTPException\BadRequestException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,10 +51,10 @@ class Objects extends BaseModule
|
||||||
DI::baseUrl()->redirect(str_replace('objects/', 'display/', DI::args()->getQueryString()));
|
DI::baseUrl()->redirect(str_replace('objects/', 'display/', DI::args()->getQueryString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
$itemuri = DBA::selectFirst('item-uri', ['id'], ['guid' => $parameters['guid']]);
|
$itemuri = DBA::selectFirst('item-uri', ['id'], ['guid' => $this->parameters['guid']]);
|
||||||
|
|
||||||
if (DBA::isResult($itemuri)) {
|
if (DBA::isResult($itemuri)) {
|
||||||
Logger::info('Provided GUID found.', ['guid' => $parameters['guid'], 'uri-id' => $itemuri['id']]);
|
Logger::info('Provided GUID found.', ['guid' => $this->parameters['guid'], 'uri-id' => $itemuri['id']]);
|
||||||
} else {
|
} else {
|
||||||
// The item URI does not always contain the GUID. This means that we have to search the URL instead
|
// The item URI does not always contain the GUID. This means that we have to search the URL instead
|
||||||
$url = DI::baseUrl()->get() . '/' . DI::args()->getQueryString();
|
$url = DI::baseUrl()->get() . '/' . DI::args()->getQueryString();
|
||||||
|
@ -104,11 +104,11 @@ class Objects extends BaseModule
|
||||||
throw new HTTPException\NotFoundException();
|
throw new HTTPException\NotFoundException();
|
||||||
}
|
}
|
||||||
|
|
||||||
$etag = md5($parameters['guid'] . '-' . $item['changed']);
|
$etag = md5($this->parameters['guid'] . '-' . $item['changed']);
|
||||||
$last_modified = $item['changed'];
|
$last_modified = $item['changed'];
|
||||||
Network::checkEtagModified($etag, $last_modified);
|
Network::checkEtagModified($etag, $last_modified);
|
||||||
|
|
||||||
if (empty($parameters['activity']) && ($item['gravity'] != GRAVITY_ACTIVITY)) {
|
if (empty($this->parameters['activity']) && ($item['gravity'] != GRAVITY_ACTIVITY)) {
|
||||||
$activity = ActivityPub\Transmitter::createActivityFromItem($item['id'], true);
|
$activity = ActivityPub\Transmitter::createActivityFromItem($item['id'], true);
|
||||||
if (empty($activity['type'])) {
|
if (empty($activity['type'])) {
|
||||||
throw new HTTPException\NotFoundException();
|
throw new HTTPException\NotFoundException();
|
||||||
|
@ -123,16 +123,16 @@ class Objects extends BaseModule
|
||||||
|
|
||||||
$data = ['@context' => ActivityPub::CONTEXT];
|
$data = ['@context' => ActivityPub::CONTEXT];
|
||||||
$data = array_merge($data, $activity['object']);
|
$data = array_merge($data, $activity['object']);
|
||||||
} elseif (empty($parameters['activity']) || in_array($parameters['activity'],
|
} elseif (empty($this->parameters['activity']) || in_array($this->parameters['activity'],
|
||||||
['Create', 'Announce', 'Update', 'Like', 'Dislike', 'Accept', 'Reject',
|
['Create', 'Announce', 'Update', 'Like', 'Dislike', 'Accept', 'Reject',
|
||||||
'TentativeAccept', 'Follow', 'Add'])) {
|
'TentativeAccept', 'Follow', 'Add'])) {
|
||||||
$data = ActivityPub\Transmitter::createActivityFromItem($item['id']);
|
$data = ActivityPub\Transmitter::createActivityFromItem($item['id']);
|
||||||
if (empty($data)) {
|
if (empty($data)) {
|
||||||
throw new HTTPException\NotFoundException();
|
throw new HTTPException\NotFoundException();
|
||||||
}
|
}
|
||||||
if (!empty($parameters['activity']) && ($parameters['activity'] != 'Create')) {
|
if (!empty($this->parameters['activity']) && ($this->parameters['activity'] != 'Create')) {
|
||||||
$data['type'] = $parameters['activity'];
|
$data['type'] = $this->parameters['activity'];
|
||||||
$data['id'] = str_replace('/Create', '/' . $parameters['activity'], $data['id']);
|
$data['id'] = str_replace('/Create', '/' . $this->parameters['activity'], $data['id']);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new HTTPException\NotFoundException();
|
throw new HTTPException\NotFoundException();
|
||||||
|
|
|
@ -31,13 +31,13 @@ use Friendica\Util\HTTPSignature;
|
||||||
*/
|
*/
|
||||||
class Outbox extends BaseModule
|
class Outbox extends BaseModule
|
||||||
{
|
{
|
||||||
public static function rawContent(array $parameters = [])
|
public function rawContent()
|
||||||
{
|
{
|
||||||
if (empty($parameters['nickname'])) {
|
if (empty($this->parameters['nickname'])) {
|
||||||
throw new \Friendica\Network\HTTPException\NotFoundException();
|
throw new \Friendica\Network\HTTPException\NotFoundException();
|
||||||
}
|
}
|
||||||
|
|
||||||
$owner = User::getOwnerDataByNick($parameters['nickname']);
|
$owner = User::getOwnerDataByNick($this->parameters['nickname']);
|
||||||
if (empty($owner)) {
|
if (empty($owner)) {
|
||||||
throw new \Friendica\Network\HTTPException\NotFoundException();
|
throw new \Friendica\Network\HTTPException\NotFoundException();
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,11 +30,11 @@ use Friendica\Util\Strings;
|
||||||
|
|
||||||
class Details extends BaseAdmin
|
class Details extends BaseAdmin
|
||||||
{
|
{
|
||||||
public static function post(array $parameters = [])
|
public function post()
|
||||||
{
|
{
|
||||||
self::checkAdminAccess();
|
self::checkAdminAccess();
|
||||||
|
|
||||||
$addon = Strings::sanitizeFilePathItem($parameters['addon']);
|
$addon = Strings::sanitizeFilePathItem($this->parameters['addon']);
|
||||||
|
|
||||||
$redirect = 'admin/addons/' . $addon;
|
$redirect = 'admin/addons/' . $addon;
|
||||||
|
|
||||||
|
@ -52,15 +52,15 @@ class Details extends BaseAdmin
|
||||||
DI::baseUrl()->redirect($redirect);
|
DI::baseUrl()->redirect($redirect);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function content(array $parameters = [])
|
public function content(): string
|
||||||
{
|
{
|
||||||
parent::content($parameters);
|
parent::content();
|
||||||
|
|
||||||
$a = DI::app();
|
$a = DI::app();
|
||||||
|
|
||||||
$addons_admin = Addon::getAdminList();
|
$addons_admin = Addon::getAdminList();
|
||||||
|
|
||||||
$addon = Strings::sanitizeFilePathItem($parameters['addon']);
|
$addon = Strings::sanitizeFilePathItem($this->parameters['addon']);
|
||||||
if (!is_file("addon/$addon/$addon.php")) {
|
if (!is_file("addon/$addon/$addon.php")) {
|
||||||
notice(DI::l10n()->t('Addon not found.'));
|
notice(DI::l10n()->t('Addon not found.'));
|
||||||
Addon::uninstall($addon);
|
Addon::uninstall($addon);
|
||||||
|
|
|
@ -28,9 +28,9 @@ use Friendica\Module\BaseAdmin;
|
||||||
|
|
||||||
class Index extends BaseAdmin
|
class Index extends BaseAdmin
|
||||||
{
|
{
|
||||||
public static function content(array $parameters = [])
|
public function content(): string
|
||||||
{
|
{
|
||||||
parent::content($parameters);
|
parent::content();
|
||||||
|
|
||||||
// reload active themes
|
// reload active themes
|
||||||
if (!empty($_GET['action'])) {
|
if (!empty($_GET['action'])) {
|
||||||
|
|
|
@ -32,7 +32,7 @@ use Friendica\Util\Network;
|
||||||
|
|
||||||
class Contact extends BaseAdmin
|
class Contact extends BaseAdmin
|
||||||
{
|
{
|
||||||
public static function post(array $parameters = [])
|
public function post()
|
||||||
{
|
{
|
||||||
self::checkAdminAccess();
|
self::checkAdminAccess();
|
||||||
|
|
||||||
|
@ -76,9 +76,9 @@ class Contact extends BaseAdmin
|
||||||
DI::baseUrl()->redirect('admin/blocklist/contact');
|
DI::baseUrl()->redirect('admin/blocklist/contact');
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function content(array $parameters = [])
|
public function content(): string
|
||||||
{
|
{
|
||||||
parent::content($parameters);
|
parent::content();
|
||||||
|
|
||||||
$condition = ['uid' => 0, 'blocked' => true];
|
$condition = ['uid' => 0, 'blocked' => true];
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,7 @@ use GuzzleHttp\Psr7\Uri;
|
||||||
|
|
||||||
class Add extends BaseAdmin
|
class Add extends BaseAdmin
|
||||||
{
|
{
|
||||||
public static function post(array $parameters = [])
|
public function post()
|
||||||
{
|
{
|
||||||
self::checkAdminAccess();
|
self::checkAdminAccess();
|
||||||
|
|
||||||
|
@ -66,9 +66,9 @@ class Add extends BaseAdmin
|
||||||
DI::baseUrl()->redirect('admin/blocklist/server');
|
DI::baseUrl()->redirect('admin/blocklist/server');
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function content(array $parameters = [])
|
public function content(): string
|
||||||
{
|
{
|
||||||
parent::content($parameters);
|
parent::content();
|
||||||
|
|
||||||
$gservers = [];
|
$gservers = [];
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@ use Friendica\Module\BaseAdmin;
|
||||||
|
|
||||||
class Index extends BaseAdmin
|
class Index extends BaseAdmin
|
||||||
{
|
{
|
||||||
public static function post(array $parameters = [])
|
public function post()
|
||||||
{
|
{
|
||||||
self::checkAdminAccess();
|
self::checkAdminAccess();
|
||||||
|
|
||||||
|
@ -56,9 +56,9 @@ class Index extends BaseAdmin
|
||||||
DI::baseUrl()->redirect('admin/blocklist/server');
|
DI::baseUrl()->redirect('admin/blocklist/server');
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function content(array $parameters = [])
|
public function content(): string
|
||||||
{
|
{
|
||||||
parent::content($parameters);
|
parent::content();
|
||||||
|
|
||||||
$blocklist = DI::config()->get('system', 'blocklist');
|
$blocklist = DI::config()->get('system', 'blocklist');
|
||||||
$blocklistform = [];
|
$blocklistform = [];
|
||||||
|
|
|
@ -30,14 +30,14 @@ use Friendica\Module\BaseAdmin;
|
||||||
|
|
||||||
class DBSync extends BaseAdmin
|
class DBSync extends BaseAdmin
|
||||||
{
|
{
|
||||||
public static function content(array $parameters = [])
|
public function content(): string
|
||||||
{
|
{
|
||||||
parent::content($parameters);
|
parent::content();
|
||||||
|
|
||||||
$a = DI::app();
|
$a = DI::app();
|
||||||
|
|
||||||
$action = $parameters['action'] ?? '';
|
$action = $this->parameters['action'] ?? '';
|
||||||
$update = $parameters['update'] ?? 0;
|
$update = $this->parameters['update'] ?? 0;
|
||||||
|
|
||||||
switch ($action) {
|
switch ($action) {
|
||||||
case 'mark':
|
case 'mark':
|
||||||
|
|
|
@ -28,7 +28,7 @@ use Friendica\Module\BaseAdmin;
|
||||||
|
|
||||||
class Features extends BaseAdmin
|
class Features extends BaseAdmin
|
||||||
{
|
{
|
||||||
public static function post(array $parameters = [])
|
public function post()
|
||||||
{
|
{
|
||||||
self::checkAdminAccess();
|
self::checkAdminAccess();
|
||||||
|
|
||||||
|
@ -60,9 +60,9 @@ class Features extends BaseAdmin
|
||||||
DI::baseUrl()->redirect('admin/features');
|
DI::baseUrl()->redirect('admin/features');
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function content(array $parameters = [])
|
public function content(): string
|
||||||
{
|
{
|
||||||
parent::content($parameters);
|
parent::content();
|
||||||
|
|
||||||
$features = [];
|
$features = [];
|
||||||
|
|
||||||
|
|
|
@ -28,9 +28,9 @@ use Friendica\Module\BaseAdmin;
|
||||||
|
|
||||||
class Federation extends BaseAdmin
|
class Federation extends BaseAdmin
|
||||||
{
|
{
|
||||||
public static function content(array $parameters = [])
|
public function content(): string
|
||||||
{
|
{
|
||||||
parent::content($parameters);
|
parent::content();
|
||||||
|
|
||||||
// get counts on active federation systems this node is knowing
|
// get counts on active federation systems this node is knowing
|
||||||
// We list the more common systems by name. The rest is counted as "other"
|
// We list the more common systems by name. The rest is counted as "other"
|
||||||
|
|
|
@ -29,7 +29,7 @@ use Friendica\Util\Strings;
|
||||||
|
|
||||||
class Delete extends BaseAdmin
|
class Delete extends BaseAdmin
|
||||||
{
|
{
|
||||||
public static function post(array $parameters = [])
|
public function post()
|
||||||
{
|
{
|
||||||
self::checkAdminAccess();
|
self::checkAdminAccess();
|
||||||
|
|
||||||
|
@ -55,9 +55,9 @@ class Delete extends BaseAdmin
|
||||||
DI::baseUrl()->redirect('admin/item/delete');
|
DI::baseUrl()->redirect('admin/item/delete');
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function content(array $parameters = [])
|
public function content(): string
|
||||||
{
|
{
|
||||||
parent::content($parameters);
|
parent::content();
|
||||||
|
|
||||||
$t = Renderer::getMarkupTemplate('admin/item/delete.tpl');
|
$t = Renderer::getMarkupTemplate('admin/item/delete.tpl');
|
||||||
|
|
||||||
|
|
|
@ -29,11 +29,11 @@ use Friendica\Module\BaseAdmin;
|
||||||
class Source extends BaseAdmin
|
class Source extends BaseAdmin
|
||||||
|
|
||||||
{
|
{
|
||||||
public static function content(array $parameters = [])
|
public function content(): string
|
||||||
{
|
{
|
||||||
parent::content($parameters);
|
parent::content();
|
||||||
|
|
||||||
$guid = basename($_REQUEST['guid'] ?? $parameters['guid'] ?? '');
|
$guid = basename($_REQUEST['guid'] ?? $this->parameters['guid'] ?? '');
|
||||||
|
|
||||||
$source = '';
|
$source = '';
|
||||||
$item_uri = '';
|
$item_uri = '';
|
||||||
|
|
|
@ -29,7 +29,7 @@ use Psr\Log\LogLevel;
|
||||||
|
|
||||||
class Settings extends BaseAdmin
|
class Settings extends BaseAdmin
|
||||||
{
|
{
|
||||||
public static function post(array $parameters = [])
|
public function post()
|
||||||
{
|
{
|
||||||
self::checkAdminAccess();
|
self::checkAdminAccess();
|
||||||
|
|
||||||
|
@ -56,9 +56,9 @@ class Settings extends BaseAdmin
|
||||||
DI::baseUrl()->redirect('admin/logs');
|
DI::baseUrl()->redirect('admin/logs');
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function content(array $parameters = [])
|
public function content(): string
|
||||||
{
|
{
|
||||||
parent::content($parameters);
|
parent::content();
|
||||||
|
|
||||||
$log_choices = [
|
$log_choices = [
|
||||||
LogLevel::ERROR => 'Error',
|
LogLevel::ERROR => 'Error',
|
||||||
|
|
|
@ -31,9 +31,9 @@ class View extends BaseAdmin
|
||||||
{
|
{
|
||||||
const LIMIT = 500;
|
const LIMIT = 500;
|
||||||
|
|
||||||
public static function content(array $parameters = [])
|
public function content(): string
|
||||||
{
|
{
|
||||||
parent::content($parameters);
|
parent::content();
|
||||||
|
|
||||||
$t = Renderer::getMarkupTemplate('admin/logs/view.tpl');
|
$t = Renderer::getMarkupTemplate('admin/logs/view.tpl');
|
||||||
DI::page()->registerFooterScript(Theme::getPathForFile('js/module/admin/logs/view.js'));
|
DI::page()->registerFooterScript(Theme::getPathForFile('js/module/admin/logs/view.js'));
|
||||||
|
@ -75,7 +75,7 @@ class View extends BaseAdmin
|
||||||
->withLimit(self::LIMIT)
|
->withLimit(self::LIMIT)
|
||||||
->withFilters($filters)
|
->withFilters($filters)
|
||||||
->withSearch($search);
|
->withSearch($search);
|
||||||
} catch (Exception $e) {
|
} catch (\Exception $e) {
|
||||||
$error = DI::l10n()->t('Couldn\'t open <strong>%1$s</strong> log file.<br/>Check to see if file %1$s is readable.', $f);
|
$error = DI::l10n()->t('Couldn\'t open <strong>%1$s</strong> log file.<br/>Check to see if file %1$s is readable.', $f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@ use Friendica\Module\BaseAdmin;
|
||||||
|
|
||||||
class PhpInfo extends BaseAdmin
|
class PhpInfo extends BaseAdmin
|
||||||
{
|
{
|
||||||
public static function rawContent(array $parameters = [])
|
public function rawContent()
|
||||||
{
|
{
|
||||||
self::checkAdminAccess();
|
self::checkAdminAccess();
|
||||||
|
|
||||||
|
|
|
@ -38,11 +38,11 @@ use Friendica\Util\DateTimeFormat;
|
||||||
*/
|
*/
|
||||||
class Queue extends BaseAdmin
|
class Queue extends BaseAdmin
|
||||||
{
|
{
|
||||||
public static function content(array $parameters = [])
|
public function content(): string
|
||||||
{
|
{
|
||||||
parent::content($parameters);
|
parent::content();
|
||||||
|
|
||||||
$status = $parameters['status'] ?? '';
|
$status = $this->parameters['status'] ?? '';
|
||||||
|
|
||||||
// get jobs from the workerqueue table
|
// get jobs from the workerqueue table
|
||||||
if ($status == 'deferred') {
|
if ($status == 'deferred') {
|
||||||
|
|
|
@ -43,7 +43,7 @@ require_once __DIR__ . '/../../../boot.php';
|
||||||
|
|
||||||
class Site extends BaseAdmin
|
class Site extends BaseAdmin
|
||||||
{
|
{
|
||||||
public static function post(array $parameters = [])
|
public function post()
|
||||||
{
|
{
|
||||||
self::checkAdminAccess();
|
self::checkAdminAccess();
|
||||||
|
|
||||||
|
@ -384,9 +384,9 @@ class Site extends BaseAdmin
|
||||||
DI::baseUrl()->redirect('admin/site' . $active_panel);
|
DI::baseUrl()->redirect('admin/site' . $active_panel);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function content(array $parameters = [])
|
public function content(): string
|
||||||
{
|
{
|
||||||
parent::content($parameters);
|
parent::content();
|
||||||
|
|
||||||
/* Installed langs */
|
/* Installed langs */
|
||||||
$lang_choices = DI::l10n()->getAvailableLanguages();
|
$lang_choices = DI::l10n()->getAvailableLanguages();
|
||||||
|
|
|
@ -31,13 +31,13 @@ use Friendica\Util\Strings;
|
||||||
|
|
||||||
class Storage extends BaseAdmin
|
class Storage extends BaseAdmin
|
||||||
{
|
{
|
||||||
public static function post(array $parameters = [])
|
public function post()
|
||||||
{
|
{
|
||||||
self::checkAdminAccess();
|
self::checkAdminAccess();
|
||||||
|
|
||||||
self::checkFormSecurityTokenRedirectOnError('/admin/storage', 'admin_storage');
|
self::checkFormSecurityTokenRedirectOnError('/admin/storage', 'admin_storage');
|
||||||
|
|
||||||
$storagebackend = trim($parameters['name'] ?? '');
|
$storagebackend = trim($this->parameters['name'] ?? '');
|
||||||
|
|
||||||
try {
|
try {
|
||||||
/** @var ICanConfigureStorage|false $newStorageConfig */
|
/** @var ICanConfigureStorage|false $newStorageConfig */
|
||||||
|
@ -91,9 +91,9 @@ class Storage extends BaseAdmin
|
||||||
DI::baseUrl()->redirect('admin/storage');
|
DI::baseUrl()->redirect('admin/storage');
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function content(array $parameters = [])
|
public function content(): string
|
||||||
{
|
{
|
||||||
parent::content($parameters);
|
parent::content();
|
||||||
|
|
||||||
$current_storage_backend = DI::storage();
|
$current_storage_backend = DI::storage();
|
||||||
$available_storage_forms = [];
|
$available_storage_forms = [];
|
||||||
|
|
|
@ -37,9 +37,9 @@ use Friendica\Util\DateTimeFormat;
|
||||||
|
|
||||||
class Summary extends BaseAdmin
|
class Summary extends BaseAdmin
|
||||||
{
|
{
|
||||||
public static function content(array $parameters = [])
|
public function content(): string
|
||||||
{
|
{
|
||||||
parent::content($parameters);
|
parent::content();
|
||||||
|
|
||||||
$a = DI::app();
|
$a = DI::app();
|
||||||
|
|
||||||
|
|
|
@ -30,11 +30,11 @@ use Friendica\Util\Strings;
|
||||||
|
|
||||||
class Details extends BaseAdmin
|
class Details extends BaseAdmin
|
||||||
{
|
{
|
||||||
public static function content(array $parameters = [])
|
public function content(): string
|
||||||
{
|
{
|
||||||
parent::content($parameters);
|
parent::content();
|
||||||
|
|
||||||
$theme = Strings::sanitizeFilePathItem($parameters['theme']);
|
$theme = Strings::sanitizeFilePathItem($this->parameters['theme']);
|
||||||
if (!is_dir("view/theme/$theme")) {
|
if (!is_dir("view/theme/$theme")) {
|
||||||
notice(DI::l10n()->t("Item not found."));
|
notice(DI::l10n()->t("Item not found."));
|
||||||
return '';
|
return '';
|
||||||
|
|
|
@ -28,19 +28,19 @@ use Friendica\Util\Strings;
|
||||||
|
|
||||||
class Embed extends BaseAdmin
|
class Embed extends BaseAdmin
|
||||||
{
|
{
|
||||||
public static function init(array $parameters = [])
|
public function init()
|
||||||
{
|
{
|
||||||
$theme = Strings::sanitizeFilePathItem($parameters['theme']);
|
$theme = Strings::sanitizeFilePathItem($this->parameters['theme']);
|
||||||
if (is_file("view/theme/$theme/config.php")) {
|
if (is_file("view/theme/$theme/config.php")) {
|
||||||
DI::app()->setCurrentTheme($theme);
|
DI::app()->setCurrentTheme($theme);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function post(array $parameters = [])
|
public function post()
|
||||||
{
|
{
|
||||||
self::checkAdminAccess();
|
self::checkAdminAccess();
|
||||||
|
|
||||||
$theme = Strings::sanitizeFilePathItem($parameters['theme']);
|
$theme = Strings::sanitizeFilePathItem($this->parameters['theme']);
|
||||||
if (is_file("view/theme/$theme/config.php")) {
|
if (is_file("view/theme/$theme/config.php")) {
|
||||||
require_once "view/theme/$theme/config.php";
|
require_once "view/theme/$theme/config.php";
|
||||||
if (function_exists('theme_admin_post')) {
|
if (function_exists('theme_admin_post')) {
|
||||||
|
@ -56,11 +56,11 @@ class Embed extends BaseAdmin
|
||||||
DI::baseUrl()->redirect('admin/themes/' . $theme . '/embed?mode=minimal');
|
DI::baseUrl()->redirect('admin/themes/' . $theme . '/embed?mode=minimal');
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function content(array $parameters = [])
|
public function content(): string
|
||||||
{
|
{
|
||||||
parent::content($parameters);
|
parent::content();
|
||||||
|
|
||||||
$theme = Strings::sanitizeFilePathItem($parameters['theme']);
|
$theme = Strings::sanitizeFilePathItem($this->parameters['theme']);
|
||||||
if (!is_dir("view/theme/$theme")) {
|
if (!is_dir("view/theme/$theme")) {
|
||||||
notice(DI::l10n()->t('Unknown theme.'));
|
notice(DI::l10n()->t('Unknown theme.'));
|
||||||
return '';
|
return '';
|
||||||
|
|
|
@ -29,9 +29,9 @@ use Friendica\Util\Strings;
|
||||||
|
|
||||||
class Index extends BaseAdmin
|
class Index extends BaseAdmin
|
||||||
{
|
{
|
||||||
public static function content(array $parameters = [])
|
public function content(): string
|
||||||
{
|
{
|
||||||
parent::content($parameters);
|
parent::content();
|
||||||
|
|
||||||
$allowed_themes = Theme::getAllowedList();
|
$allowed_themes = Theme::getAllowedList();
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@ use Friendica\Module\BaseAdmin;
|
||||||
|
|
||||||
class Tos extends BaseAdmin
|
class Tos extends BaseAdmin
|
||||||
{
|
{
|
||||||
public static function post(array $parameters = [])
|
public function post()
|
||||||
{
|
{
|
||||||
self::checkAdminAccess();
|
self::checkAdminAccess();
|
||||||
|
|
||||||
|
@ -48,11 +48,11 @@ class Tos extends BaseAdmin
|
||||||
DI::baseUrl()->redirect('admin/tos');
|
DI::baseUrl()->redirect('admin/tos');
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function content(array $parameters = [])
|
public function content(): string
|
||||||
{
|
{
|
||||||
parent::content($parameters);
|
parent::content();
|
||||||
|
|
||||||
$tos = new \Friendica\Module\Tos();
|
$tos = new \Friendica\Module\Tos($this->parameters);
|
||||||
$t = Renderer::getMarkupTemplate('admin/tos.tpl');
|
$t = Renderer::getMarkupTemplate('admin/tos.tpl');
|
||||||
return Renderer::replaceMacros($t, [
|
return Renderer::replaceMacros($t, [
|
||||||
'$title' => DI::l10n()->t('Administration'),
|
'$title' => DI::l10n()->t('Administration'),
|
||||||
|
|
|
@ -30,7 +30,7 @@ use Friendica\Module\Admin\BaseUsers;
|
||||||
|
|
||||||
class Active extends BaseUsers
|
class Active extends BaseUsers
|
||||||
{
|
{
|
||||||
public static function post(array $parameters = [])
|
public function post()
|
||||||
{
|
{
|
||||||
self::checkAdminAccess();
|
self::checkAdminAccess();
|
||||||
|
|
||||||
|
@ -60,12 +60,12 @@ class Active extends BaseUsers
|
||||||
DI::baseUrl()->redirect(DI::args()->getQueryString());
|
DI::baseUrl()->redirect(DI::args()->getQueryString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function content(array $parameters = [])
|
public function content(): string
|
||||||
{
|
{
|
||||||
parent::content($parameters);
|
parent::content();
|
||||||
|
|
||||||
$action = $parameters['action'] ?? '';
|
$action = $this->parameters['action'] ?? '';
|
||||||
$uid = $parameters['uid'] ?? 0;
|
$uid = $this->parameters['uid'] ?? 0;
|
||||||
|
|
||||||
if ($uid) {
|
if ($uid) {
|
||||||
$user = User::getById($uid, ['username', 'blocked']);
|
$user = User::getById($uid, ['username', 'blocked']);
|
||||||
|
|
|
@ -31,7 +31,7 @@ use Friendica\Util\Temporal;
|
||||||
|
|
||||||
class Blocked extends BaseUsers
|
class Blocked extends BaseUsers
|
||||||
{
|
{
|
||||||
public static function post(array $parameters = [])
|
public function post()
|
||||||
{
|
{
|
||||||
self::checkAdminAccess();
|
self::checkAdminAccess();
|
||||||
|
|
||||||
|
@ -61,12 +61,12 @@ class Blocked extends BaseUsers
|
||||||
DI::baseUrl()->redirect('admin/users/blocked');
|
DI::baseUrl()->redirect('admin/users/blocked');
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function content(array $parameters = [])
|
public function content(): string
|
||||||
{
|
{
|
||||||
parent::content($parameters);
|
parent::content();
|
||||||
|
|
||||||
$action = $parameters['action'] ?? '';
|
$action = $this->parameters['action'] ?? '';
|
||||||
$uid = $parameters['uid'] ?? 0;
|
$uid = $this->parameters['uid'] ?? 0;
|
||||||
|
|
||||||
if ($uid) {
|
if ($uid) {
|
||||||
$user = User::getById($uid, ['username', 'blocked']);
|
$user = User::getById($uid, ['username', 'blocked']);
|
||||||
|
|
|
@ -28,7 +28,7 @@ use Friendica\Module\Admin\BaseUsers;
|
||||||
|
|
||||||
class Create extends BaseUsers
|
class Create extends BaseUsers
|
||||||
{
|
{
|
||||||
public static function post(array $parameters = [])
|
public function post()
|
||||||
{
|
{
|
||||||
self::checkAdminAccess();
|
self::checkAdminAccess();
|
||||||
|
|
||||||
|
@ -51,9 +51,9 @@ class Create extends BaseUsers
|
||||||
DI::baseUrl()->redirect('admin/users/create');
|
DI::baseUrl()->redirect('admin/users/create');
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function content(array $parameters = [])
|
public function content(): string
|
||||||
{
|
{
|
||||||
parent::content($parameters);
|
parent::content();
|
||||||
|
|
||||||
$t = Renderer::getMarkupTemplate('admin/users/create.tpl');
|
$t = Renderer::getMarkupTemplate('admin/users/create.tpl');
|
||||||
return self::getTabsHTML('all') . Renderer::replaceMacros($t, [
|
return self::getTabsHTML('all') . Renderer::replaceMacros($t, [
|
||||||
|
|
|
@ -33,7 +33,7 @@ use Friendica\Util\Temporal;
|
||||||
|
|
||||||
class Deleted extends BaseUsers
|
class Deleted extends BaseUsers
|
||||||
{
|
{
|
||||||
public static function post(array $parameters = [])
|
public function post()
|
||||||
{
|
{
|
||||||
self::checkAdminAccess();
|
self::checkAdminAccess();
|
||||||
|
|
||||||
|
@ -44,9 +44,9 @@ class Deleted extends BaseUsers
|
||||||
DI::baseUrl()->redirect('admin/users/deleted');
|
DI::baseUrl()->redirect('admin/users/deleted');
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function content(array $parameters = [])
|
public function content(): string
|
||||||
{
|
{
|
||||||
parent::content($parameters);
|
parent::content();
|
||||||
|
|
||||||
$pager = new Pager(DI::l10n(), DI::args()->getQueryString(), 100);
|
$pager = new Pager(DI::l10n(), DI::args()->getQueryString(), 100);
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@ use Friendica\Module\Admin\BaseUsers;
|
||||||
|
|
||||||
class Index extends BaseUsers
|
class Index extends BaseUsers
|
||||||
{
|
{
|
||||||
public static function post(array $parameters = [])
|
public function post()
|
||||||
{
|
{
|
||||||
self::checkAdminAccess();
|
self::checkAdminAccess();
|
||||||
|
|
||||||
|
@ -67,12 +67,12 @@ class Index extends BaseUsers
|
||||||
DI::baseUrl()->redirect(DI::args()->getQueryString());
|
DI::baseUrl()->redirect(DI::args()->getQueryString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function content(array $parameters = [])
|
public function content(): string
|
||||||
{
|
{
|
||||||
parent::content($parameters);
|
parent::content();
|
||||||
|
|
||||||
$action = $parameters['action'] ?? '';
|
$action = $this->parameters['action'] ?? '';
|
||||||
$uid = $parameters['uid'] ?? 0;
|
$uid = $this->parameters['uid'] ?? 0;
|
||||||
|
|
||||||
if ($uid) {
|
if ($uid) {
|
||||||
$user = User::getById($uid, ['username', 'blocked']);
|
$user = User::getById($uid, ['username', 'blocked']);
|
||||||
|
|
|
@ -33,7 +33,7 @@ use Friendica\Util\Temporal;
|
||||||
|
|
||||||
class Pending extends BaseUsers
|
class Pending extends BaseUsers
|
||||||
{
|
{
|
||||||
public static function post(array $parameters = [])
|
public function post()
|
||||||
{
|
{
|
||||||
self::checkAdminAccess();
|
self::checkAdminAccess();
|
||||||
|
|
||||||
|
@ -58,12 +58,12 @@ class Pending extends BaseUsers
|
||||||
DI::baseUrl()->redirect('admin/users/pending');
|
DI::baseUrl()->redirect('admin/users/pending');
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function content(array $parameters = [])
|
public function content(): string
|
||||||
{
|
{
|
||||||
parent::content($parameters);
|
parent::content();
|
||||||
|
|
||||||
$action = $parameters['action'] ?? '';
|
$action = $this->parameters['action'] ?? '';
|
||||||
$uid = $parameters['uid'] ?? 0;
|
$uid = $this->parameters['uid'] ?? 0;
|
||||||
|
|
||||||
if ($uid) {
|
if ($uid) {
|
||||||
$user = User::getById($uid, ['username', 'blocked']);
|
$user = User::getById($uid, ['username', 'blocked']);
|
||||||
|
|
|
@ -40,7 +40,7 @@ use Friendica\Module\BaseApi;
|
||||||
*/
|
*/
|
||||||
class Activity extends BaseApi
|
class Activity extends BaseApi
|
||||||
{
|
{
|
||||||
public static function rawContent(array $parameters = [])
|
public function rawContent()
|
||||||
{
|
{
|
||||||
self::checkAllowedScope(self::SCOPE_WRITE);
|
self::checkAllowedScope(self::SCOPE_WRITE);
|
||||||
$uid = self::getCurrentUserID();
|
$uid = self::getCurrentUserID();
|
||||||
|
@ -49,17 +49,17 @@ class Activity extends BaseApi
|
||||||
'id' => 0, // Id of the post
|
'id' => 0, // Id of the post
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$res = Item::performActivity($request['id'], $parameters['verb'], $uid);
|
$res = Item::performActivity($request['id'], $this->parameters['verb'], $uid);
|
||||||
|
|
||||||
if ($res) {
|
if ($res) {
|
||||||
if (!empty($parameters['extension']) && ($parameters['extension'] == 'xml')) {
|
if (!empty($this->parameters['extension']) && ($this->parameters['extension'] == 'xml')) {
|
||||||
$ok = 'true';
|
$ok = 'true';
|
||||||
} else {
|
} else {
|
||||||
$ok = 'ok';
|
$ok = 'ok';
|
||||||
}
|
}
|
||||||
DI::apiResponse()->exit('ok', ['ok' => $ok], $parameters['extension'] ?? null);
|
DI::apiResponse()->exit('ok', ['ok' => $ok], $this->parameters['extension'] ?? null);
|
||||||
} else {
|
} else {
|
||||||
DI::apiResponse()->error(500, 'Error adding activity', '', $parameters['extension'] ?? null);
|
DI::apiResponse()->error(500, 'Error adding activity', '', $this->parameters['extension'] ?? null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,7 @@ use Friendica\Module\BaseApi;
|
||||||
*/
|
*/
|
||||||
class Setseen extends BaseApi
|
class Setseen extends BaseApi
|
||||||
{
|
{
|
||||||
public static function rawContent(array $parameters = [])
|
public function rawContent()
|
||||||
{
|
{
|
||||||
self::checkAllowedScope(self::SCOPE_WRITE);
|
self::checkAllowedScope(self::SCOPE_WRITE);
|
||||||
$uid = self::getCurrentUserID();
|
$uid = self::getCurrentUserID();
|
||||||
|
@ -42,13 +42,13 @@ class Setseen extends BaseApi
|
||||||
// return error if id is zero
|
// return error if id is zero
|
||||||
if (empty($request['id'])) {
|
if (empty($request['id'])) {
|
||||||
$answer = ['result' => 'error', 'message' => 'message id not specified'];
|
$answer = ['result' => 'error', 'message' => 'message id not specified'];
|
||||||
DI::apiResponse()->exit('direct_messages_setseen', ['$result' => $answer], $parameters['extension'] ?? null);
|
DI::apiResponse()->exit('direct_messages_setseen', ['$result' => $answer], $this->parameters['extension'] ?? null);
|
||||||
}
|
}
|
||||||
|
|
||||||
// error message if specified id is not in database
|
// error message if specified id is not in database
|
||||||
if (!DBA::exists('mail', ['id' => $request['id'], 'uid' => $uid])) {
|
if (!DBA::exists('mail', ['id' => $request['id'], 'uid' => $uid])) {
|
||||||
$answer = ['result' => 'error', 'message' => 'message id not in database'];
|
$answer = ['result' => 'error', 'message' => 'message id not in database'];
|
||||||
DI::apiResponse()->exit('direct_messages_setseen', ['$result' => $answer], $parameters['extension'] ?? null);
|
DI::apiResponse()->exit('direct_messages_setseen', ['$result' => $answer], $this->parameters['extension'] ?? null);
|
||||||
}
|
}
|
||||||
|
|
||||||
// update seen indicator
|
// update seen indicator
|
||||||
|
@ -58,6 +58,6 @@ class Setseen extends BaseApi
|
||||||
$answer = ['result' => 'error', 'message' => 'unknown error'];
|
$answer = ['result' => 'error', 'message' => 'unknown error'];
|
||||||
}
|
}
|
||||||
|
|
||||||
DI::apiResponse()->exit('direct_messages_setseen', ['$result' => $answer], $parameters['extension'] ?? null);
|
DI::apiResponse()->exit('direct_messages_setseen', ['$result' => $answer], $this->parameters['extension'] ?? null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,7 @@ use Friendica\Module\BaseApi;
|
||||||
*/
|
*/
|
||||||
class Index extends BaseApi
|
class Index extends BaseApi
|
||||||
{
|
{
|
||||||
public static function rawContent(array $parameters = [])
|
public function rawContent()
|
||||||
{
|
{
|
||||||
self::checkAllowedScope(self::SCOPE_READ);
|
self::checkAllowedScope(self::SCOPE_READ);
|
||||||
$uid = self::getCurrentUserID();
|
$uid = self::getCurrentUserID();
|
||||||
|
@ -70,6 +70,6 @@ class Index extends BaseApi
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
DI::apiResponse()->exit('events', ['events' => $items], $parameters['extension'] ?? null);
|
DI::apiResponse()->exit('events', ['events' => $items], $this->parameters['extension'] ?? null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
namespace Friendica\Module\Api\Friendica\Group;
|
namespace Friendica\Module\Api\Friendica\Group;
|
||||||
|
|
||||||
use Friendica\Database\DBA;
|
use Friendica\Database\DBA;
|
||||||
|
use Friendica\DI;
|
||||||
use Friendica\Model\Group;
|
use Friendica\Model\Group;
|
||||||
use Friendica\Module\BaseApi;
|
use Friendica\Module\BaseApi;
|
||||||
use Friendica\Network\HTTPException\BadRequestException;
|
use Friendica\Network\HTTPException\BadRequestException;
|
||||||
|
@ -31,7 +32,7 @@ use Friendica\Network\HTTPException\BadRequestException;
|
||||||
*/
|
*/
|
||||||
class Delete extends BaseApi
|
class Delete extends BaseApi
|
||||||
{
|
{
|
||||||
public static function rawContent(array $parameters = [])
|
public function rawContent()
|
||||||
{
|
{
|
||||||
self::checkAllowedScope(self::SCOPE_WRITE);
|
self::checkAllowedScope(self::SCOPE_WRITE);
|
||||||
$uid = self::getCurrentUserID();
|
$uid = self::getCurrentUserID();
|
||||||
|
@ -69,7 +70,7 @@ class Delete extends BaseApi
|
||||||
if ($ret) {
|
if ($ret) {
|
||||||
// return success
|
// return success
|
||||||
$success = ['success' => $ret, 'gid' => $request['gid'], 'name' => $request['name'], 'status' => 'deleted', 'wrong users' => []];
|
$success = ['success' => $ret, 'gid' => $request['gid'], 'name' => $request['name'], 'status' => 'deleted', 'wrong users' => []];
|
||||||
self::exit('group_delete', ['$result' => $success], $parameters['extension'] ?? null);
|
DI::apiResponse()->exit('group_delete', ['$result' => $success], $parameters['extension'] ?? null);
|
||||||
} else {
|
} else {
|
||||||
throw new BadRequestException('other API error');
|
throw new BadRequestException('other API error');
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,17 +31,17 @@ use Friendica\Module\BaseApi;
|
||||||
*/
|
*/
|
||||||
class Index extends BaseApi
|
class Index extends BaseApi
|
||||||
{
|
{
|
||||||
public static function post(array $parameters = [])
|
public function post()
|
||||||
{
|
{
|
||||||
self::checkAllowedScope(self::SCOPE_WRITE);
|
self::checkAllowedScope(self::SCOPE_WRITE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function delete(array $parameters = [])
|
public function delete()
|
||||||
{
|
{
|
||||||
self::checkAllowedScope(self::SCOPE_WRITE);
|
self::checkAllowedScope(self::SCOPE_WRITE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function rawContent(array $parameters = [])
|
public function rawContent()
|
||||||
{
|
{
|
||||||
echo api_call(DI::app());
|
echo api_call(DI::app());
|
||||||
exit();
|
exit();
|
||||||
|
|
|
@ -31,7 +31,7 @@ use Friendica\Object\Api\Friendica\Notification as ApiNotification;
|
||||||
*/
|
*/
|
||||||
class Notification extends BaseApi
|
class Notification extends BaseApi
|
||||||
{
|
{
|
||||||
public static function rawContent(array $parameters = [])
|
public function rawContent()
|
||||||
{
|
{
|
||||||
self::checkAllowedScope(self::SCOPE_READ);
|
self::checkAllowedScope(self::SCOPE_READ);
|
||||||
$uid = self::getCurrentUserID();
|
$uid = self::getCurrentUserID();
|
||||||
|
@ -43,7 +43,7 @@ class Notification extends BaseApi
|
||||||
$notifications[] = new ApiNotification($Notify);
|
$notifications[] = new ApiNotification($Notify);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($parameters['extension']) && ($parameters['extension'] == 'xml')) {
|
if (!empty($this->parameters['extension']) && ($this->parameters['extension'] == 'xml')) {
|
||||||
$xmlnotes = [];
|
$xmlnotes = [];
|
||||||
foreach ($notifications as $notification) {
|
foreach ($notifications as $notification) {
|
||||||
$xmlnotes[] = ['@attributes' => $notification->toArray()];
|
$xmlnotes[] = ['@attributes' => $notification->toArray()];
|
||||||
|
@ -56,6 +56,6 @@ class Notification extends BaseApi
|
||||||
$result = false;
|
$result = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
DI::apiResponse()->exit('notes', ['note' => $result], $parameters['extension'] ?? null);
|
DI::apiResponse()->exit('notes', ['note' => $result], $this->parameters['extension'] ?? null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,7 @@ use Friendica\Network\HTTPException\InternalServerErrorException;
|
||||||
*/
|
*/
|
||||||
class Delete extends BaseApi
|
class Delete extends BaseApi
|
||||||
{
|
{
|
||||||
public static function rawContent(array $parameters = [])
|
public function rawContent()
|
||||||
{
|
{
|
||||||
self::checkAllowedScope(self::SCOPE_WRITE);
|
self::checkAllowedScope(self::SCOPE_WRITE);
|
||||||
$uid = self::getCurrentUserID();
|
$uid = self::getCurrentUserID();
|
||||||
|
@ -64,7 +64,7 @@ class Delete extends BaseApi
|
||||||
Item::deleteForUser($condition, $uid);
|
Item::deleteForUser($condition, $uid);
|
||||||
|
|
||||||
$result = ['result' => 'deleted', 'message' => 'photo with id `' . $request['photo_id'] . '` has been deleted from server.'];
|
$result = ['result' => 'deleted', 'message' => 'photo with id `' . $request['photo_id'] . '` has been deleted from server.'];
|
||||||
DI::apiResponse()->exit('photo_delete', ['$result' => $result], $parameters['extension'] ?? null);
|
DI::apiResponse()->exit('photo_delete', ['$result' => $result], $this->parameters['extension'] ?? null);
|
||||||
} else {
|
} else {
|
||||||
throw new InternalServerErrorException("unknown error on deleting photo from database table");
|
throw new InternalServerErrorException("unknown error on deleting photo from database table");
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,7 @@ use Friendica\Network\HTTPException\InternalServerErrorException;
|
||||||
*/
|
*/
|
||||||
class Delete extends BaseApi
|
class Delete extends BaseApi
|
||||||
{
|
{
|
||||||
public static function rawContent(array $parameters = [])
|
public function rawContent()
|
||||||
{
|
{
|
||||||
self::checkAllowedScope(self::SCOPE_WRITE);
|
self::checkAllowedScope(self::SCOPE_WRITE);
|
||||||
$uid = self::getCurrentUserID();
|
$uid = self::getCurrentUserID();
|
||||||
|
@ -67,7 +67,7 @@ class Delete extends BaseApi
|
||||||
// return success of deletion or error message
|
// return success of deletion or error message
|
||||||
if ($result) {
|
if ($result) {
|
||||||
$answer = ['result' => 'deleted', 'message' => 'album `' . $request['album'] . '` with all containing photos has been deleted.'];
|
$answer = ['result' => 'deleted', 'message' => 'album `' . $request['album'] . '` with all containing photos has been deleted.'];
|
||||||
DI::apiResponse()->exit('photoalbum_delete', ['$result' => $answer], $parameters['extension'] ?? null);
|
DI::apiResponse()->exit('photoalbum_delete', ['$result' => $answer], $this->parameters['extension'] ?? null);
|
||||||
} else {
|
} else {
|
||||||
throw new InternalServerErrorException("unknown error - deleting from database failed");
|
throw new InternalServerErrorException("unknown error - deleting from database failed");
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,7 @@ use Friendica\Network\HTTPException\InternalServerErrorException;
|
||||||
*/
|
*/
|
||||||
class Update extends BaseApi
|
class Update extends BaseApi
|
||||||
{
|
{
|
||||||
public static function rawContent(array $parameters = [])
|
public function rawContent()
|
||||||
{
|
{
|
||||||
self::checkAllowedScope(self::SCOPE_WRITE);
|
self::checkAllowedScope(self::SCOPE_WRITE);
|
||||||
$uid = self::getCurrentUserID();
|
$uid = self::getCurrentUserID();
|
||||||
|
@ -59,7 +59,7 @@ class Update extends BaseApi
|
||||||
// return success of updating or error message
|
// return success of updating or error message
|
||||||
if ($result) {
|
if ($result) {
|
||||||
$answer = ['result' => 'updated', 'message' => 'album `' . $request['album'] . '` with all containing photos has been renamed to `' . $request['album_new'] . '`.'];
|
$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], $parameters['extension'] ?? null);
|
DI::apiResponse()->exit('photoalbum_update', ['$result' => $answer], $this->parameters['extension'] ?? null);
|
||||||
} else {
|
} else {
|
||||||
throw new InternalServerErrorException("unknown error - updating in database failed");
|
throw new InternalServerErrorException("unknown error - updating in database failed");
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,7 @@ use Friendica\Network\HTTPException;
|
||||||
*/
|
*/
|
||||||
class Show extends BaseApi
|
class Show extends BaseApi
|
||||||
{
|
{
|
||||||
public static function rawContent(array $parameters = [])
|
public function rawContent()
|
||||||
{
|
{
|
||||||
self::checkAllowedScope(self::SCOPE_READ);
|
self::checkAllowedScope(self::SCOPE_READ);
|
||||||
$uid = self::getCurrentUserID();
|
$uid = self::getCurrentUserID();
|
||||||
|
@ -48,7 +48,7 @@ class Show extends BaseApi
|
||||||
$profile = self::formatProfile($profile, $profileFields);
|
$profile = self::formatProfile($profile, $profileFields);
|
||||||
|
|
||||||
$profiles = [];
|
$profiles = [];
|
||||||
if (!empty($parameters['extension']) && ($parameters['extension'] == 'xml')) {
|
if (!empty($this->parameters['extension']) && ($this->parameters['extension'] == 'xml')) {
|
||||||
$profiles['0:profile'] = $profile;
|
$profiles['0:profile'] = $profile;
|
||||||
} else {
|
} else {
|
||||||
$profiles[] = $profile;
|
$profiles[] = $profile;
|
||||||
|
@ -61,7 +61,7 @@ class Show extends BaseApi
|
||||||
'profiles' => $profiles
|
'profiles' => $profiles
|
||||||
];
|
];
|
||||||
|
|
||||||
DI::apiResponse()->exit('friendica_profiles', ['$result' => $result], $parameters['extension'] ?? null);
|
DI::apiResponse()->exit('friendica_profiles', ['$result' => $result], $this->parameters['extension'] ?? null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -31,7 +31,7 @@ use Friendica\Module\Register;
|
||||||
*/
|
*/
|
||||||
class Config extends BaseApi
|
class Config extends BaseApi
|
||||||
{
|
{
|
||||||
public static function rawContent(array $parameters = [])
|
public function rawContent()
|
||||||
{
|
{
|
||||||
$config = [
|
$config = [
|
||||||
'site' => [
|
'site' => [
|
||||||
|
@ -61,6 +61,6 @@ class Config extends BaseApi
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
self::exit('config', ['config' => $config], $parameters['extension'] ?? null);
|
DI::apiResponse()->exit('config', ['config' => $config], $this->parameters['extension'] ?? null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,8 +29,8 @@ use Friendica\DI;
|
||||||
*/
|
*/
|
||||||
class Version extends BaseApi
|
class Version extends BaseApi
|
||||||
{
|
{
|
||||||
public static function rawContent(array $parameters = [])
|
public function rawContent()
|
||||||
{
|
{
|
||||||
DI::apiResponse()->exit('version', ['version' => '0.9.7'], $parameters['extension'] ?? null);
|
DI::apiResponse()->exit('version', ['version' => '0.9.7'], $this->parameters['extension'] ?? null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,14 +29,14 @@ use Friendica\DI;
|
||||||
*/
|
*/
|
||||||
class Test extends BaseApi
|
class Test extends BaseApi
|
||||||
{
|
{
|
||||||
public static function rawContent(array $parameters = [])
|
public function rawContent()
|
||||||
{
|
{
|
||||||
if (!empty($parameters['extension']) && ($parameters['extension'] == 'xml')) {
|
if (!empty($this->parameters['extension']) && ($this->parameters['extension'] == 'xml')) {
|
||||||
$ok = 'true';
|
$ok = 'true';
|
||||||
} else {
|
} else {
|
||||||
$ok = 'ok';
|
$ok = 'ok';
|
||||||
}
|
}
|
||||||
|
|
||||||
DI::apiResponse()->exit('ok', ['ok' => $ok], $parameters['extension'] ?? null);
|
DI::apiResponse()->exit('ok', ['ok' => $ok], $this->parameters['extension'] ?? null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,27 +33,26 @@ use Friendica\Module\BaseApi;
|
||||||
class Accounts extends BaseApi
|
class Accounts extends BaseApi
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @param array $parameters
|
|
||||||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||||
*/
|
*/
|
||||||
public static function rawContent(array $parameters = [])
|
public function rawContent()
|
||||||
{
|
{
|
||||||
$uid = self::getCurrentUserID();
|
$uid = self::getCurrentUserID();
|
||||||
|
|
||||||
if (empty($parameters['id']) && empty($parameters['name'])) {
|
if (empty($this->parameters['id']) && empty($this->parameters['name'])) {
|
||||||
DI::mstdnError()->UnprocessableEntity();
|
DI::mstdnError()->UnprocessableEntity();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($parameters['id'])) {
|
if (!empty($this->parameters['id'])) {
|
||||||
$id = $parameters['id'];
|
$id = $this->parameters['id'];
|
||||||
if (!DBA::exists('contact', ['id' => $id, 'uid' => 0])) {
|
if (!DBA::exists('contact', ['id' => $id, 'uid' => 0])) {
|
||||||
DI::mstdnError()->RecordNotFound();
|
DI::mstdnError()->RecordNotFound();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$contact = Contact::selectFirst(['id'], ['nick' => $parameters['name'], 'uid' => 0]);
|
$contact = Contact::selectFirst(['id'], ['nick' => $this->parameters['name'], 'uid' => 0]);
|
||||||
if (!empty($contact['id'])) {
|
if (!empty($contact['id'])) {
|
||||||
$id = $contact['id'];
|
$id = $contact['id'];
|
||||||
} elseif (!($id = Contact::getIdForURL($parameters['name'], 0, false))) {
|
} elseif (!($id = Contact::getIdForURL($this->parameters['name'], 0, false))) {
|
||||||
DI::mstdnError()->RecordNotFound();
|
DI::mstdnError()->RecordNotFound();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,12 +32,12 @@ use Friendica\Module\BaseApi;
|
||||||
*/
|
*/
|
||||||
class Block extends BaseApi
|
class Block extends BaseApi
|
||||||
{
|
{
|
||||||
public static function post(array $parameters = [])
|
public function post()
|
||||||
{
|
{
|
||||||
self::checkAllowedScope(self::SCOPE_FOLLOW);
|
self::checkAllowedScope(self::SCOPE_FOLLOW);
|
||||||
$uid = self::getCurrentUserID();
|
$uid = self::getCurrentUserID();
|
||||||
|
|
||||||
if (empty($parameters['id'])) {
|
if (empty($this->parameters['id'])) {
|
||||||
DI::mstdnError()->UnprocessableEntity();
|
DI::mstdnError()->UnprocessableEntity();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ class Block extends BaseApi
|
||||||
DI::mstdnError()->Forbidden();
|
DI::mstdnError()->Forbidden();
|
||||||
}
|
}
|
||||||
|
|
||||||
$cdata = Contact::getPublicAndUserContactID($parameters['id'], $uid);
|
$cdata = Contact::getPublicAndUserContactID($this->parameters['id'], $uid);
|
||||||
if (empty($cdata['user'])) {
|
if (empty($cdata['user'])) {
|
||||||
DI::mstdnError()->RecordNotFound();
|
DI::mstdnError()->RecordNotFound();
|
||||||
}
|
}
|
||||||
|
@ -62,6 +62,6 @@ class Block extends BaseApi
|
||||||
Contact::terminateFriendship($owner, $contact);
|
Contact::terminateFriendship($owner, $contact);
|
||||||
Contact::revokeFollow($contact);
|
Contact::revokeFollow($contact);
|
||||||
|
|
||||||
System::jsonExit(DI::mstdnRelationship()->createFromContactId($parameters['id'], $uid)->toArray());
|
System::jsonExit(DI::mstdnRelationship()->createFromContactId($this->parameters['id'], $uid)->toArray());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,10 +30,9 @@ use Friendica\Module\BaseApi;
|
||||||
class FeaturedTags extends BaseApi
|
class FeaturedTags extends BaseApi
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @param array $parameters
|
|
||||||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||||
*/
|
*/
|
||||||
public static function rawContent(array $parameters = [])
|
public function rawContent()
|
||||||
{
|
{
|
||||||
self::checkAllowedScope(self::SCOPE_READ);
|
self::checkAllowedScope(self::SCOPE_READ);
|
||||||
|
|
||||||
|
|
|
@ -31,16 +31,16 @@ use Friendica\Module\BaseApi;
|
||||||
*/
|
*/
|
||||||
class Follow extends BaseApi
|
class Follow extends BaseApi
|
||||||
{
|
{
|
||||||
public static function post(array $parameters = [])
|
public function post()
|
||||||
{
|
{
|
||||||
self::checkAllowedScope(self::SCOPE_FOLLOW);
|
self::checkAllowedScope(self::SCOPE_FOLLOW);
|
||||||
$uid = self::getCurrentUserID();
|
$uid = self::getCurrentUserID();
|
||||||
|
|
||||||
if (empty($parameters['id'])) {
|
if (empty($this->parameters['id'])) {
|
||||||
DI::mstdnError()->UnprocessableEntity();
|
DI::mstdnError()->UnprocessableEntity();
|
||||||
}
|
}
|
||||||
|
|
||||||
$cid = Contact::follow($parameters['id'], $uid);
|
$cid = Contact::follow($this->parameters['id'], $uid);
|
||||||
|
|
||||||
System::jsonExit(DI::mstdnRelationship()->createFromContactId($cid, $uid)->toArray());
|
System::jsonExit(DI::mstdnRelationship()->createFromContactId($cid, $uid)->toArray());
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,19 +32,18 @@ use Friendica\Module\BaseApi;
|
||||||
class Followers extends BaseApi
|
class Followers extends BaseApi
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @param array $parameters
|
|
||||||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||||
*/
|
*/
|
||||||
public static function rawContent(array $parameters = [])
|
public function rawContent()
|
||||||
{
|
{
|
||||||
self::checkAllowedScope(self::SCOPE_READ);
|
self::checkAllowedScope(self::SCOPE_READ);
|
||||||
$uid = self::getCurrentUserID();
|
$uid = self::getCurrentUserID();
|
||||||
|
|
||||||
if (empty($parameters['id'])) {
|
if (empty($this->parameters['id'])) {
|
||||||
DI::mstdnError()->UnprocessableEntity();
|
DI::mstdnError()->UnprocessableEntity();
|
||||||
}
|
}
|
||||||
|
|
||||||
$id = $parameters['id'];
|
$id = $this->parameters['id'];
|
||||||
if (!DBA::exists('contact', ['id' => $id, 'uid' => 0])) {
|
if (!DBA::exists('contact', ['id' => $id, 'uid' => 0])) {
|
||||||
DI::mstdnError()->RecordNotFound();
|
DI::mstdnError()->RecordNotFound();
|
||||||
}
|
}
|
||||||
|
@ -73,7 +72,7 @@ class Followers extends BaseApi
|
||||||
$params['order'] = ['cid'];
|
$params['order'] = ['cid'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$followers = DBA::select('contact-relation', ['relation-cid'], $condition, $parameters);
|
$followers = DBA::select('contact-relation', ['relation-cid'], $condition, $this->parameters);
|
||||||
while ($follower = DBA::fetch($followers)) {
|
while ($follower = DBA::fetch($followers)) {
|
||||||
self::setBoundaries($follower['relation-cid']);
|
self::setBoundaries($follower['relation-cid']);
|
||||||
$accounts[] = DI::mstdnAccount()->createFromContactId($follower['relation-cid'], $uid);
|
$accounts[] = DI::mstdnAccount()->createFromContactId($follower['relation-cid'], $uid);
|
||||||
|
|
|
@ -32,19 +32,18 @@ use Friendica\Module\BaseApi;
|
||||||
class Following extends BaseApi
|
class Following extends BaseApi
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @param array $parameters
|
|
||||||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||||
*/
|
*/
|
||||||
public static function rawContent(array $parameters = [])
|
public function rawContent()
|
||||||
{
|
{
|
||||||
self::checkAllowedScope(self::SCOPE_READ);
|
self::checkAllowedScope(self::SCOPE_READ);
|
||||||
$uid = self::getCurrentUserID();
|
$uid = self::getCurrentUserID();
|
||||||
|
|
||||||
if (empty($parameters['id'])) {
|
if (empty($this->parameters['id'])) {
|
||||||
DI::mstdnError()->UnprocessableEntity();
|
DI::mstdnError()->UnprocessableEntity();
|
||||||
}
|
}
|
||||||
|
|
||||||
$id = $parameters['id'];
|
$id = $this->parameters['id'];
|
||||||
if (!DBA::exists('contact', ['id' => $id, 'uid' => 0])) {
|
if (!DBA::exists('contact', ['id' => $id, 'uid' => 0])) {
|
||||||
DI::mstdnError()->RecordNotFound();
|
DI::mstdnError()->RecordNotFound();
|
||||||
}
|
}
|
||||||
|
@ -73,7 +72,7 @@ class Following extends BaseApi
|
||||||
$params['order'] = ['cid'];
|
$params['order'] = ['cid'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$followers = DBA::select('contact-relation', ['cid'], $condition, $parameters);
|
$followers = DBA::select('contact-relation', ['cid'], $condition, $this->parameters);
|
||||||
while ($follower = DBA::fetch($followers)) {
|
while ($follower = DBA::fetch($followers)) {
|
||||||
self::setBoundaries($follower['cid']);
|
self::setBoundaries($follower['cid']);
|
||||||
$accounts[] = DI::mstdnAccount()->createFromContactId($follower['cid'], $uid);
|
$accounts[] = DI::mstdnAccount()->createFromContactId($follower['cid'], $uid);
|
||||||
|
|
|
@ -30,10 +30,9 @@ use Friendica\Module\BaseApi;
|
||||||
class IdentityProofs extends BaseApi
|
class IdentityProofs extends BaseApi
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @param array $parameters
|
|
||||||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||||
*/
|
*/
|
||||||
public static function rawContent(array $parameters = [])
|
public function rawContent()
|
||||||
{
|
{
|
||||||
self::checkAllowedScope(self::SCOPE_READ);
|
self::checkAllowedScope(self::SCOPE_READ);
|
||||||
|
|
||||||
|
|
|
@ -33,19 +33,18 @@ use Friendica\Module\BaseApi;
|
||||||
class Lists extends BaseApi
|
class Lists extends BaseApi
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @param array $parameters
|
|
||||||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||||
*/
|
*/
|
||||||
public static function rawContent(array $parameters = [])
|
public function rawContent()
|
||||||
{
|
{
|
||||||
self::checkAllowedScope(self::SCOPE_READ);
|
self::checkAllowedScope(self::SCOPE_READ);
|
||||||
$uid = self::getCurrentUserID();
|
$uid = self::getCurrentUserID();
|
||||||
|
|
||||||
if (empty($parameters['id'])) {
|
if (empty($this->parameters['id'])) {
|
||||||
DI::mstdnError()->UnprocessableEntity();
|
DI::mstdnError()->UnprocessableEntity();
|
||||||
}
|
}
|
||||||
|
|
||||||
$id = $parameters['id'];
|
$id = $this->parameters['id'];
|
||||||
if (!DBA::exists('contact', ['id' => $id, 'uid' => 0])) {
|
if (!DBA::exists('contact', ['id' => $id, 'uid' => 0])) {
|
||||||
DI::mstdnError()->RecordNotFound();
|
DI::mstdnError()->RecordNotFound();
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,17 +31,17 @@ use Friendica\Module\BaseApi;
|
||||||
*/
|
*/
|
||||||
class Mute extends BaseApi
|
class Mute extends BaseApi
|
||||||
{
|
{
|
||||||
public static function post(array $parameters = [])
|
public function post()
|
||||||
{
|
{
|
||||||
self::checkAllowedScope(self::SCOPE_FOLLOW);
|
self::checkAllowedScope(self::SCOPE_FOLLOW);
|
||||||
$uid = self::getCurrentUserID();
|
$uid = self::getCurrentUserID();
|
||||||
|
|
||||||
if (empty($parameters['id'])) {
|
if (empty($this->parameters['id'])) {
|
||||||
DI::mstdnError()->UnprocessableEntity();
|
DI::mstdnError()->UnprocessableEntity();
|
||||||
}
|
}
|
||||||
|
|
||||||
Contact\User::setIgnored($parameters['id'], $uid, true);
|
Contact\User::setIgnored($this->parameters['id'], $uid, true);
|
||||||
|
|
||||||
System::jsonExit(DI::mstdnRelationship()->createFromContactId($parameters['id'], $uid)->toArray());
|
System::jsonExit(DI::mstdnRelationship()->createFromContactId($this->parameters['id'], $uid)->toArray());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,12 +32,12 @@ use Friendica\Module\BaseApi;
|
||||||
*/
|
*/
|
||||||
class Note extends BaseApi
|
class Note extends BaseApi
|
||||||
{
|
{
|
||||||
public static function post(array $parameters = [])
|
public function post()
|
||||||
{
|
{
|
||||||
self::checkAllowedScope(self::SCOPE_WRITE);
|
self::checkAllowedScope(self::SCOPE_WRITE);
|
||||||
$uid = self::getCurrentUserID();
|
$uid = self::getCurrentUserID();
|
||||||
|
|
||||||
if (empty($parameters['id'])) {
|
if (empty($this->parameters['id'])) {
|
||||||
DI::mstdnError()->UnprocessableEntity();
|
DI::mstdnError()->UnprocessableEntity();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,13 +45,13 @@ class Note extends BaseApi
|
||||||
'comment' => '',
|
'comment' => '',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$cdata = Contact::getPublicAndUserContactID($parameters['id'], $uid);
|
$cdata = Contact::getPublicAndUserContactID($this->parameters['id'], $uid);
|
||||||
if (empty($cdata['user'])) {
|
if (empty($cdata['user'])) {
|
||||||
DI::mstdnError()->RecordNotFound();
|
DI::mstdnError()->RecordNotFound();
|
||||||
}
|
}
|
||||||
|
|
||||||
Contact::update(['info' => $request['comment']], ['id' => $cdata['user']]);
|
Contact::update(['info' => $request['comment']], ['id' => $cdata['user']]);
|
||||||
|
|
||||||
System::jsonExit(DI::mstdnRelationship()->createFromContactId($parameters['id'], $uid)->toArray());
|
System::jsonExit(DI::mstdnRelationship()->createFromContactId($this->parameters['id'], $uid)->toArray());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,10 +32,9 @@ use Friendica\Module\BaseApi;
|
||||||
class Relationships extends BaseApi
|
class Relationships extends BaseApi
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @param array $parameters
|
|
||||||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||||
*/
|
*/
|
||||||
public static function rawContent(array $parameters = [])
|
public function rawContent()
|
||||||
{
|
{
|
||||||
self::checkAllowedScope(self::SCOPE_READ);
|
self::checkAllowedScope(self::SCOPE_READ);
|
||||||
$uid = self::getCurrentUserID();
|
$uid = self::getCurrentUserID();
|
||||||
|
|
|
@ -35,10 +35,9 @@ use Friendica\Object\Search\ContactResult;
|
||||||
class Search extends BaseApi
|
class Search extends BaseApi
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @param array $parameters
|
|
||||||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||||
*/
|
*/
|
||||||
public static function rawContent(array $parameters = [])
|
public function rawContent()
|
||||||
{
|
{
|
||||||
self::checkAllowedScope(self::SCOPE_READ);
|
self::checkAllowedScope(self::SCOPE_READ);
|
||||||
$uid = self::getCurrentUserID();
|
$uid = self::getCurrentUserID();
|
||||||
|
|
|
@ -37,18 +37,17 @@ use Friendica\Protocol\Activity;
|
||||||
class Statuses extends BaseApi
|
class Statuses extends BaseApi
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @param array $parameters
|
|
||||||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||||
*/
|
*/
|
||||||
public static function rawContent(array $parameters = [])
|
public function rawContent()
|
||||||
{
|
{
|
||||||
$uid = self::getCurrentUserID();
|
$uid = self::getCurrentUserID();
|
||||||
|
|
||||||
if (empty($parameters['id'])) {
|
if (empty($this->parameters['id'])) {
|
||||||
DI::mstdnError()->UnprocessableEntity();
|
DI::mstdnError()->UnprocessableEntity();
|
||||||
}
|
}
|
||||||
|
|
||||||
$id = $parameters['id'];
|
$id = $this->parameters['id'];
|
||||||
if (!DBA::exists('contact', ['id' => $id, 'uid' => 0])) {
|
if (!DBA::exists('contact', ['id' => $id, 'uid' => 0])) {
|
||||||
DI::mstdnError()->RecordNotFound();
|
DI::mstdnError()->RecordNotFound();
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,17 +31,17 @@ use Friendica\Module\BaseApi;
|
||||||
*/
|
*/
|
||||||
class Unblock extends BaseApi
|
class Unblock extends BaseApi
|
||||||
{
|
{
|
||||||
public static function post(array $parameters = [])
|
public function post()
|
||||||
{
|
{
|
||||||
self::checkAllowedScope(self::SCOPE_FOLLOW);
|
self::checkAllowedScope(self::SCOPE_FOLLOW);
|
||||||
$uid = self::getCurrentUserID();
|
$uid = self::getCurrentUserID();
|
||||||
|
|
||||||
if (empty($parameters['id'])) {
|
if (empty($this->parameters['id'])) {
|
||||||
DI::mstdnError()->UnprocessableEntity();
|
DI::mstdnError()->UnprocessableEntity();
|
||||||
}
|
}
|
||||||
|
|
||||||
Contact\User::setBlocked($parameters['id'], $uid, false);
|
Contact\User::setBlocked($this->parameters['id'], $uid, false);
|
||||||
|
|
||||||
System::jsonExit(DI::mstdnRelationship()->createFromContactId($parameters['id'], $uid)->toArray());
|
System::jsonExit(DI::mstdnRelationship()->createFromContactId($this->parameters['id'], $uid)->toArray());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,17 +31,17 @@ use Friendica\Module\BaseApi;
|
||||||
*/
|
*/
|
||||||
class Unfollow extends BaseApi
|
class Unfollow extends BaseApi
|
||||||
{
|
{
|
||||||
public static function post(array $parameters = [])
|
public function post()
|
||||||
{
|
{
|
||||||
self::checkAllowedScope(self::SCOPE_FOLLOW);
|
self::checkAllowedScope(self::SCOPE_FOLLOW);
|
||||||
$uid = self::getCurrentUserID();
|
$uid = self::getCurrentUserID();
|
||||||
|
|
||||||
if (empty($parameters['id'])) {
|
if (empty($this->parameters['id'])) {
|
||||||
DI::mstdnError()->UnprocessableEntity();
|
DI::mstdnError()->UnprocessableEntity();
|
||||||
}
|
}
|
||||||
|
|
||||||
Contact::unfollow($parameters['id'], $uid);
|
Contact::unfollow($this->parameters['id'], $uid);
|
||||||
|
|
||||||
System::jsonExit(DI::mstdnRelationship()->createFromContactId($parameters['id'], $uid)->toArray());
|
System::jsonExit(DI::mstdnRelationship()->createFromContactId($this->parameters['id'], $uid)->toArray());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,17 +31,17 @@ use Friendica\Module\BaseApi;
|
||||||
*/
|
*/
|
||||||
class Unmute extends BaseApi
|
class Unmute extends BaseApi
|
||||||
{
|
{
|
||||||
public static function post(array $parameters = [])
|
public function post()
|
||||||
{
|
{
|
||||||
self::checkAllowedScope(self::SCOPE_FOLLOW);
|
self::checkAllowedScope(self::SCOPE_FOLLOW);
|
||||||
$uid = self::getCurrentUserID();
|
$uid = self::getCurrentUserID();
|
||||||
|
|
||||||
if (empty($parameters['id'])) {
|
if (empty($this->parameters['id'])) {
|
||||||
DI::mstdnError()->UnprocessableEntity();
|
DI::mstdnError()->UnprocessableEntity();
|
||||||
}
|
}
|
||||||
|
|
||||||
Contact\User::setIgnored($parameters['id'], $uid, false);
|
Contact\User::setIgnored($this->parameters['id'], $uid, false);
|
||||||
|
|
||||||
System::jsonExit(DI::mstdnRelationship()->createFromContactId($parameters['id'], $uid)->toArray());
|
System::jsonExit(DI::mstdnRelationship()->createFromContactId($this->parameters['id'], $uid)->toArray());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,7 @@ use Friendica\Util\HTTPInputData;
|
||||||
*/
|
*/
|
||||||
class UpdateCredentials extends BaseApi
|
class UpdateCredentials extends BaseApi
|
||||||
{
|
{
|
||||||
public static function patch(array $parameters = [])
|
public function patch()
|
||||||
{
|
{
|
||||||
self::checkAllowedScope(self::SCOPE_WRITE);
|
self::checkAllowedScope(self::SCOPE_WRITE);
|
||||||
$uid = self::getCurrentUserID();
|
$uid = self::getCurrentUserID();
|
||||||
|
|
|
@ -33,10 +33,9 @@ use Friendica\Module\BaseApi;
|
||||||
class VerifyCredentials extends BaseApi
|
class VerifyCredentials extends BaseApi
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @param array $parameters
|
|
||||||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||||
*/
|
*/
|
||||||
public static function rawContent(array $parameters = [])
|
public function rawContent()
|
||||||
{
|
{
|
||||||
self::checkAllowedScope(self::SCOPE_READ);
|
self::checkAllowedScope(self::SCOPE_READ);
|
||||||
$uid = self::getCurrentUserID();
|
$uid = self::getCurrentUserID();
|
||||||
|
|
|
@ -30,10 +30,9 @@ use Friendica\Module\BaseApi;
|
||||||
class Announcements extends BaseApi
|
class Announcements extends BaseApi
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @param array $parameters
|
|
||||||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||||
*/
|
*/
|
||||||
public static function rawContent(array $parameters = [])
|
public function rawContent()
|
||||||
{
|
{
|
||||||
self::checkAllowedScope(self::SCOPE_READ);
|
self::checkAllowedScope(self::SCOPE_READ);
|
||||||
|
|
||||||
|
|
|
@ -33,10 +33,9 @@ use Friendica\Util\Network;
|
||||||
class Apps extends BaseApi
|
class Apps extends BaseApi
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @param array $parameters
|
|
||||||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||||
*/
|
*/
|
||||||
public static function post(array $parameters = [])
|
public function post()
|
||||||
{
|
{
|
||||||
$request = self::getRequest([
|
$request = self::getRequest([
|
||||||
'client_name' => '',
|
'client_name' => '',
|
||||||
|
|
|
@ -30,7 +30,7 @@ use Friendica\Module\BaseApi;
|
||||||
*/
|
*/
|
||||||
class VerifyCredentials extends BaseApi
|
class VerifyCredentials extends BaseApi
|
||||||
{
|
{
|
||||||
public static function rawContent(array $parameters = [])
|
public function rawContent()
|
||||||
{
|
{
|
||||||
self::checkAllowedScope(self::SCOPE_READ);
|
self::checkAllowedScope(self::SCOPE_READ);
|
||||||
$application = self::getCurrentApplication();
|
$application = self::getCurrentApplication();
|
||||||
|
|
|
@ -32,19 +32,18 @@ use Friendica\Module\BaseApi;
|
||||||
class Blocks extends BaseApi
|
class Blocks extends BaseApi
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @param array $parameters
|
|
||||||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||||
*/
|
*/
|
||||||
public static function rawContent(array $parameters = [])
|
public function rawContent()
|
||||||
{
|
{
|
||||||
self::checkAllowedScope(self::SCOPE_READ);
|
self::checkAllowedScope(self::SCOPE_READ);
|
||||||
$uid = self::getCurrentUserID();
|
$uid = self::getCurrentUserID();
|
||||||
|
|
||||||
if (empty($parameters['id'])) {
|
if (empty($this->parameters['id'])) {
|
||||||
DI::mstdnError()->UnprocessableEntity();
|
DI::mstdnError()->UnprocessableEntity();
|
||||||
}
|
}
|
||||||
|
|
||||||
$id = $parameters['id'];
|
$id = $this->parameters['id'];
|
||||||
if (!DBA::exists('contact', ['id' => $id, 'uid' => 0])) {
|
if (!DBA::exists('contact', ['id' => $id, 'uid' => 0])) {
|
||||||
DI::mstdnError()->RecordNotFound();
|
DI::mstdnError()->RecordNotFound();
|
||||||
}
|
}
|
||||||
|
@ -73,7 +72,7 @@ class Blocks extends BaseApi
|
||||||
$params['order'] = ['cid'];
|
$params['order'] = ['cid'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$followers = DBA::select('user-contact', ['cid'], $condition, $parameters);
|
$followers = DBA::select('user-contact', ['cid'], $condition, $this->parameters);
|
||||||
while ($follower = DBA::fetch($followers)) {
|
while ($follower = DBA::fetch($followers)) {
|
||||||
self::setBoundaries($follower['cid']);
|
self::setBoundaries($follower['cid']);
|
||||||
$accounts[] = DI::mstdnAccount()->createFromContactId($follower['cid'], $uid);
|
$accounts[] = DI::mstdnAccount()->createFromContactId($follower['cid'], $uid);
|
||||||
|
|
|
@ -34,10 +34,9 @@ use Friendica\Network\HTTPException;
|
||||||
class Bookmarks extends BaseApi
|
class Bookmarks extends BaseApi
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @param array $parameters
|
|
||||||
* @throws HTTPException\InternalServerErrorException
|
* @throws HTTPException\InternalServerErrorException
|
||||||
*/
|
*/
|
||||||
public static function rawContent(array $parameters = [])
|
public function rawContent()
|
||||||
{
|
{
|
||||||
self::checkAllowedScope(self::SCOPE_READ);
|
self::checkAllowedScope(self::SCOPE_READ);
|
||||||
$uid = self::getCurrentUserID();
|
$uid = self::getCurrentUserID();
|
||||||
|
|
|
@ -31,26 +31,25 @@ use Friendica\Module\BaseApi;
|
||||||
*/
|
*/
|
||||||
class Conversations extends BaseApi
|
class Conversations extends BaseApi
|
||||||
{
|
{
|
||||||
public static function delete(array $parameters = [])
|
public function delete()
|
||||||
{
|
{
|
||||||
self::checkAllowedScope(self::SCOPE_WRITE);
|
self::checkAllowedScope(self::SCOPE_WRITE);
|
||||||
$uid = self::getCurrentUserID();
|
$uid = self::getCurrentUserID();
|
||||||
|
|
||||||
if (!empty($parameters['id'])) {
|
if (!empty($this->parameters['id'])) {
|
||||||
DI::mstdnError()->UnprocessableEntity();
|
DI::mstdnError()->UnprocessableEntity();
|
||||||
}
|
}
|
||||||
|
|
||||||
DBA::delete('conv', ['id' => $parameters['id'], 'uid' => $uid]);
|
DBA::delete('conv', ['id' => $this->parameters['id'], 'uid' => $uid]);
|
||||||
DBA::delete('mail', ['convid' => $parameters['id'], 'uid' => $uid]);
|
DBA::delete('mail', ['convid' => $this->parameters['id'], 'uid' => $uid]);
|
||||||
|
|
||||||
System::jsonExit([]);
|
System::jsonExit([]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array $parameters
|
|
||||||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||||
*/
|
*/
|
||||||
public static function rawContent(array $parameters = [])
|
public function rawContent()
|
||||||
{
|
{
|
||||||
self::checkAllowedScope(self::SCOPE_READ);
|
self::checkAllowedScope(self::SCOPE_READ);
|
||||||
$uid = self::getCurrentUserID();
|
$uid = self::getCurrentUserID();
|
||||||
|
|
|
@ -31,17 +31,17 @@ use Friendica\Module\BaseApi;
|
||||||
*/
|
*/
|
||||||
class Read extends BaseApi
|
class Read extends BaseApi
|
||||||
{
|
{
|
||||||
public static function post(array $parameters = [])
|
public function post()
|
||||||
{
|
{
|
||||||
self::checkAllowedScope(self::SCOPE_WRITE);
|
self::checkAllowedScope(self::SCOPE_WRITE);
|
||||||
$uid = self::getCurrentUserID();
|
$uid = self::getCurrentUserID();
|
||||||
|
|
||||||
if (!empty($parameters['id'])) {
|
if (!empty($this->parameters['id'])) {
|
||||||
DI::mstdnError()->UnprocessableEntity();
|
DI::mstdnError()->UnprocessableEntity();
|
||||||
}
|
}
|
||||||
|
|
||||||
DBA::update('mail', ['seen' => true], ['convid' => $parameters['id'], 'uid' => $uid]);
|
DBA::update('mail', ['seen' => true], ['convid' => $this->parameters['id'], 'uid' => $uid]);
|
||||||
|
|
||||||
System::jsonExit(DI::mstdnConversation()->CreateFromConvId($parameters['id'])->toArray());
|
System::jsonExit(DI::mstdnConversation()->CreateFromConvId($this->parameters['id'])->toArray());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,12 +33,11 @@ use Friendica\Network\HTTPException;
|
||||||
class CustomEmojis extends BaseApi
|
class CustomEmojis extends BaseApi
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @param array $parameters
|
|
||||||
* @throws HTTPException\InternalServerErrorException
|
* @throws HTTPException\InternalServerErrorException
|
||||||
* @throws \ImagickException
|
* @throws \ImagickException
|
||||||
* @see https://docs.joinmastodon.org/methods/accounts/follow_requests#pending-follows
|
* @see https://docs.joinmastodon.org/methods/accounts/follow_requests#pending-follows
|
||||||
*/
|
*/
|
||||||
public static function rawContent(array $parameters = [])
|
public function rawContent()
|
||||||
{
|
{
|
||||||
$emojis = DI::mstdnEmoji()->createCollectionFromSmilies(Smilies::getList());
|
$emojis = DI::mstdnEmoji()->createCollectionFromSmilies(Smilies::getList());
|
||||||
|
|
||||||
|
|
|
@ -35,12 +35,11 @@ use Friendica\Network\HTTPException;
|
||||||
class Directory extends BaseApi
|
class Directory extends BaseApi
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @param array $parameters
|
|
||||||
* @throws HTTPException\InternalServerErrorException
|
* @throws HTTPException\InternalServerErrorException
|
||||||
* @throws \ImagickException
|
* @throws \ImagickException
|
||||||
* @see https://docs.joinmastodon.org/methods/instance/directory/
|
* @see https://docs.joinmastodon.org/methods/instance/directory/
|
||||||
*/
|
*/
|
||||||
public static function rawContent(array $parameters = [])
|
public function rawContent()
|
||||||
{
|
{
|
||||||
$request = self::getRequest([
|
$request = self::getRequest([
|
||||||
'offset' => 0, // How many accounts to skip before returning results. Default 0.
|
'offset' => 0, // How many accounts to skip before returning results. Default 0.
|
||||||
|
|
|
@ -30,10 +30,9 @@ use Friendica\Module\BaseApi;
|
||||||
class Endorsements extends BaseApi
|
class Endorsements extends BaseApi
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @param array $parameters
|
|
||||||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||||
*/
|
*/
|
||||||
public static function rawContent(array $parameters = [])
|
public function rawContent()
|
||||||
{
|
{
|
||||||
System::jsonExit([]);
|
System::jsonExit([]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,10 +35,9 @@ use Friendica\Protocol\Activity;
|
||||||
class Favourited extends BaseApi
|
class Favourited extends BaseApi
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @param array $parameters
|
|
||||||
* @throws HTTPException\InternalServerErrorException
|
* @throws HTTPException\InternalServerErrorException
|
||||||
*/
|
*/
|
||||||
public static function rawContent(array $parameters = [])
|
public function rawContent()
|
||||||
{
|
{
|
||||||
self::checkAllowedScope(self::SCOPE_READ);
|
self::checkAllowedScope(self::SCOPE_READ);
|
||||||
$uid = self::getCurrentUserID();
|
$uid = self::getCurrentUserID();
|
||||||
|
|
|
@ -31,7 +31,7 @@ use Friendica\Module\BaseApi;
|
||||||
*/
|
*/
|
||||||
class Filters extends BaseApi
|
class Filters extends BaseApi
|
||||||
{
|
{
|
||||||
public static function post(array $parameters = [])
|
public function post()
|
||||||
{
|
{
|
||||||
self::checkAllowedScope(self::SCOPE_WRITE);
|
self::checkAllowedScope(self::SCOPE_WRITE);
|
||||||
|
|
||||||
|
@ -39,10 +39,9 @@ class Filters extends BaseApi
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array $parameters
|
|
||||||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||||
*/
|
*/
|
||||||
public static function rawContent(array $parameters = [])
|
public function rawContent()
|
||||||
{
|
{
|
||||||
self::checkAllowedScope(self::SCOPE_READ);
|
self::checkAllowedScope(self::SCOPE_READ);
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,6 @@ use Friendica\Network\HTTPException;
|
||||||
class FollowRequests extends BaseApi
|
class FollowRequests extends BaseApi
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @param array $parameters
|
|
||||||
* @throws HTTPException\BadRequestException
|
* @throws HTTPException\BadRequestException
|
||||||
* @throws HTTPException\InternalServerErrorException
|
* @throws HTTPException\InternalServerErrorException
|
||||||
* @throws HTTPException\NotFoundException
|
* @throws HTTPException\NotFoundException
|
||||||
|
@ -43,16 +42,16 @@ class FollowRequests extends BaseApi
|
||||||
* @see https://docs.joinmastodon.org/methods/accounts/follow_requests#accept-follow
|
* @see https://docs.joinmastodon.org/methods/accounts/follow_requests#accept-follow
|
||||||
* @see https://docs.joinmastodon.org/methods/accounts/follow_requests#reject-follow
|
* @see https://docs.joinmastodon.org/methods/accounts/follow_requests#reject-follow
|
||||||
*/
|
*/
|
||||||
public static function post(array $parameters = [])
|
public function post()
|
||||||
{
|
{
|
||||||
self::checkAllowedScope(self::SCOPE_FOLLOW);
|
self::checkAllowedScope(self::SCOPE_FOLLOW);
|
||||||
$uid = self::getCurrentUserID();
|
$uid = self::getCurrentUserID();
|
||||||
|
|
||||||
$introduction = DI::intro()->selectOneById($parameters['id'], $uid);
|
$introduction = DI::intro()->selectOneById($this->parameters['id'], $uid);
|
||||||
|
|
||||||
$contactId = $introduction->cid;
|
$contactId = $introduction->cid;
|
||||||
|
|
||||||
switch ($parameters['action']) {
|
switch ($this->parameters['action']) {
|
||||||
case 'authorize':
|
case 'authorize':
|
||||||
Contact\Introduction::confirm($introduction);
|
Contact\Introduction::confirm($introduction);
|
||||||
$relationship = DI::mstdnRelationship()->createFromContactId($contactId, $uid);
|
$relationship = DI::mstdnRelationship()->createFromContactId($contactId, $uid);
|
||||||
|
@ -79,12 +78,11 @@ class FollowRequests extends BaseApi
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array $parameters
|
|
||||||
* @throws HTTPException\InternalServerErrorException
|
* @throws HTTPException\InternalServerErrorException
|
||||||
* @throws \ImagickException
|
* @throws \ImagickException
|
||||||
* @see https://docs.joinmastodon.org/methods/accounts/follow_requests/
|
* @see https://docs.joinmastodon.org/methods/accounts/follow_requests/
|
||||||
*/
|
*/
|
||||||
public static function rawContent(array $parameters = [])
|
public function rawContent()
|
||||||
{
|
{
|
||||||
self::checkAllowedScope(self::SCOPE_READ);
|
self::checkAllowedScope(self::SCOPE_READ);
|
||||||
$uid = self::getCurrentUserID();
|
$uid = self::getCurrentUserID();
|
||||||
|
|
|
@ -31,10 +31,9 @@ use Friendica\Object\Api\Mastodon\Instance as InstanceEntity;
|
||||||
class Instance extends BaseApi
|
class Instance extends BaseApi
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @param array $parameters
|
|
||||||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||||
*/
|
*/
|
||||||
public static function rawContent(array $parameters = [])
|
public function rawContent()
|
||||||
{
|
{
|
||||||
System::jsonExit(InstanceEntity::get());
|
System::jsonExit(InstanceEntity::get());
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,10 +34,9 @@ use Friendica\Util\Network;
|
||||||
class Peers extends BaseApi
|
class Peers extends BaseApi
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @param array $parameters
|
|
||||||
* @throws HTTPException\InternalServerErrorException
|
* @throws HTTPException\InternalServerErrorException
|
||||||
*/
|
*/
|
||||||
public static function rawContent(array $parameters = [])
|
public function rawContent()
|
||||||
{
|
{
|
||||||
$return = [];
|
$return = [];
|
||||||
|
|
||||||
|
|
|
@ -34,10 +34,9 @@ use Friendica\Network\HTTPException;
|
||||||
class Rules extends BaseApi
|
class Rules extends BaseApi
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @param array $parameters
|
|
||||||
* @throws HTTPException\InternalServerErrorException
|
* @throws HTTPException\InternalServerErrorException
|
||||||
*/
|
*/
|
||||||
public static function rawContent(array $parameters = [])
|
public function rawContent()
|
||||||
{
|
{
|
||||||
$rules = [];
|
$rules = [];
|
||||||
$id = 0;
|
$id = 0;
|
||||||
|
|
|
@ -31,27 +31,27 @@ use Friendica\Model\Group;
|
||||||
*/
|
*/
|
||||||
class Lists extends BaseApi
|
class Lists extends BaseApi
|
||||||
{
|
{
|
||||||
public static function delete(array $parameters = [])
|
public function delete()
|
||||||
{
|
{
|
||||||
self::checkAllowedScope(self::SCOPE_WRITE);
|
self::checkAllowedScope(self::SCOPE_WRITE);
|
||||||
$uid = self::getCurrentUserID();
|
$uid = self::getCurrentUserID();
|
||||||
|
|
||||||
if (empty($parameters['id'])) {
|
if (empty($this->parameters['id'])) {
|
||||||
DI::mstdnError()->UnprocessableEntity();
|
DI::mstdnError()->UnprocessableEntity();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Group::exists($parameters['id'], $uid)) {
|
if (!Group::exists($this->parameters['id'], $uid)) {
|
||||||
DI::mstdnError()->RecordNotFound();
|
DI::mstdnError()->RecordNotFound();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Group::remove($parameters['id'])) {
|
if (!Group::remove($this->parameters['id'])) {
|
||||||
DI::mstdnError()->InternalError();
|
DI::mstdnError()->InternalError();
|
||||||
}
|
}
|
||||||
|
|
||||||
System::jsonExit([]);
|
System::jsonExit([]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function post(array $parameters = [])
|
public function post()
|
||||||
{
|
{
|
||||||
self::checkAllowedScope(self::SCOPE_WRITE);
|
self::checkAllowedScope(self::SCOPE_WRITE);
|
||||||
$uid = self::getCurrentUserID();
|
$uid = self::getCurrentUserID();
|
||||||
|
@ -74,30 +74,29 @@ class Lists extends BaseApi
|
||||||
System::jsonExit(DI::mstdnList()->createFromGroupId($id));
|
System::jsonExit(DI::mstdnList()->createFromGroupId($id));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function put(array $parameters = [])
|
public function put()
|
||||||
{
|
{
|
||||||
$request = self::getRequest([
|
$request = self::getRequest([
|
||||||
'title' => '', // The title of the list to be updated.
|
'title' => '', // The title of the list to be updated.
|
||||||
'replies_policy' => '', // One of: "followed", "list", or "none".
|
'replies_policy' => '', // One of: "followed", "list", or "none".
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if (empty($request['title']) || empty($parameters['id'])) {
|
if (empty($request['title']) || empty($this->parameters['id'])) {
|
||||||
DI::mstdnError()->UnprocessableEntity();
|
DI::mstdnError()->UnprocessableEntity();
|
||||||
}
|
}
|
||||||
|
|
||||||
Group::update($parameters['id'], $request['title']);
|
Group::update($this->parameters['id'], $request['title']);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array $parameters
|
|
||||||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||||
*/
|
*/
|
||||||
public static function rawContent(array $parameters = [])
|
public function rawContent()
|
||||||
{
|
{
|
||||||
self::checkAllowedScope(self::SCOPE_READ);
|
self::checkAllowedScope(self::SCOPE_READ);
|
||||||
$uid = self::getCurrentUserID();
|
$uid = self::getCurrentUserID();
|
||||||
|
|
||||||
if (empty($parameters['id'])) {
|
if (empty($this->parameters['id'])) {
|
||||||
$lists = [];
|
$lists = [];
|
||||||
|
|
||||||
$groups = Group::getByUserId($uid);
|
$groups = Group::getByUserId($uid);
|
||||||
|
@ -106,7 +105,7 @@ class Lists extends BaseApi
|
||||||
$lists[] = DI::mstdnList()->createFromGroupId($group['id']);
|
$lists[] = DI::mstdnList()->createFromGroupId($group['id']);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$id = $parameters['id'];
|
$id = $this->parameters['id'];
|
||||||
|
|
||||||
if (!Group::exists($id, $uid)) {
|
if (!Group::exists($id, $uid)) {
|
||||||
DI::mstdnError()->RecordNotFound();
|
DI::mstdnError()->RecordNotFound();
|
||||||
|
|
|
@ -35,30 +35,29 @@ use Friendica\Module\BaseApi;
|
||||||
*/
|
*/
|
||||||
class Accounts extends BaseApi
|
class Accounts extends BaseApi
|
||||||
{
|
{
|
||||||
public static function delete(array $parameters = [])
|
public function delete()
|
||||||
{
|
{
|
||||||
DI::apiResponse()->unsupported(Router::DELETE);
|
DI::apiResponse()->unsupported(Router::DELETE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function post(array $parameters = [])
|
public function post()
|
||||||
{
|
{
|
||||||
DI::apiResponse()->unsupported(Router::POST);
|
DI::apiResponse()->unsupported(Router::POST);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array $parameters
|
|
||||||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||||
*/
|
*/
|
||||||
public static function rawContent(array $parameters = [])
|
public function rawContent()
|
||||||
{
|
{
|
||||||
self::checkAllowedScope(self::SCOPE_READ);
|
self::checkAllowedScope(self::SCOPE_READ);
|
||||||
$uid = self::getCurrentUserID();
|
$uid = self::getCurrentUserID();
|
||||||
|
|
||||||
if (empty($parameters['id'])) {
|
if (empty($this->parameters['id'])) {
|
||||||
DI::mstdnError()->UnprocessableEntity();
|
DI::mstdnError()->UnprocessableEntity();
|
||||||
}
|
}
|
||||||
|
|
||||||
$id = $parameters['id'];
|
$id = $this->parameters['id'];
|
||||||
if (!DBA::exists('group', ['id' => $id, 'uid' => $uid])) {
|
if (!DBA::exists('group', ['id' => $id, 'uid' => $uid])) {
|
||||||
DI::mstdnError()->RecordNotFound();
|
DI::mstdnError()->RecordNotFound();
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,7 @@ use Friendica\Module\BaseApi;
|
||||||
*/
|
*/
|
||||||
class Markers extends BaseApi
|
class Markers extends BaseApi
|
||||||
{
|
{
|
||||||
public static function post(array $parameters = [])
|
public function post()
|
||||||
{
|
{
|
||||||
self::checkAllowedScope(self::SCOPE_WRITE);
|
self::checkAllowedScope(self::SCOPE_WRITE);
|
||||||
|
|
||||||
|
@ -39,10 +39,9 @@ class Markers extends BaseApi
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array $parameters
|
|
||||||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||||
*/
|
*/
|
||||||
public static function rawContent(array $parameters = [])
|
public function rawContent()
|
||||||
{
|
{
|
||||||
self::checkAllowedScope(self::SCOPE_READ);
|
self::checkAllowedScope(self::SCOPE_READ);
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,7 @@ use Friendica\Module\BaseApi;
|
||||||
*/
|
*/
|
||||||
class Media extends BaseApi
|
class Media extends BaseApi
|
||||||
{
|
{
|
||||||
public static function post(array $parameters = [])
|
public function post()
|
||||||
{
|
{
|
||||||
self::checkAllowedScope(self::SCOPE_WRITE);
|
self::checkAllowedScope(self::SCOPE_WRITE);
|
||||||
$uid = self::getCurrentUserID();
|
$uid = self::getCurrentUserID();
|
||||||
|
@ -53,7 +53,7 @@ class Media extends BaseApi
|
||||||
System::jsonExit(DI::mstdnAttachment()->createFromPhoto($media['id']));
|
System::jsonExit(DI::mstdnAttachment()->createFromPhoto($media['id']));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function put(array $parameters = [])
|
public function put()
|
||||||
{
|
{
|
||||||
self::checkAllowedScope(self::SCOPE_WRITE);
|
self::checkAllowedScope(self::SCOPE_WRITE);
|
||||||
$uid = self::getCurrentUserID();
|
$uid = self::getCurrentUserID();
|
||||||
|
@ -65,34 +65,33 @@ class Media extends BaseApi
|
||||||
'focus' => '', // Two floating points (x,y), comma-delimited ranging from -1.0 to 1.0
|
'focus' => '', // Two floating points (x,y), comma-delimited ranging from -1.0 to 1.0
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if (empty($parameters['id'])) {
|
if (empty($this->parameters['id'])) {
|
||||||
DI::mstdnError()->UnprocessableEntity();
|
DI::mstdnError()->UnprocessableEntity();
|
||||||
}
|
}
|
||||||
|
|
||||||
$photo = Photo::selectFirst(['resource-id'], ['id' => $parameters['id'], 'uid' => $uid]);
|
$photo = Photo::selectFirst(['resource-id'], ['id' => $this->parameters['id'], 'uid' => $uid]);
|
||||||
if (empty($photo['resource-id'])) {
|
if (empty($photo['resource-id'])) {
|
||||||
DI::mstdnError()->RecordNotFound();
|
DI::mstdnError()->RecordNotFound();
|
||||||
}
|
}
|
||||||
|
|
||||||
Photo::update(['desc' => $request['description']], ['resource-id' => $photo['resource-id']]);
|
Photo::update(['desc' => $request['description']], ['resource-id' => $photo['resource-id']]);
|
||||||
|
|
||||||
System::jsonExit(DI::mstdnAttachment()->createFromPhoto($parameters['id']));
|
System::jsonExit(DI::mstdnAttachment()->createFromPhoto($this->parameters['id']));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array $parameters
|
|
||||||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||||
*/
|
*/
|
||||||
public static function rawContent(array $parameters = [])
|
public function rawContent()
|
||||||
{
|
{
|
||||||
self::checkAllowedScope(self::SCOPE_READ);
|
self::checkAllowedScope(self::SCOPE_READ);
|
||||||
$uid = self::getCurrentUserID();
|
$uid = self::getCurrentUserID();
|
||||||
|
|
||||||
if (empty($parameters['id'])) {
|
if (empty($this->parameters['id'])) {
|
||||||
DI::mstdnError()->UnprocessableEntity();
|
DI::mstdnError()->UnprocessableEntity();
|
||||||
}
|
}
|
||||||
|
|
||||||
$id = $parameters['id'];
|
$id = $this->parameters['id'];
|
||||||
if (!Photo::exists(['id' => $id, 'uid' => $uid])) {
|
if (!Photo::exists(['id' => $id, 'uid' => $uid])) {
|
||||||
DI::mstdnError()->RecordNotFound();
|
DI::mstdnError()->RecordNotFound();
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,19 +32,18 @@ use Friendica\Module\BaseApi;
|
||||||
class Mutes extends BaseApi
|
class Mutes extends BaseApi
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @param array $parameters
|
|
||||||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||||
*/
|
*/
|
||||||
public static function rawContent(array $parameters = [])
|
public function rawContent()
|
||||||
{
|
{
|
||||||
self::checkAllowedScope(self::SCOPE_READ);
|
self::checkAllowedScope(self::SCOPE_READ);
|
||||||
$uid = self::getCurrentUserID();
|
$uid = self::getCurrentUserID();
|
||||||
|
|
||||||
if (empty($parameters['id'])) {
|
if (empty($this->parameters['id'])) {
|
||||||
DI::mstdnError()->UnprocessableEntity();
|
DI::mstdnError()->UnprocessableEntity();
|
||||||
}
|
}
|
||||||
|
|
||||||
$id = $parameters['id'];
|
$id = $this->parameters['id'];
|
||||||
if (!DBA::exists('contact', ['id' => $id, 'uid' => 0])) {
|
if (!DBA::exists('contact', ['id' => $id, 'uid' => 0])) {
|
||||||
DI::mstdnError()->RecordNotFound();
|
DI::mstdnError()->RecordNotFound();
|
||||||
}
|
}
|
||||||
|
@ -73,7 +72,7 @@ class Mutes extends BaseApi
|
||||||
$params['order'] = ['cid'];
|
$params['order'] = ['cid'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$followers = DBA::select('user-contact', ['cid'], $condition, $parameters);
|
$followers = DBA::select('user-contact', ['cid'], $condition, $this->parameters);
|
||||||
while ($follower = DBA::fetch($followers)) {
|
while ($follower = DBA::fetch($followers)) {
|
||||||
self::setBoundaries($follower['cid']);
|
self::setBoundaries($follower['cid']);
|
||||||
$accounts[] = DI::mstdnAccount()->createFromContactId($follower['cid'], $uid);
|
$accounts[] = DI::mstdnAccount()->createFromContactId($follower['cid'], $uid);
|
||||||
|
|
|
@ -38,16 +38,15 @@ use Friendica\Protocol\Activity;
|
||||||
class Notifications extends BaseApi
|
class Notifications extends BaseApi
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @param array $parameters
|
|
||||||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||||
*/
|
*/
|
||||||
public static function rawContent(array $parameters = [])
|
public function rawContent()
|
||||||
{
|
{
|
||||||
self::checkAllowedScope(self::SCOPE_READ);
|
self::checkAllowedScope(self::SCOPE_READ);
|
||||||
$uid = self::getCurrentUserID();
|
$uid = self::getCurrentUserID();
|
||||||
|
|
||||||
if (!empty($parameters['id'])) {
|
if (!empty($this->parameters['id'])) {
|
||||||
$id = $parameters['id'];
|
$id = $this->parameters['id'];
|
||||||
try {
|
try {
|
||||||
$notification = DI::notification()->selectOneForUser($uid, ['id' => $id]);
|
$notification = DI::notification()->selectOneForUser($uid, ['id' => $id]);
|
||||||
System::jsonExit(DI::mstdnNotification()->createFromNotification($notification));
|
System::jsonExit(DI::mstdnNotification()->createFromNotification($notification));
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user