Replace $parameters argument per method with static::$parameters

This commit is contained in:
Philipp 2021-11-14 20:46:25 +01:00
parent 018275919c
commit 714f0febc4
No known key found for this signature in database
GPG key ID: 24A7501396EB5432
249 changed files with 710 additions and 775 deletions

View file

@ -297,32 +297,32 @@ class Module
Core\Hook::callAll($this->module . '_mod_init', $placeholder);
$this->module_class::init($this->module_class::getParameters());
$this->module_class::init();
$profiler->set(microtime(true) - $timestamp, 'init');
if ($server['REQUEST_METHOD'] === Router::DELETE) {
$this->module_class::delete($this->module_class::getParameters());
$this->module_class::delete();
}
if ($server['REQUEST_METHOD'] === Router::PATCH) {
$this->module_class::patch($this->module_class::getParameters());
$this->module_class::patch();
}
if ($server['REQUEST_METHOD'] === Router::POST) {
Core\Hook::callAll($this->module . '_mod_post', $post);
$this->module_class::post($this->module_class::getParameters());
$this->module_class::post();
}
if ($server['REQUEST_METHOD'] === Router::PUT) {
$this->module_class::put($this->module_class::getParameters());
$this->module_class::put();
}
Core\Hook::callAll($this->module . '_mod_afterpost', $placeholder);
$this->module_class::afterpost($this->module_class::getParameters());
$this->module_class::afterpost();
// "rawContent" is especially meant for technical endpoints.
// This endpoint doesn't need any theme initialization or other comparable stuff.
$this->module_class::rawContent($this->module_class::getParameters());
$this->module_class::rawContent();
}
}

View file

@ -352,7 +352,7 @@ class Page implements ArrayAccess
$arr = ['content' => $content];
Hook::callAll( $moduleClass::getClassName() . '_mod_content', $arr);
$content = $arr['content'];
$arr = ['content' => $moduleClass::content($moduleClass::getParameters())];
$arr = ['content' => $moduleClass::content()];
Hook::callAll($moduleClass::getClassName() . '_mod_aftercontent', $arr);
$content .= $arr['content'];
} catch (HTTPException $e) {

View file

@ -44,25 +44,17 @@ abstract class BaseModule implements ICanHandleRequests
static::$parameters = $parameters;
}
/**
* @return array
*/
public static function getParameters(): array
{
return self::$parameters;
}
/**
* {@inheritDoc}
*/
public static function init(array $parameters = [])
public static function init()
{
}
/**
* {@inheritDoc}
*/
public static function rawContent(array $parameters = [])
public static function rawContent()
{
// echo '';
// exit;
@ -71,7 +63,7 @@ abstract class BaseModule implements ICanHandleRequests
/**
* {@inheritDoc}
*/
public static function content(array $parameters = [])
public static function content()
{
return '';
}
@ -79,21 +71,21 @@ abstract class BaseModule implements ICanHandleRequests
/**
* {@inheritDoc}
*/
public static function delete(array $parameters = [])
public static function delete()
{
}
/**
* {@inheritDoc}
*/
public static function patch(array $parameters = [])
public static function patch()
{
}
/**
* {@inheritDoc}
*/
public static function post(array $parameters = [])
public static function post()
{
// DI::baseurl()->redirect('module');
}
@ -101,14 +93,14 @@ abstract class BaseModule implements ICanHandleRequests
/**
* {@inheritDoc}
*/
public static function afterpost(array $parameters = [])
public static function afterpost()
{
}
/**
* {@inheritDoc}
*/
public static function put(array $parameters = [])
public static function put()
{
}

View file

@ -13,7 +13,7 @@ interface ICanHandleRequests
* Extend this method if you need to do any shared processing before both
* content() or post()
*/
public static function init(array $parameters = []);
public static function init();
/**
* Module GET method to display raw content from technical endpoints
@ -21,7 +21,7 @@ interface ICanHandleRequests
* Extend this method if the module is supposed to return communication data,
* e.g. from protocol implementations.
*/
public static function rawContent(array $parameters = []);
public static function rawContent();
/**
* Module GET method to display any content
@ -32,7 +32,7 @@ interface ICanHandleRequests
*
* @return string
*/
public static function content(array $parameters = []);
public static function content();
/**
* Module DELETE method to process submitted data
@ -40,7 +40,7 @@ interface ICanHandleRequests
* Extend this method if the module is supposed to process DELETE requests.
* Doesn't display any content
*/
public static function delete(array $parameters = []);
public static function delete();
/**
* Module PATCH method to process submitted data
@ -48,7 +48,7 @@ interface ICanHandleRequests
* Extend this method if the module is supposed to process PATCH requests.
* Doesn't display any content
*/
public static function patch(array $parameters = []);
public static function patch();
/**
* Module POST method to process submitted data
@ -56,14 +56,14 @@ interface ICanHandleRequests
* Extend this method if the module is supposed to process POST requests.
* Doesn't display any content
*/
public static function post(array $parameters = []);
public static function post();
/**
* Called after post()
*
* Unknown purpose
*/
public static function afterpost(array $parameters = []);
public static function afterpost();
/**
* Module PUT method to process submitted data
@ -71,9 +71,7 @@ interface ICanHandleRequests
* Extend this method if the module is supposed to process PUT requests.
* Doesn't display any content
*/
public static function put(array $parameters = []);
public static function put();
public static function getClassName(): string;
public static function getParameters(): array;
}

View file

@ -54,24 +54,24 @@ class LegacyModule extends BaseModule
require_once $file_path;
}
public static function init(array $parameters = [])
public static function init()
{
self::runModuleFunction('init', $parameters);
self::runModuleFunction('init', static::$parameters);
}
public static function content(array $parameters = [])
public static function content()
{
return self::runModuleFunction('content', $parameters);
return self::runModuleFunction('content', static::$parameters);
}
public static function post(array $parameters = [])
public static function post()
{
self::runModuleFunction('post', $parameters);
self::runModuleFunction('post', static::$parameters);
}
public static function afterpost(array $parameters = [])
public static function afterpost()
{
self::runModuleFunction('afterpost', $parameters);
self::runModuleFunction('afterpost', static::$parameters);
}
/**

View file

@ -30,7 +30,7 @@ use Friendica\BaseModule;
*/
class AccountManagementControlDocument extends BaseModule
{
public static function rawContent(array $parameters = [])
public static function rawContent()
{
$output = [
'version' => 1,

View file

@ -30,7 +30,7 @@ use Friendica\Model\Contact;
*/
class Acctlink extends BaseModule
{
public static function content(array $parameters = [])
public static function content()
{
$addr = trim($_GET['addr'] ?? '');

View file

@ -31,14 +31,14 @@ use Friendica\Protocol\ActivityPub;
*/
class Followers extends BaseModule
{
public static function rawContent(array $parameters = [])
public static function rawContent()
{
if (empty($parameters['nickname'])) {
if (empty(static::$parameters['nickname'])) {
throw new \Friendica\Network\HTTPException\NotFoundException();
}
// @TODO: Replace with parameter from router
$owner = User::getOwnerDataByNick($parameters['nickname']);
$owner = User::getOwnerDataByNick(static::$parameters['nickname']);
if (empty($owner)) {
throw new \Friendica\Network\HTTPException\NotFoundException();
}

View file

@ -31,13 +31,13 @@ use Friendica\Protocol\ActivityPub;
*/
class Following extends BaseModule
{
public static function rawContent(array $parameters = [])
public static function rawContent()
{
if (empty($parameters['nickname'])) {
if (empty(static::$parameters['nickname'])) {
throw new \Friendica\Network\HTTPException\NotFoundException();
}
$owner = User::getOwnerDataByNick($parameters['nickname']);
$owner = User::getOwnerDataByNick(static::$parameters['nickname']);
if (empty($owner)) {
throw new \Friendica\Network\HTTPException\NotFoundException();
}

View file

@ -35,7 +35,7 @@ use Friendica\Util\Network;
*/
class Inbox extends BaseModule
{
public static function rawContent(array $parameters = [])
public static function rawContent()
{
$postdata = Network::postdata();
@ -50,12 +50,12 @@ class Inbox extends BaseModule
$filename = 'failed-activitypub';
}
$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' => static::$parameters, 'header' => $_SERVER, 'body' => $postdata], JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE));
Logger::notice('Incoming message stored', ['file' => $tempfile]);
}
if (!empty($parameters['nickname'])) {
$user = DBA::selectFirst('user', ['uid'], ['nickname' => $parameters['nickname']]);
if (!empty(static::$parameters['nickname'])) {
$user = DBA::selectFirst('user', ['uid'], ['nickname' => static::$parameters['nickname']]);
if (!DBA::isResult($user)) {
throw new \Friendica\Network\HTTPException\NotFoundException();
}

View file

@ -41,9 +41,9 @@ use Friendica\Util\Strings;
*/
class Objects extends BaseModule
{
public static function rawContent(array $parameters = [])
public static function rawContent()
{
if (empty($parameters['guid'])) {
if (empty(static::$parameters['guid'])) {
throw new HTTPException\BadRequestException();
}
@ -51,10 +51,10 @@ class Objects extends BaseModule
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' => static::$parameters['guid']]);
if (DBA::isResult($itemuri)) {
Logger::info('Provided GUID found.', ['guid' => $parameters['guid'], 'uri-id' => $itemuri['id']]);
Logger::info('Provided GUID found.', ['guid' => static::$parameters['guid'], 'uri-id' => $itemuri['id']]);
} else {
// 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();
@ -104,11 +104,11 @@ class Objects extends BaseModule
throw new HTTPException\NotFoundException();
}
$etag = md5($parameters['guid'] . '-' . $item['changed']);
$etag = md5(static::$parameters['guid'] . '-' . $item['changed']);
$last_modified = $item['changed'];
Network::checkEtagModified($etag, $last_modified);
if (empty($parameters['activity']) && ($item['gravity'] != GRAVITY_ACTIVITY)) {
if (empty(static::$parameters['activity']) && ($item['gravity'] != GRAVITY_ACTIVITY)) {
$activity = ActivityPub\Transmitter::createActivityFromItem($item['id'], true);
if (empty($activity['type'])) {
throw new HTTPException\NotFoundException();
@ -123,16 +123,16 @@ class Objects extends BaseModule
$data = ['@context' => ActivityPub::CONTEXT];
$data = array_merge($data, $activity['object']);
} elseif (empty($parameters['activity']) || in_array($parameters['activity'],
} elseif (empty(static::$parameters['activity']) || in_array(static::$parameters['activity'],
['Create', 'Announce', 'Update', 'Like', 'Dislike', 'Accept', 'Reject',
'TentativeAccept', 'Follow', 'Add'])) {
$data = ActivityPub\Transmitter::createActivityFromItem($item['id']);
if (empty($data)) {
throw new HTTPException\NotFoundException();
}
if (!empty($parameters['activity']) && ($parameters['activity'] != 'Create')) {
$data['type'] = $parameters['activity'];
$data['id'] = str_replace('/Create', '/' . $parameters['activity'], $data['id']);
if (!empty(static::$parameters['activity']) && (static::$parameters['activity'] != 'Create')) {
$data['type'] = static::$parameters['activity'];
$data['id'] = str_replace('/Create', '/' . static::$parameters['activity'], $data['id']);
}
} else {
throw new HTTPException\NotFoundException();

View file

@ -31,13 +31,13 @@ use Friendica\Util\HTTPSignature;
*/
class Outbox extends BaseModule
{
public static function rawContent(array $parameters = [])
public static function rawContent()
{
if (empty($parameters['nickname'])) {
if (empty(static::$parameters['nickname'])) {
throw new \Friendica\Network\HTTPException\NotFoundException();
}
$owner = User::getOwnerDataByNick($parameters['nickname']);
$owner = User::getOwnerDataByNick(static::$parameters['nickname']);
if (empty($owner)) {
throw new \Friendica\Network\HTTPException\NotFoundException();
}

View file

@ -30,11 +30,11 @@ use Friendica\Util\Strings;
class Details extends BaseAdmin
{
public static function post(array $parameters = [])
public static function post()
{
self::checkAdminAccess();
$addon = Strings::sanitizeFilePathItem($parameters['addon']);
$addon = Strings::sanitizeFilePathItem(static::$parameters['addon']);
$redirect = 'admin/addons/' . $addon;
@ -52,15 +52,15 @@ class Details extends BaseAdmin
DI::baseUrl()->redirect($redirect);
}
public static function content(array $parameters = [])
public static function content()
{
parent::content($parameters);
parent::content();
$a = DI::app();
$addons_admin = Addon::getAdminList();
$addon = Strings::sanitizeFilePathItem($parameters['addon']);
$addon = Strings::sanitizeFilePathItem(static::$parameters['addon']);
if (!is_file("addon/$addon/$addon.php")) {
notice(DI::l10n()->t('Addon not found.'));
Addon::uninstall($addon);

View file

@ -28,9 +28,9 @@ use Friendica\Module\BaseAdmin;
class Index extends BaseAdmin
{
public static function content(array $parameters = [])
public static function content()
{
parent::content($parameters);
parent::content();
// reload active themes
if (!empty($_GET['action'])) {

View file

@ -32,7 +32,7 @@ use Friendica\Util\Network;
class Contact extends BaseAdmin
{
public static function post(array $parameters = [])
public static function post()
{
self::checkAdminAccess();
@ -76,9 +76,9 @@ class Contact extends BaseAdmin
DI::baseUrl()->redirect('admin/blocklist/contact');
}
public static function content(array $parameters = [])
public static function content()
{
parent::content($parameters);
parent::content();
$condition = ['uid' => 0, 'blocked' => true];

View file

@ -32,7 +32,7 @@ use GuzzleHttp\Psr7\Uri;
class Add extends BaseAdmin
{
public static function post(array $parameters = [])
public static function post()
{
self::checkAdminAccess();
@ -66,9 +66,9 @@ class Add extends BaseAdmin
DI::baseUrl()->redirect('admin/blocklist/server');
}
public static function content(array $parameters = [])
public static function content()
{
parent::content($parameters);
parent::content();
$gservers = [];

View file

@ -27,7 +27,7 @@ use Friendica\Module\BaseAdmin;
class Index extends BaseAdmin
{
public static function post(array $parameters = [])
public static function post()
{
self::checkAdminAccess();
@ -56,9 +56,9 @@ class Index extends BaseAdmin
DI::baseUrl()->redirect('admin/blocklist/server');
}
public static function content(array $parameters = [])
public static function content()
{
parent::content($parameters);
parent::content();
$blocklist = DI::config()->get('system', 'blocklist');
$blocklistform = [];

View file

@ -30,14 +30,14 @@ use Friendica\Module\BaseAdmin;
class DBSync extends BaseAdmin
{
public static function content(array $parameters = [])
public static function content()
{
parent::content($parameters);
parent::content();
$a = DI::app();
$action = $parameters['action'] ?? '';
$update = $parameters['update'] ?? 0;
$action = static::$parameters['action'] ?? '';
$update = static::$parameters['update'] ?? 0;
switch ($action) {
case 'mark':

View file

@ -28,7 +28,7 @@ use Friendica\Module\BaseAdmin;
class Features extends BaseAdmin
{
public static function post(array $parameters = [])
public static function post()
{
self::checkAdminAccess();
@ -60,9 +60,9 @@ class Features extends BaseAdmin
DI::baseUrl()->redirect('admin/features');
}
public static function content(array $parameters = [])
public static function content()
{
parent::content($parameters);
parent::content();
$features = [];

View file

@ -28,9 +28,9 @@ use Friendica\Module\BaseAdmin;
class Federation extends BaseAdmin
{
public static function content(array $parameters = [])
public static function content()
{
parent::content($parameters);
parent::content();
// get counts on active federation systems this node is knowing
// We list the more common systems by name. The rest is counted as "other"

View file

@ -29,7 +29,7 @@ use Friendica\Util\Strings;
class Delete extends BaseAdmin
{
public static function post(array $parameters = [])
public static function post()
{
self::checkAdminAccess();
@ -55,9 +55,9 @@ class Delete extends BaseAdmin
DI::baseUrl()->redirect('admin/item/delete');
}
public static function content(array $parameters = [])
public static function content()
{
parent::content($parameters);
parent::content();
$t = Renderer::getMarkupTemplate('admin/item/delete.tpl');

View file

@ -29,11 +29,11 @@ use Friendica\Module\BaseAdmin;
class Source extends BaseAdmin
{
public static function content(array $parameters = [])
public static function content()
{
parent::content($parameters);
parent::content();
$guid = basename($_REQUEST['guid'] ?? $parameters['guid'] ?? '');
$guid = basename($_REQUEST['guid'] ?? static::$parameters['guid'] ?? '');
$source = '';
$item_uri = '';

View file

@ -29,7 +29,7 @@ use Psr\Log\LogLevel;
class Settings extends BaseAdmin
{
public static function post(array $parameters = [])
public static function post()
{
self::checkAdminAccess();
@ -56,9 +56,9 @@ class Settings extends BaseAdmin
DI::baseUrl()->redirect('admin/logs');
}
public static function content(array $parameters = [])
public static function content()
{
parent::content($parameters);
parent::content();
$log_choices = [
LogLevel::ERROR => 'Error',

View file

@ -31,9 +31,9 @@ class View extends BaseAdmin
{
const LIMIT = 500;
public static function content(array $parameters = [])
public static function content()
{
parent::content($parameters);
parent::content();
$t = Renderer::getMarkupTemplate('admin/logs/view.tpl');
DI::page()->registerFooterScript(Theme::getPathForFile('js/module/admin/logs/view.js'));
@ -75,7 +75,7 @@ class View extends BaseAdmin
->withLimit(self::LIMIT)
->withFilters($filters)
->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);
}
}

View file

@ -25,7 +25,7 @@ use Friendica\Module\BaseAdmin;
class PhpInfo extends BaseAdmin
{
public static function rawContent(array $parameters = [])
public static function rawContent()
{
self::checkAdminAccess();

View file

@ -38,11 +38,11 @@ use Friendica\Util\DateTimeFormat;
*/
class Queue extends BaseAdmin
{
public static function content(array $parameters = [])
public static function content()
{
parent::content($parameters);
parent::content();
$status = $parameters['status'] ?? '';
$status = static::$parameters['status'] ?? '';
// get jobs from the workerqueue table
if ($status == 'deferred') {

View file

@ -43,7 +43,7 @@ require_once __DIR__ . '/../../../boot.php';
class Site extends BaseAdmin
{
public static function post(array $parameters = [])
public static function post()
{
self::checkAdminAccess();
@ -384,9 +384,9 @@ class Site extends BaseAdmin
DI::baseUrl()->redirect('admin/site' . $active_panel);
}
public static function content(array $parameters = [])
public static function content()
{
parent::content($parameters);
parent::content();
/* Installed langs */
$lang_choices = DI::l10n()->getAvailableLanguages();

View file

@ -31,13 +31,13 @@ use Friendica\Util\Strings;
class Storage extends BaseAdmin
{
public static function post(array $parameters = [])
public static function post()
{
self::checkAdminAccess();
self::checkFormSecurityTokenRedirectOnError('/admin/storage', 'admin_storage');
$storagebackend = trim($parameters['name'] ?? '');
$storagebackend = trim(static::$parameters['name'] ?? '');
try {
/** @var ICanConfigureStorage|false $newStorageConfig */
@ -91,9 +91,9 @@ class Storage extends BaseAdmin
DI::baseUrl()->redirect('admin/storage');
}
public static function content(array $parameters = [])
public static function content()
{
parent::content($parameters);
parent::content();
$current_storage_backend = DI::storage();
$available_storage_forms = [];

View file

@ -37,9 +37,9 @@ use Friendica\Util\DateTimeFormat;
class Summary extends BaseAdmin
{
public static function content(array $parameters = [])
public static function content()
{
parent::content($parameters);
parent::content();
$a = DI::app();

View file

@ -30,11 +30,11 @@ use Friendica\Util\Strings;
class Details extends BaseAdmin
{
public static function content(array $parameters = [])
public static function content()
{
parent::content($parameters);
parent::content();
$theme = Strings::sanitizeFilePathItem($parameters['theme']);
$theme = Strings::sanitizeFilePathItem(static::$parameters['theme']);
if (!is_dir("view/theme/$theme")) {
notice(DI::l10n()->t("Item not found."));
return '';

View file

@ -28,19 +28,19 @@ use Friendica\Util\Strings;
class Embed extends BaseAdmin
{
public static function init(array $parameters = [])
public static function init()
{
$theme = Strings::sanitizeFilePathItem($parameters['theme']);
$theme = Strings::sanitizeFilePathItem(static::$parameters['theme']);
if (is_file("view/theme/$theme/config.php")) {
DI::app()->setCurrentTheme($theme);
}
}
public static function post(array $parameters = [])
public static function post()
{
self::checkAdminAccess();
$theme = Strings::sanitizeFilePathItem($parameters['theme']);
$theme = Strings::sanitizeFilePathItem(static::$parameters['theme']);
if (is_file("view/theme/$theme/config.php")) {
require_once "view/theme/$theme/config.php";
if (function_exists('theme_admin_post')) {
@ -56,11 +56,11 @@ class Embed extends BaseAdmin
DI::baseUrl()->redirect('admin/themes/' . $theme . '/embed?mode=minimal');
}
public static function content(array $parameters = [])
public static function content()
{
parent::content($parameters);
parent::content();
$theme = Strings::sanitizeFilePathItem($parameters['theme']);
$theme = Strings::sanitizeFilePathItem(static::$parameters['theme']);
if (!is_dir("view/theme/$theme")) {
notice(DI::l10n()->t('Unknown theme.'));
return '';

View file

@ -29,9 +29,9 @@ use Friendica\Util\Strings;
class Index extends BaseAdmin
{
public static function content(array $parameters = [])
public static function content()
{
parent::content($parameters);
parent::content();
$allowed_themes = Theme::getAllowedList();

View file

@ -27,7 +27,7 @@ use Friendica\Module\BaseAdmin;
class Tos extends BaseAdmin
{
public static function post(array $parameters = [])
public static function post()
{
self::checkAdminAccess();
@ -48,11 +48,11 @@ class Tos extends BaseAdmin
DI::baseUrl()->redirect('admin/tos');
}
public static function content(array $parameters = [])
public static function content()
{
parent::content($parameters);
parent::content();
$tos = new \Friendica\Module\Tos();
$tos = new \Friendica\Module\Tos(static::$parameters);
$t = Renderer::getMarkupTemplate('admin/tos.tpl');
return Renderer::replaceMacros($t, [
'$title' => DI::l10n()->t('Administration'),

View file

@ -30,7 +30,7 @@ use Friendica\Module\Admin\BaseUsers;
class Active extends BaseUsers
{
public static function post(array $parameters = [])
public static function post()
{
self::checkAdminAccess();
@ -60,12 +60,12 @@ class Active extends BaseUsers
DI::baseUrl()->redirect(DI::args()->getQueryString());
}
public static function content(array $parameters = [])
public static function content()
{
parent::content($parameters);
parent::content();
$action = $parameters['action'] ?? '';
$uid = $parameters['uid'] ?? 0;
$action = static::$parameters['action'] ?? '';
$uid = static::$parameters['uid'] ?? 0;
if ($uid) {
$user = User::getById($uid, ['username', 'blocked']);

View file

@ -31,7 +31,7 @@ use Friendica\Util\Temporal;
class Blocked extends BaseUsers
{
public static function post(array $parameters = [])
public static function post()
{
self::checkAdminAccess();
@ -61,12 +61,12 @@ class Blocked extends BaseUsers
DI::baseUrl()->redirect('admin/users/blocked');
}
public static function content(array $parameters = [])
public static function content()
{
parent::content($parameters);
parent::content();
$action = $parameters['action'] ?? '';
$uid = $parameters['uid'] ?? 0;
$action = static::$parameters['action'] ?? '';
$uid = static::$parameters['uid'] ?? 0;
if ($uid) {
$user = User::getById($uid, ['username', 'blocked']);

View file

@ -28,7 +28,7 @@ use Friendica\Module\Admin\BaseUsers;
class Create extends BaseUsers
{
public static function post(array $parameters = [])
public static function post()
{
self::checkAdminAccess();
@ -51,9 +51,9 @@ class Create extends BaseUsers
DI::baseUrl()->redirect('admin/users/create');
}
public static function content(array $parameters = [])
public static function content()
{
parent::content($parameters);
parent::content();
$t = Renderer::getMarkupTemplate('admin/users/create.tpl');
return self::getTabsHTML('all') . Renderer::replaceMacros($t, [

View file

@ -33,7 +33,7 @@ use Friendica\Util\Temporal;
class Deleted extends BaseUsers
{
public static function post(array $parameters = [])
public static function post()
{
self::checkAdminAccess();
@ -44,9 +44,9 @@ class Deleted extends BaseUsers
DI::baseUrl()->redirect('admin/users/deleted');
}
public static function content(array $parameters = [])
public static function content()
{
parent::content($parameters);
parent::content();
$pager = new Pager(DI::l10n(), DI::args()->getQueryString(), 100);

View file

@ -30,7 +30,7 @@ use Friendica\Module\Admin\BaseUsers;
class Index extends BaseUsers
{
public static function post(array $parameters = [])
public static function post()
{
self::checkAdminAccess();
@ -67,12 +67,12 @@ class Index extends BaseUsers
DI::baseUrl()->redirect(DI::args()->getQueryString());
}
public static function content(array $parameters = [])
public static function content()
{
parent::content($parameters);
parent::content();
$action = $parameters['action'] ?? '';
$uid = $parameters['uid'] ?? 0;
$action = static::$parameters['action'] ?? '';
$uid = static::$parameters['uid'] ?? 0;
if ($uid) {
$user = User::getById($uid, ['username', 'blocked']);

View file

@ -33,7 +33,7 @@ use Friendica\Util\Temporal;
class Pending extends BaseUsers
{
public static function post(array $parameters = [])
public static function post()
{
self::checkAdminAccess();
@ -58,12 +58,12 @@ class Pending extends BaseUsers
DI::baseUrl()->redirect('admin/users/pending');
}
public static function content(array $parameters = [])
public static function content()
{
parent::content($parameters);
parent::content();
$action = $parameters['action'] ?? '';
$uid = $parameters['uid'] ?? 0;
$action = static::$parameters['action'] ?? '';
$uid = static::$parameters['uid'] ?? 0;
if ($uid) {
$user = User::getById($uid, ['username', 'blocked']);

View file

@ -40,7 +40,7 @@ use Friendica\Module\BaseApi;
*/
class Activity extends BaseApi
{
public static function rawContent(array $parameters = [])
public static function rawContent()
{
self::checkAllowedScope(self::SCOPE_WRITE);
$uid = self::getCurrentUserID();
@ -49,17 +49,17 @@ class Activity extends BaseApi
'id' => 0, // Id of the post
]);
$res = Item::performActivity($request['id'], $parameters['verb'], $uid);
$res = Item::performActivity($request['id'], static::$parameters['verb'], $uid);
if ($res) {
if (!empty($parameters['extension']) && ($parameters['extension'] == 'xml')) {
if (!empty(static::$parameters['extension']) && (static::$parameters['extension'] == 'xml')) {
$ok = 'true';
} else {
$ok = 'ok';
}
DI::apiResponse()->exit('ok', ['ok' => $ok], $parameters['extension'] ?? null);
DI::apiResponse()->exit('ok', ['ok' => $ok], static::$parameters['extension'] ?? null);
} else {
DI::apiResponse()->error(500, 'Error adding activity', '', $parameters['extension'] ?? null);
DI::apiResponse()->error(500, 'Error adding activity', '', static::$parameters['extension'] ?? null);
}
}
}

View file

@ -30,7 +30,7 @@ use Friendica\Module\BaseApi;
*/
class Setseen extends BaseApi
{
public static function rawContent(array $parameters = [])
public static function rawContent()
{
self::checkAllowedScope(self::SCOPE_WRITE);
$uid = self::getCurrentUserID();
@ -42,13 +42,13 @@ class Setseen extends BaseApi
// return error if id is zero
if (empty($request['id'])) {
$answer = ['result' => 'error', 'message' => 'message id not specified'];
DI::apiResponse()->exit('direct_messages_setseen', ['$result' => $answer], $parameters['extension'] ?? null);
DI::apiResponse()->exit('direct_messages_setseen', ['$result' => $answer], static::$parameters['extension'] ?? null);
}
// error message if specified id is not in database
if (!DBA::exists('mail', ['id' => $request['id'], 'uid' => $uid])) {
$answer = ['result' => 'error', 'message' => 'message id not in database'];
DI::apiResponse()->exit('direct_messages_setseen', ['$result' => $answer], $parameters['extension'] ?? null);
DI::apiResponse()->exit('direct_messages_setseen', ['$result' => $answer], static::$parameters['extension'] ?? null);
}
// update seen indicator
@ -58,6 +58,6 @@ class Setseen extends BaseApi
$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], static::$parameters['extension'] ?? null);
}
}

View file

@ -33,7 +33,7 @@ use Friendica\Module\BaseApi;
*/
class Index extends BaseApi
{
public static function rawContent(array $parameters = [])
public static function rawContent()
{
self::checkAllowedScope(self::SCOPE_READ);
$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], static::$parameters['extension'] ?? null);
}
}

View file

@ -31,17 +31,17 @@ use Friendica\Module\BaseApi;
*/
class Index extends BaseApi
{
public static function post(array $parameters = [])
public static function post()
{
self::checkAllowedScope(self::SCOPE_WRITE);
}
public static function delete(array $parameters = [])
public static function delete()
{
self::checkAllowedScope(self::SCOPE_WRITE);
}
public static function rawContent(array $parameters = [])
public static function rawContent()
{
echo api_call(DI::app());
exit();

View file

@ -31,7 +31,7 @@ use Friendica\Object\Api\Friendica\Notification as ApiNotification;
*/
class Notification extends BaseApi
{
public static function rawContent(array $parameters = [])
public static function rawContent()
{
self::checkAllowedScope(self::SCOPE_READ);
$uid = self::getCurrentUserID();
@ -43,7 +43,7 @@ class Notification extends BaseApi
$notifications[] = new ApiNotification($Notify);
}
if (!empty($parameters['extension']) && ($parameters['extension'] == 'xml')) {
if (!empty(static::$parameters['extension']) && (static::$parameters['extension'] == 'xml')) {
$xmlnotes = [];
foreach ($notifications as $notification) {
$xmlnotes[] = ['@attributes' => $notification->toArray()];
@ -56,6 +56,6 @@ class Notification extends BaseApi
$result = false;
}
DI::apiResponse()->exit('notes', ['note' => $result], $parameters['extension'] ?? null);
DI::apiResponse()->exit('notes', ['note' => $result], static::$parameters['extension'] ?? null);
}
}

View file

@ -33,7 +33,7 @@ use Friendica\Network\HTTPException\InternalServerErrorException;
*/
class Delete extends BaseApi
{
public static function rawContent(array $parameters = [])
public static function rawContent()
{
self::checkAllowedScope(self::SCOPE_WRITE);
$uid = self::getCurrentUserID();
@ -64,7 +64,7 @@ class Delete extends BaseApi
Item::deleteForUser($condition, $uid);
$result = ['result' => 'deleted', 'message' => 'photo with id `' . $request['photo_id'] . '` has been deleted from server.'];
DI::apiResponse()->exit('photo_delete', ['$result' => $result], $parameters['extension'] ?? null);
DI::apiResponse()->exit('photo_delete', ['$result' => $result], static::$parameters['extension'] ?? null);
} else {
throw new InternalServerErrorException("unknown error on deleting photo from database table");
}

View file

@ -34,7 +34,7 @@ use Friendica\Network\HTTPException\InternalServerErrorException;
*/
class Delete extends BaseApi
{
public static function rawContent(array $parameters = [])
public static function rawContent()
{
self::checkAllowedScope(self::SCOPE_WRITE);
$uid = self::getCurrentUserID();
@ -67,7 +67,7 @@ class Delete extends BaseApi
// return success of deletion or error message
if ($result) {
$answer = ['result' => 'deleted', 'message' => 'album `' . $request['album'] . '` with all containing photos has been deleted.'];
DI::apiResponse()->exit('photoalbum_delete', ['$result' => $answer], $parameters['extension'] ?? null);
DI::apiResponse()->exit('photoalbum_delete', ['$result' => $answer], static::$parameters['extension'] ?? null);
} else {
throw new InternalServerErrorException("unknown error - deleting from database failed");
}

View file

@ -32,7 +32,7 @@ use Friendica\Network\HTTPException\InternalServerErrorException;
*/
class Update extends BaseApi
{
public static function rawContent(array $parameters = [])
public static function rawContent()
{
self::checkAllowedScope(self::SCOPE_WRITE);
$uid = self::getCurrentUserID();
@ -59,7 +59,7 @@ class Update extends BaseApi
// return success of updating or error message
if ($result) {
$answer = ['result' => 'updated', 'message' => 'album `' . $request['album'] . '` with all containing photos has been renamed to `' . $request['album_new'] . '`.'];
DI::apiResponse()->exit('photoalbum_update', ['$result' => $answer], $parameters['extension'] ?? null);
DI::apiResponse()->exit('photoalbum_update', ['$result' => $answer], static::$parameters['extension'] ?? null);
} else {
throw new InternalServerErrorException("unknown error - updating in database failed");
}

View file

@ -34,7 +34,7 @@ use Friendica\Network\HTTPException;
*/
class Show extends BaseApi
{
public static function rawContent(array $parameters = [])
public static function rawContent()
{
self::checkAllowedScope(self::SCOPE_READ);
$uid = self::getCurrentUserID();
@ -49,7 +49,7 @@ class Show extends BaseApi
$profile = self::formatProfile($profile, $profileFields);
$profiles = [];
if (!empty($parameters['extension']) && ($parameters['extension'] == 'xml')) {
if (!empty(static::$parameters['extension']) && (static::$parameters['extension'] == 'xml')) {
$profiles['0:profile'] = $profile;
} else {
$profiles[] = $profile;
@ -65,7 +65,7 @@ class Show extends BaseApi
'profiles' => $profiles
];
DI::apiResponse()->exit('friendica_profiles', ['$result' => $result], $parameters['extension'] ?? null);
DI::apiResponse()->exit('friendica_profiles', ['$result' => $result], static::$parameters['extension'] ?? null);
}
/**

View file

@ -29,8 +29,8 @@ use Friendica\DI;
*/
class Version extends BaseApi
{
public static function rawContent(array $parameters = [])
public static function rawContent()
{
DI::apiResponse()->exit('version', ['version' => '0.9.7'], $parameters['extension'] ?? null);
DI::apiResponse()->exit('version', ['version' => '0.9.7'], static::$parameters['extension'] ?? null);
}
}

View file

@ -29,14 +29,14 @@ use Friendica\DI;
*/
class Test extends BaseApi
{
public static function rawContent(array $parameters = [])
public static function rawContent()
{
if (!empty($parameters['extension']) && ($parameters['extension'] == 'xml')) {
if (!empty(static::$parameters['extension']) && (static::$parameters['extension'] == 'xml')) {
$ok = 'true';
} else {
$ok = 'ok';
}
DI::apiResponse()->exit('ok', ['ok' => $ok], $parameters['extension'] ?? null);
DI::apiResponse()->exit('ok', ['ok' => $ok], static::$parameters['extension'] ?? null);
}
}

View file

@ -33,27 +33,26 @@ use Friendica\Module\BaseApi;
class Accounts extends BaseApi
{
/**
* @param array $parameters
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function rawContent(array $parameters = [])
public static function rawContent()
{
$uid = self::getCurrentUserID();
if (empty($parameters['id']) && empty($parameters['name'])) {
if (empty(static::$parameters['id']) && empty(static::$parameters['name'])) {
DI::mstdnError()->UnprocessableEntity();
}
if (!empty($parameters['id'])) {
$id = $parameters['id'];
if (!empty(static::$parameters['id'])) {
$id = static::$parameters['id'];
if (!DBA::exists('contact', ['id' => $id, 'uid' => 0])) {
DI::mstdnError()->RecordNotFound();
}
} else {
$contact = Contact::selectFirst(['id'], ['nick' => $parameters['name'], 'uid' => 0]);
$contact = Contact::selectFirst(['id'], ['nick' => static::$parameters['name'], 'uid' => 0]);
if (!empty($contact['id'])) {
$id = $contact['id'];
} elseif (!($id = Contact::getIdForURL($parameters['name'], 0, false))) {
} elseif (!($id = Contact::getIdForURL(static::$parameters['name'], 0, false))) {
DI::mstdnError()->RecordNotFound();
}
}

View file

@ -32,12 +32,12 @@ use Friendica\Module\BaseApi;
*/
class Block extends BaseApi
{
public static function post(array $parameters = [])
public static function post()
{
self::checkAllowedScope(self::SCOPE_FOLLOW);
$uid = self::getCurrentUserID();
if (empty($parameters['id'])) {
if (empty(static::$parameters['id'])) {
DI::mstdnError()->UnprocessableEntity();
}
@ -46,7 +46,7 @@ class Block extends BaseApi
DI::mstdnError()->Forbidden();
}
$cdata = Contact::getPublicAndUserContactID($parameters['id'], $uid);
$cdata = Contact::getPublicAndUserContactID(static::$parameters['id'], $uid);
if (empty($cdata['user'])) {
DI::mstdnError()->RecordNotFound();
}
@ -62,6 +62,6 @@ class Block extends BaseApi
Contact::terminateFriendship($owner, $contact);
Contact::revokeFollow($contact);
System::jsonExit(DI::mstdnRelationship()->createFromContactId($parameters['id'], $uid)->toArray());
System::jsonExit(DI::mstdnRelationship()->createFromContactId(static::$parameters['id'], $uid)->toArray());
}
}

View file

@ -30,10 +30,9 @@ use Friendica\Module\BaseApi;
class FeaturedTags extends BaseApi
{
/**
* @param array $parameters
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function rawContent(array $parameters = [])
public static function rawContent()
{
self::checkAllowedScope(self::SCOPE_READ);

View file

@ -31,16 +31,16 @@ use Friendica\Module\BaseApi;
*/
class Follow extends BaseApi
{
public static function post(array $parameters = [])
public static function post()
{
self::checkAllowedScope(self::SCOPE_FOLLOW);
$uid = self::getCurrentUserID();
if (empty($parameters['id'])) {
if (empty(static::$parameters['id'])) {
DI::mstdnError()->UnprocessableEntity();
}
$cid = Contact::follow($parameters['id'], $uid);
$cid = Contact::follow(static::$parameters['id'], $uid);
System::jsonExit(DI::mstdnRelationship()->createFromContactId($cid, $uid)->toArray());
}

View file

@ -32,19 +32,18 @@ use Friendica\Module\BaseApi;
class Followers extends BaseApi
{
/**
* @param array $parameters
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function rawContent(array $parameters = [])
public static function rawContent()
{
self::checkAllowedScope(self::SCOPE_READ);
$uid = self::getCurrentUserID();
if (empty($parameters['id'])) {
if (empty(static::$parameters['id'])) {
DI::mstdnError()->UnprocessableEntity();
}
$id = $parameters['id'];
$id = static::$parameters['id'];
if (!DBA::exists('contact', ['id' => $id, 'uid' => 0])) {
DI::mstdnError()->RecordNotFound();
}
@ -73,7 +72,7 @@ class Followers extends BaseApi
$params['order'] = ['cid'];
}
$followers = DBA::select('contact-relation', ['relation-cid'], $condition, $parameters);
$followers = DBA::select('contact-relation', ['relation-cid'], $condition, static::$parameters);
while ($follower = DBA::fetch($followers)) {
self::setBoundaries($follower['relation-cid']);
$accounts[] = DI::mstdnAccount()->createFromContactId($follower['relation-cid'], $uid);

View file

@ -32,19 +32,18 @@ use Friendica\Module\BaseApi;
class Following extends BaseApi
{
/**
* @param array $parameters
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function rawContent(array $parameters = [])
public static function rawContent()
{
self::checkAllowedScope(self::SCOPE_READ);
$uid = self::getCurrentUserID();
if (empty($parameters['id'])) {
if (empty(static::$parameters['id'])) {
DI::mstdnError()->UnprocessableEntity();
}
$id = $parameters['id'];
$id = static::$parameters['id'];
if (!DBA::exists('contact', ['id' => $id, 'uid' => 0])) {
DI::mstdnError()->RecordNotFound();
}
@ -73,7 +72,7 @@ class Following extends BaseApi
$params['order'] = ['cid'];
}
$followers = DBA::select('contact-relation', ['cid'], $condition, $parameters);
$followers = DBA::select('contact-relation', ['cid'], $condition, static::$parameters);
while ($follower = DBA::fetch($followers)) {
self::setBoundaries($follower['cid']);
$accounts[] = DI::mstdnAccount()->createFromContactId($follower['cid'], $uid);

View file

@ -30,10 +30,9 @@ use Friendica\Module\BaseApi;
class IdentityProofs extends BaseApi
{
/**
* @param array $parameters
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function rawContent(array $parameters = [])
public static function rawContent()
{
self::checkAllowedScope(self::SCOPE_READ);

View file

@ -33,19 +33,18 @@ use Friendica\Module\BaseApi;
class Lists extends BaseApi
{
/**
* @param array $parameters
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function rawContent(array $parameters = [])
public static function rawContent()
{
self::checkAllowedScope(self::SCOPE_READ);
$uid = self::getCurrentUserID();
if (empty($parameters['id'])) {
if (empty(static::$parameters['id'])) {
DI::mstdnError()->UnprocessableEntity();
}
$id = $parameters['id'];
$id = static::$parameters['id'];
if (!DBA::exists('contact', ['id' => $id, 'uid' => 0])) {
DI::mstdnError()->RecordNotFound();
}

View file

@ -31,17 +31,17 @@ use Friendica\Module\BaseApi;
*/
class Mute extends BaseApi
{
public static function post(array $parameters = [])
public static function post()
{
self::checkAllowedScope(self::SCOPE_FOLLOW);
$uid = self::getCurrentUserID();
if (empty($parameters['id'])) {
if (empty(static::$parameters['id'])) {
DI::mstdnError()->UnprocessableEntity();
}
Contact\User::setIgnored($parameters['id'], $uid, true);
Contact\User::setIgnored(static::$parameters['id'], $uid, true);
System::jsonExit(DI::mstdnRelationship()->createFromContactId($parameters['id'], $uid)->toArray());
System::jsonExit(DI::mstdnRelationship()->createFromContactId(static::$parameters['id'], $uid)->toArray());
}
}

View file

@ -32,12 +32,12 @@ use Friendica\Module\BaseApi;
*/
class Note extends BaseApi
{
public static function post(array $parameters = [])
public static function post()
{
self::checkAllowedScope(self::SCOPE_WRITE);
$uid = self::getCurrentUserID();
if (empty($parameters['id'])) {
if (empty(static::$parameters['id'])) {
DI::mstdnError()->UnprocessableEntity();
}
@ -45,13 +45,13 @@ class Note extends BaseApi
'comment' => '',
]);
$cdata = Contact::getPublicAndUserContactID($parameters['id'], $uid);
$cdata = Contact::getPublicAndUserContactID(static::$parameters['id'], $uid);
if (empty($cdata['user'])) {
DI::mstdnError()->RecordNotFound();
}
Contact::update(['info' => $request['comment']], ['id' => $cdata['user']]);
System::jsonExit(DI::mstdnRelationship()->createFromContactId($parameters['id'], $uid)->toArray());
System::jsonExit(DI::mstdnRelationship()->createFromContactId(static::$parameters['id'], $uid)->toArray());
}
}

View file

@ -32,10 +32,9 @@ use Friendica\Module\BaseApi;
class Relationships extends BaseApi
{
/**
* @param array $parameters
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function rawContent(array $parameters = [])
public static function rawContent()
{
self::checkAllowedScope(self::SCOPE_READ);
$uid = self::getCurrentUserID();

View file

@ -35,10 +35,9 @@ use Friendica\Object\Search\ContactResult;
class Search extends BaseApi
{
/**
* @param array $parameters
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function rawContent(array $parameters = [])
public static function rawContent()
{
self::checkAllowedScope(self::SCOPE_READ);
$uid = self::getCurrentUserID();

View file

@ -37,18 +37,17 @@ use Friendica\Protocol\Activity;
class Statuses extends BaseApi
{
/**
* @param array $parameters
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function rawContent(array $parameters = [])
public static function rawContent()
{
$uid = self::getCurrentUserID();
if (empty($parameters['id'])) {
if (empty(static::$parameters['id'])) {
DI::mstdnError()->UnprocessableEntity();
}
$id = $parameters['id'];
$id = static::$parameters['id'];
if (!DBA::exists('contact', ['id' => $id, 'uid' => 0])) {
DI::mstdnError()->RecordNotFound();
}

View file

@ -31,17 +31,17 @@ use Friendica\Module\BaseApi;
*/
class Unblock extends BaseApi
{
public static function post(array $parameters = [])
public static function post()
{
self::checkAllowedScope(self::SCOPE_FOLLOW);
$uid = self::getCurrentUserID();
if (empty($parameters['id'])) {
if (empty(static::$parameters['id'])) {
DI::mstdnError()->UnprocessableEntity();
}
Contact\User::setBlocked($parameters['id'], $uid, false);
Contact\User::setBlocked(static::$parameters['id'], $uid, false);
System::jsonExit(DI::mstdnRelationship()->createFromContactId($parameters['id'], $uid)->toArray());
System::jsonExit(DI::mstdnRelationship()->createFromContactId(static::$parameters['id'], $uid)->toArray());
}
}

View file

@ -31,17 +31,17 @@ use Friendica\Module\BaseApi;
*/
class Unfollow extends BaseApi
{
public static function post(array $parameters = [])
public static function post()
{
self::checkAllowedScope(self::SCOPE_FOLLOW);
$uid = self::getCurrentUserID();
if (empty($parameters['id'])) {
if (empty(static::$parameters['id'])) {
DI::mstdnError()->UnprocessableEntity();
}
Contact::unfollow($parameters['id'], $uid);
Contact::unfollow(static::$parameters['id'], $uid);
System::jsonExit(DI::mstdnRelationship()->createFromContactId($parameters['id'], $uid)->toArray());
System::jsonExit(DI::mstdnRelationship()->createFromContactId(static::$parameters['id'], $uid)->toArray());
}
}

View file

@ -31,17 +31,17 @@ use Friendica\Module\BaseApi;
*/
class Unmute extends BaseApi
{
public static function post(array $parameters = [])
public static function post()
{
self::checkAllowedScope(self::SCOPE_FOLLOW);
$uid = self::getCurrentUserID();
if (empty($parameters['id'])) {
if (empty(static::$parameters['id'])) {
DI::mstdnError()->UnprocessableEntity();
}
Contact\User::setIgnored($parameters['id'], $uid, false);
Contact\User::setIgnored(static::$parameters['id'], $uid, false);
System::jsonExit(DI::mstdnRelationship()->createFromContactId($parameters['id'], $uid)->toArray());
System::jsonExit(DI::mstdnRelationship()->createFromContactId(static::$parameters['id'], $uid)->toArray());
}
}

View file

@ -32,7 +32,7 @@ use Friendica\Util\HTTPInputData;
*/
class UpdateCredentials extends BaseApi
{
public static function patch(array $parameters = [])
public static function patch()
{
self::checkAllowedScope(self::SCOPE_WRITE);
$uid = self::getCurrentUserID();

View file

@ -33,10 +33,9 @@ use Friendica\Module\BaseApi;
class VerifyCredentials extends BaseApi
{
/**
* @param array $parameters
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function rawContent(array $parameters = [])
public static function rawContent()
{
self::checkAllowedScope(self::SCOPE_READ);
$uid = self::getCurrentUserID();

View file

@ -30,10 +30,9 @@ use Friendica\Module\BaseApi;
class Announcements extends BaseApi
{
/**
* @param array $parameters
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function rawContent(array $parameters = [])
public static function rawContent()
{
self::checkAllowedScope(self::SCOPE_READ);

View file

@ -33,10 +33,9 @@ use Friendica\Util\Network;
class Apps extends BaseApi
{
/**
* @param array $parameters
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function post(array $parameters = [])
public static function post()
{
$request = self::getRequest([
'client_name' => '',

View file

@ -30,7 +30,7 @@ use Friendica\Module\BaseApi;
*/
class VerifyCredentials extends BaseApi
{
public static function rawContent(array $parameters = [])
public static function rawContent()
{
self::checkAllowedScope(self::SCOPE_READ);
$application = self::getCurrentApplication();

View file

@ -32,19 +32,18 @@ use Friendica\Module\BaseApi;
class Blocks extends BaseApi
{
/**
* @param array $parameters
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function rawContent(array $parameters = [])
public static function rawContent()
{
self::checkAllowedScope(self::SCOPE_READ);
$uid = self::getCurrentUserID();
if (empty($parameters['id'])) {
if (empty(static::$parameters['id'])) {
DI::mstdnError()->UnprocessableEntity();
}
$id = $parameters['id'];
$id = static::$parameters['id'];
if (!DBA::exists('contact', ['id' => $id, 'uid' => 0])) {
DI::mstdnError()->RecordNotFound();
}
@ -73,7 +72,7 @@ class Blocks extends BaseApi
$params['order'] = ['cid'];
}
$followers = DBA::select('user-contact', ['cid'], $condition, $parameters);
$followers = DBA::select('user-contact', ['cid'], $condition, static::$parameters);
while ($follower = DBA::fetch($followers)) {
self::setBoundaries($follower['cid']);
$accounts[] = DI::mstdnAccount()->createFromContactId($follower['cid'], $uid);

View file

@ -34,10 +34,9 @@ use Friendica\Network\HTTPException;
class Bookmarks extends BaseApi
{
/**
* @param array $parameters
* @throws HTTPException\InternalServerErrorException
*/
public static function rawContent(array $parameters = [])
public static function rawContent()
{
self::checkAllowedScope(self::SCOPE_READ);
$uid = self::getCurrentUserID();

View file

@ -31,26 +31,25 @@ use Friendica\Module\BaseApi;
*/
class Conversations extends BaseApi
{
public static function delete(array $parameters = [])
public static function delete()
{
self::checkAllowedScope(self::SCOPE_WRITE);
$uid = self::getCurrentUserID();
if (!empty($parameters['id'])) {
if (!empty(static::$parameters['id'])) {
DI::mstdnError()->UnprocessableEntity();
}
DBA::delete('conv', ['id' => $parameters['id'], 'uid' => $uid]);
DBA::delete('mail', ['convid' => $parameters['id'], 'uid' => $uid]);
DBA::delete('conv', ['id' => static::$parameters['id'], 'uid' => $uid]);
DBA::delete('mail', ['convid' => static::$parameters['id'], 'uid' => $uid]);
System::jsonExit([]);
}
/**
* @param array $parameters
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function rawContent(array $parameters = [])
public static function rawContent()
{
self::checkAllowedScope(self::SCOPE_READ);
$uid = self::getCurrentUserID();

View file

@ -31,17 +31,17 @@ use Friendica\Module\BaseApi;
*/
class Read extends BaseApi
{
public static function post(array $parameters = [])
public static function post()
{
self::checkAllowedScope(self::SCOPE_WRITE);
$uid = self::getCurrentUserID();
if (!empty($parameters['id'])) {
if (!empty(static::$parameters['id'])) {
DI::mstdnError()->UnprocessableEntity();
}
DBA::update('mail', ['seen' => true], ['convid' => $parameters['id'], 'uid' => $uid]);
DBA::update('mail', ['seen' => true], ['convid' => static::$parameters['id'], 'uid' => $uid]);
System::jsonExit(DI::mstdnConversation()->CreateFromConvId($parameters['id'])->toArray());
System::jsonExit(DI::mstdnConversation()->CreateFromConvId(static::$parameters['id'])->toArray());
}
}

View file

@ -33,12 +33,11 @@ use Friendica\Network\HTTPException;
class CustomEmojis extends BaseApi
{
/**
* @param array $parameters
* @throws HTTPException\InternalServerErrorException
* @throws \ImagickException
* @see https://docs.joinmastodon.org/methods/accounts/follow_requests#pending-follows
*/
public static function rawContent(array $parameters = [])
public static function rawContent()
{
$emojis = DI::mstdnEmoji()->createCollectionFromSmilies(Smilies::getList());

View file

@ -35,12 +35,11 @@ use Friendica\Network\HTTPException;
class Directory extends BaseApi
{
/**
* @param array $parameters
* @throws HTTPException\InternalServerErrorException
* @throws \ImagickException
* @see https://docs.joinmastodon.org/methods/instance/directory/
*/
public static function rawContent(array $parameters = [])
public static function rawContent()
{
$request = self::getRequest([
'offset' => 0, // How many accounts to skip before returning results. Default 0.

View file

@ -30,10 +30,9 @@ use Friendica\Module\BaseApi;
class Endorsements extends BaseApi
{
/**
* @param array $parameters
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function rawContent(array $parameters = [])
public static function rawContent()
{
System::jsonExit([]);
}

View file

@ -35,10 +35,9 @@ use Friendica\Protocol\Activity;
class Favourited extends BaseApi
{
/**
* @param array $parameters
* @throws HTTPException\InternalServerErrorException
*/
public static function rawContent(array $parameters = [])
public static function rawContent()
{
self::checkAllowedScope(self::SCOPE_READ);
$uid = self::getCurrentUserID();

View file

@ -31,7 +31,7 @@ use Friendica\Module\BaseApi;
*/
class Filters extends BaseApi
{
public static function post(array $parameters = [])
public static function post()
{
self::checkAllowedScope(self::SCOPE_WRITE);
@ -39,10 +39,9 @@ class Filters extends BaseApi
}
/**
* @param array $parameters
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function rawContent(array $parameters = [])
public static function rawContent()
{
self::checkAllowedScope(self::SCOPE_READ);

View file

@ -33,7 +33,6 @@ use Friendica\Network\HTTPException;
class FollowRequests extends BaseApi
{
/**
* @param array $parameters
* @throws HTTPException\BadRequestException
* @throws HTTPException\InternalServerErrorException
* @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#reject-follow
*/
public static function post(array $parameters = [])
public static function post()
{
self::checkAllowedScope(self::SCOPE_FOLLOW);
$uid = self::getCurrentUserID();
$introduction = DI::intro()->selectOneById($parameters['id'], $uid);
$introduction = DI::intro()->selectOneById(static::$parameters['id'], $uid);
$contactId = $introduction->cid;
switch ($parameters['action']) {
switch (static::$parameters['action']) {
case 'authorize':
Contact\Introduction::confirm($introduction);
$relationship = DI::mstdnRelationship()->createFromContactId($contactId, $uid);
@ -79,12 +78,11 @@ class FollowRequests extends BaseApi
}
/**
* @param array $parameters
* @throws HTTPException\InternalServerErrorException
* @throws \ImagickException
* @see https://docs.joinmastodon.org/methods/accounts/follow_requests/
*/
public static function rawContent(array $parameters = [])
public static function rawContent()
{
self::checkAllowedScope(self::SCOPE_READ);
$uid = self::getCurrentUserID();

View file

@ -31,10 +31,9 @@ use Friendica\Object\Api\Mastodon\Instance as InstanceEntity;
class Instance extends BaseApi
{
/**
* @param array $parameters
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function rawContent(array $parameters = [])
public static function rawContent()
{
System::jsonExit(InstanceEntity::get());
}

View file

@ -34,10 +34,9 @@ use Friendica\Util\Network;
class Peers extends BaseApi
{
/**
* @param array $parameters
* @throws HTTPException\InternalServerErrorException
*/
public static function rawContent(array $parameters = [])
public static function rawContent()
{
$return = [];

View file

@ -34,10 +34,9 @@ use Friendica\Network\HTTPException;
class Rules extends BaseApi
{
/**
* @param array $parameters
* @throws HTTPException\InternalServerErrorException
*/
public static function rawContent(array $parameters = [])
public static function rawContent()
{
$rules = [];
$id = 0;

View file

@ -31,27 +31,27 @@ use Friendica\Model\Group;
*/
class Lists extends BaseApi
{
public static function delete(array $parameters = [])
public static function delete()
{
self::checkAllowedScope(self::SCOPE_WRITE);
$uid = self::getCurrentUserID();
if (empty($parameters['id'])) {
if (empty(static::$parameters['id'])) {
DI::mstdnError()->UnprocessableEntity();
}
if (!Group::exists($parameters['id'], $uid)) {
if (!Group::exists(static::$parameters['id'], $uid)) {
DI::mstdnError()->RecordNotFound();
}
if (!Group::remove($parameters['id'])) {
if (!Group::remove(static::$parameters['id'])) {
DI::mstdnError()->InternalError();
}
System::jsonExit([]);
}
public static function post(array $parameters = [])
public static function post()
{
self::checkAllowedScope(self::SCOPE_WRITE);
$uid = self::getCurrentUserID();
@ -74,30 +74,29 @@ class Lists extends BaseApi
System::jsonExit(DI::mstdnList()->createFromGroupId($id));
}
public static function put(array $parameters = [])
public static function put()
{
$request = self::getRequest([
'title' => '', // The title of the list to be updated.
'replies_policy' => '', // One of: "followed", "list", or "none".
]);
if (empty($request['title']) || empty($parameters['id'])) {
if (empty($request['title']) || empty(static::$parameters['id'])) {
DI::mstdnError()->UnprocessableEntity();
}
Group::update($parameters['id'], $request['title']);
Group::update(static::$parameters['id'], $request['title']);
}
/**
* @param array $parameters
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function rawContent(array $parameters = [])
public static function rawContent()
{
self::checkAllowedScope(self::SCOPE_READ);
$uid = self::getCurrentUserID();
if (empty($parameters['id'])) {
if (empty(static::$parameters['id'])) {
$lists = [];
$groups = Group::getByUserId($uid);
@ -106,7 +105,7 @@ class Lists extends BaseApi
$lists[] = DI::mstdnList()->createFromGroupId($group['id']);
}
} else {
$id = $parameters['id'];
$id = static::$parameters['id'];
if (!Group::exists($id, $uid)) {
DI::mstdnError()->RecordNotFound();

View file

@ -35,30 +35,29 @@ use Friendica\Module\BaseApi;
*/
class Accounts extends BaseApi
{
public static function delete(array $parameters = [])
public static function delete()
{
DI::apiResponse()->unsupported(Router::DELETE);
}
public static function post(array $parameters = [])
public static function post()
{
DI::apiResponse()->unsupported(Router::POST);
}
/**
* @param array $parameters
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function rawContent(array $parameters = [])
public static function rawContent()
{
self::checkAllowedScope(self::SCOPE_READ);
$uid = self::getCurrentUserID();
if (empty($parameters['id'])) {
if (empty(static::$parameters['id'])) {
DI::mstdnError()->UnprocessableEntity();
}
$id = $parameters['id'];
$id = static::$parameters['id'];
if (!DBA::exists('group', ['id' => $id, 'uid' => $uid])) {
DI::mstdnError()->RecordNotFound();
}

View file

@ -31,7 +31,7 @@ use Friendica\Module\BaseApi;
*/
class Markers extends BaseApi
{
public static function post(array $parameters = [])
public static function post()
{
self::checkAllowedScope(self::SCOPE_WRITE);
@ -39,10 +39,9 @@ class Markers extends BaseApi
}
/**
* @param array $parameters
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function rawContent(array $parameters = [])
public static function rawContent()
{
self::checkAllowedScope(self::SCOPE_READ);

View file

@ -32,7 +32,7 @@ use Friendica\Module\BaseApi;
*/
class Media extends BaseApi
{
public static function post(array $parameters = [])
public static function post()
{
self::checkAllowedScope(self::SCOPE_WRITE);
$uid = self::getCurrentUserID();
@ -53,7 +53,7 @@ class Media extends BaseApi
System::jsonExit(DI::mstdnAttachment()->createFromPhoto($media['id']));
}
public static function put(array $parameters = [])
public static function put()
{
self::checkAllowedScope(self::SCOPE_WRITE);
$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
]);
if (empty($parameters['id'])) {
if (empty(static::$parameters['id'])) {
DI::mstdnError()->UnprocessableEntity();
}
$photo = Photo::selectFirst(['resource-id'], ['id' => $parameters['id'], 'uid' => $uid]);
$photo = Photo::selectFirst(['resource-id'], ['id' => static::$parameters['id'], 'uid' => $uid]);
if (empty($photo['resource-id'])) {
DI::mstdnError()->RecordNotFound();
}
Photo::update(['desc' => $request['description']], ['resource-id' => $photo['resource-id']]);
System::jsonExit(DI::mstdnAttachment()->createFromPhoto($parameters['id']));
System::jsonExit(DI::mstdnAttachment()->createFromPhoto(static::$parameters['id']));
}
/**
* @param array $parameters
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function rawContent(array $parameters = [])
public static function rawContent()
{
self::checkAllowedScope(self::SCOPE_READ);
$uid = self::getCurrentUserID();
if (empty($parameters['id'])) {
if (empty(static::$parameters['id'])) {
DI::mstdnError()->UnprocessableEntity();
}
$id = $parameters['id'];
$id = static::$parameters['id'];
if (!Photo::exists(['id' => $id, 'uid' => $uid])) {
DI::mstdnError()->RecordNotFound();
}

View file

@ -32,19 +32,18 @@ use Friendica\Module\BaseApi;
class Mutes extends BaseApi
{
/**
* @param array $parameters
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function rawContent(array $parameters = [])
public static function rawContent()
{
self::checkAllowedScope(self::SCOPE_READ);
$uid = self::getCurrentUserID();
if (empty($parameters['id'])) {
if (empty(static::$parameters['id'])) {
DI::mstdnError()->UnprocessableEntity();
}
$id = $parameters['id'];
$id = static::$parameters['id'];
if (!DBA::exists('contact', ['id' => $id, 'uid' => 0])) {
DI::mstdnError()->RecordNotFound();
}
@ -73,7 +72,7 @@ class Mutes extends BaseApi
$params['order'] = ['cid'];
}
$followers = DBA::select('user-contact', ['cid'], $condition, $parameters);
$followers = DBA::select('user-contact', ['cid'], $condition, static::$parameters);
while ($follower = DBA::fetch($followers)) {
self::setBoundaries($follower['cid']);
$accounts[] = DI::mstdnAccount()->createFromContactId($follower['cid'], $uid);

View file

@ -38,16 +38,15 @@ use Friendica\Protocol\Activity;
class Notifications extends BaseApi
{
/**
* @param array $parameters
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function rawContent(array $parameters = [])
public static function rawContent()
{
self::checkAllowedScope(self::SCOPE_READ);
$uid = self::getCurrentUserID();
if (!empty($parameters['id'])) {
$id = $parameters['id'];
if (!empty(static::$parameters['id'])) {
$id = static::$parameters['id'];
try {
$notification = DI::notification()->selectOneForUser($uid, ['id' => $id]);
System::jsonExit(DI::mstdnNotification()->createFromNotification($notification));

View file

@ -30,7 +30,7 @@ use Friendica\Module\BaseApi;
*/
class Clear extends BaseApi
{
public static function post(array $parameters = [])
public static function post()
{
self::checkAllowedScope(self::SCOPE_WRITE);
$uid = self::getCurrentUserID();

View file

@ -32,16 +32,16 @@ use Friendica\Network\HTTPException\ForbiddenException;
*/
class Dismiss extends BaseApi
{
public static function post(array $parameters = [])
public static function post()
{
self::checkAllowedScope(self::SCOPE_WRITE);
$uid = self::getCurrentUserID();
if (empty($parameters['id'])) {
if (empty(static::$parameters['id'])) {
DI::mstdnError()->UnprocessableEntity();
}
$Notification = DI::notification()->selectOneForUser($uid, $parameters['id']);
$Notification = DI::notification()->selectOneForUser($uid, static::$parameters['id']);
$Notification->setSeen();
DI::notification()->save($Notification);

View file

@ -32,10 +32,9 @@ use Friendica\Module\BaseApi;
class Preferences extends BaseApi
{
/**
* @param array $parameters
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function rawContent(array $parameters = [])
public static function rawContent()
{
self::checkAllowedScope(self::SCOPE_READ);
$uid = self::getCurrentUserID();

View file

@ -30,10 +30,9 @@ use Friendica\Module\BaseApi;
class Proofs extends BaseApi
{
/**
* @param array $parameters
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function rawContent(array $parameters = [])
public static function rawContent()
{
System::jsonError(404, ['error' => 'Record not found']);
}

View file

@ -33,7 +33,7 @@ use Friendica\Object\Api\Mastodon\Notification;
*/
class PushSubscription extends BaseApi
{
public static function post(array $parameters = [])
public static function post()
{
self::checkAllowedScope(self::SCOPE_PUSH);
$uid = self::getCurrentUserID();
@ -66,7 +66,7 @@ class PushSubscription extends BaseApi
return DI::mstdnSubscription()->createForApplicationIdAndUserId($application['id'], $uid)->toArray();
}
public static function put(array $parameters = [])
public static function put()
{
self::checkAllowedScope(self::SCOPE_PUSH);
$uid = self::getCurrentUserID();
@ -99,7 +99,7 @@ class PushSubscription extends BaseApi
return DI::mstdnSubscription()->createForApplicationIdAndUserId($application['id'], $uid)->toArray();
}
public static function delete(array $parameters = [])
public static function delete()
{
self::checkAllowedScope(self::SCOPE_PUSH);
$uid = self::getCurrentUserID();
@ -112,7 +112,7 @@ class PushSubscription extends BaseApi
System::jsonExit([]);
}
public static function rawContent(array $parameters = [])
public static function rawContent()
{
self::checkAllowedScope(self::SCOPE_PUSH);
$uid = self::getCurrentUserID();

View file

@ -34,7 +34,7 @@ use Friendica\Module\BaseApi;
*/
class ScheduledStatuses extends BaseApi
{
public static function put(array $parameters = [])
public static function put()
{
self::checkAllowedScope(self::SCOPE_WRITE);
$uid = self::getCurrentUserID();
@ -42,35 +42,34 @@ class ScheduledStatuses extends BaseApi
DI::apiResponse()->unsupported(Router::PUT);
}
public static function delete(array $parameters = [])
public static function delete()
{
self::checkAllowedScope(self::SCOPE_WRITE);
$uid = self::getCurrentUserID();
if (empty($parameters['id'])) {
if (empty(static::$parameters['id'])) {
DI::mstdnError()->UnprocessableEntity();
}
if (!DBA::exists('delayed-post', ['id' => $parameters['id'], 'uid' => $uid])) {
if (!DBA::exists('delayed-post', ['id' => static::$parameters['id'], 'uid' => $uid])) {
DI::mstdnError()->RecordNotFound();
}
Post\Delayed::deleteById($parameters['id']);
Post\Delayed::deleteById(static::$parameters['id']);
System::jsonExit([]);
}
/**
* @param array $parameters
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function rawContent(array $parameters = [])
public static function rawContent()
{
self::checkAllowedScope(self::SCOPE_READ);
$uid = self::getCurrentUserID();
if (isset($parameters['id'])) {
System::jsonExit(DI::mstdnScheduledStatus()->createFromDelayedPostId($parameters['id'], $uid)->toArray());
if (isset(static::$parameters['id'])) {
System::jsonExit(DI::mstdnScheduledStatus()->createFromDelayedPostId(static::$parameters['id'], $uid)->toArray());
}
$request = self::getRequest([

View file

@ -38,10 +38,9 @@ use Friendica\Object\Search\ContactResult;
class Search extends BaseApi
{
/**
* @param array $parameters
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function rawContent(array $parameters = [])
public static function rawContent()
{
self::checkAllowedScope(self::SCOPE_READ);
$uid = self::getCurrentUserID();
@ -74,7 +73,7 @@ class Search extends BaseApi
$result['statuses'] = self::searchStatuses($uid, $request['q'], $request['account_id'], $request['max_id'], $request['min_id'], $limit, $request['offset']);
}
if ((empty($request['type']) || ($request['type'] == 'hashtags')) && (strpos($request['q'], '@') == false)) {
$result['hashtags'] = self::searchHashtags($request['q'], $request['exclude_unreviewed'], $limit, $request['offset'], $parameters['version']);
$result['hashtags'] = self::searchHashtags($request['q'], $request['exclude_unreviewed'], $limit, $request['offset'], static::$parameters['version']);
}
System::jsonExit($result);

View file

@ -41,7 +41,7 @@ use Friendica\Util\Images;
*/
class Statuses extends BaseApi
{
public static function post(array $parameters = [])
public static function post()
{
self::checkAllowedScope(self::SCOPE_WRITE);
$uid = self::getCurrentUserID();
@ -207,16 +207,16 @@ class Statuses extends BaseApi
DI::mstdnError()->InternalError();
}
public static function delete(array $parameters = [])
public static function delete()
{
self::checkAllowedScope(self::SCOPE_READ);
$uid = self::getCurrentUserID();
if (empty($parameters['id'])) {
if (empty(static::$parameters['id'])) {
DI::mstdnError()->UnprocessableEntity();
}
$item = Post::selectFirstForUser($uid, ['id'], ['uri-id' => $parameters['id'], 'uid' => $uid]);
$item = Post::selectFirstForUser($uid, ['id'], ['uri-id' => static::$parameters['id'], 'uid' => $uid]);
if (empty($item['id'])) {
DI::mstdnError()->RecordNotFound();
}
@ -229,17 +229,16 @@ class Statuses extends BaseApi
}
/**
* @param array $parameters
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function rawContent(array $parameters = [])
public static function rawContent()
{
$uid = self::getCurrentUserID();
if (empty($parameters['id'])) {
if (empty(static::$parameters['id'])) {
DI::mstdnError()->UnprocessableEntity();
}
System::jsonExit(DI::mstdnStatus()->createFromUriId($parameters['id'], $uid));
System::jsonExit(DI::mstdnStatus()->createFromUriId(static::$parameters['id'], $uid));
}
}

View file

@ -33,16 +33,16 @@ use Friendica\Module\BaseApi;
*/
class Bookmark extends BaseApi
{
public static function post(array $parameters = [])
public static function post()
{
self::checkAllowedScope(self::SCOPE_WRITE);
$uid = self::getCurrentUserID();
if (empty($parameters['id'])) {
if (empty(static::$parameters['id'])) {
DI::mstdnError()->UnprocessableEntity();
}
$item = Post::selectFirstForUser($uid, ['id', 'gravity'], ['uri-id' => $parameters['id'], 'uid' => [$uid, 0]]);
$item = Post::selectFirstForUser($uid, ['id', 'gravity'], ['uri-id' => static::$parameters['id'], 'uid' => [$uid, 0]]);
if (!DBA::isResult($item)) {
DI::mstdnError()->RecordNotFound();
}
@ -53,6 +53,6 @@ class Bookmark extends BaseApi
Item::update(['starred' => true], ['id' => $item['id']]);
System::jsonExit(DI::mstdnStatus()->createFromUriId($parameters['id'], $uid)->toArray());
System::jsonExit(DI::mstdnStatus()->createFromUriId(static::$parameters['id'], $uid)->toArray());
}
}

View file

@ -33,18 +33,17 @@ use Friendica\Network\HTTPException;
class Card extends BaseApi
{
/**
* @param array $parameters
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function rawContent(array $parameters = [])
public static function rawContent()
{
$uid = self::getCurrentUserID();
if (empty($parameters['id'])) {
if (empty(static::$parameters['id'])) {
DI::mstdnError()->UnprocessableEntity();
}
$id = $parameters['id'];
$id = static::$parameters['id'];
if (!Post::exists(['uri-id' => $id, 'uid' => [0, $uid]])) {
throw new HTTPException\NotFoundException('Item with URI ID ' . $id . ' not found' . ($uid ? ' for user ' . $uid : '.'));

Some files were not shown because too many files have changed in this diff Show more