Make BaseModule methods dynamic

This commit is contained in:
Philipp 2021-11-14 23:13:47 +01:00
parent 714f0febc4
commit 489cd0884a
No known key found for this signature in database
GPG key ID: 24A7501396EB5432
253 changed files with 397 additions and 385 deletions

View file

@ -40,7 +40,7 @@ use Friendica\Protocol\DFRN;
function display_init(App $a)
{
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()) {

View file

@ -122,7 +122,7 @@ function unfollow_process(string $url)
$owner = User::getOwnerDataById($uid);
if (!$owner) {
\Friendica\Module\Security\Logout::init();
(new \Friendica\Module\Security\Logout())->init();
// NOTREACHED
}

View file

@ -297,32 +297,32 @@ class Module
Core\Hook::callAll($this->module . '_mod_init', $placeholder);
$this->module_class::init();
$this->module_class->init();
$profiler->set(microtime(true) - $timestamp, 'init');
if ($server['REQUEST_METHOD'] === Router::DELETE) {
$this->module_class::delete();
$this->module_class->delete();
}
if ($server['REQUEST_METHOD'] === Router::PATCH) {
$this->module_class::patch();
$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->post();
}
if ($server['REQUEST_METHOD'] === Router::PUT) {
$this->module_class::put();
$this->module_class->put();
}
Core\Hook::callAll($this->module . '_mod_afterpost', $placeholder);
$this->module_class::afterpost();
$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->rawContent();
}
}

View file

@ -350,13 +350,13 @@ class Page implements ArrayAccess
$moduleClass = $module->getClass();
$arr = ['content' => $content];
Hook::callAll( $moduleClass::getClassName() . '_mod_content', $arr);
Hook::callAll( $moduleClass->getClassName() . '_mod_content', $arr);
$content = $arr['content'];
$arr = ['content' => $moduleClass::content()];
Hook::callAll($moduleClass::getClassName() . '_mod_aftercontent', $arr);
$arr = ['content' => $moduleClass->content()];
Hook::callAll($moduleClass->getClassName() . '_mod_aftercontent', $arr);
$content .= $arr['content'];
} catch (HTTPException $e) {
$content = ModuleHTTPException::content($e);
$content = (new ModuleHTTPException())->content($e);
}
// initialise content region

View file

@ -47,14 +47,14 @@ abstract class BaseModule implements ICanHandleRequests
/**
* {@inheritDoc}
*/
public static function init()
public function init()
{
}
/**
* {@inheritDoc}
*/
public static function rawContent()
public function rawContent()
{
// echo '';
// exit;
@ -63,7 +63,7 @@ abstract class BaseModule implements ICanHandleRequests
/**
* {@inheritDoc}
*/
public static function content()
public function content(): string
{
return '';
}
@ -71,21 +71,21 @@ abstract class BaseModule implements ICanHandleRequests
/**
* {@inheritDoc}
*/
public static function delete()
public function delete()
{
}
/**
* {@inheritDoc}
*/
public static function patch()
public function patch()
{
}
/**
* {@inheritDoc}
*/
public static function post()
public function post()
{
// DI::baseurl()->redirect('module');
}
@ -93,19 +93,19 @@ abstract class BaseModule implements ICanHandleRequests
/**
* {@inheritDoc}
*/
public static function afterpost()
public function afterpost()
{
}
/**
* {@inheritDoc}
*/
public static function put()
public function put()
{
}
/** Gets the name of the current class */
public static function getClassName(): string
public function getClassName(): string
{
return static::class;
}

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();
public 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();
public function rawContent();
/**
* Module GET method to display any content
@ -29,10 +29,8 @@ interface ICanHandleRequests
* 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();
public function content(): string;
/**
* Module DELETE method to process submitted data
@ -40,7 +38,7 @@ interface ICanHandleRequests
* Extend this method if the module is supposed to process DELETE requests.
* Doesn't display any content
*/
public static function delete();
public function delete();
/**
* Module PATCH method to process submitted data
@ -48,7 +46,7 @@ interface ICanHandleRequests
* Extend this method if the module is supposed to process PATCH requests.
* Doesn't display any content
*/
public static function patch();
public function patch();
/**
* Module POST method to process submitted data
@ -56,14 +54,14 @@ interface ICanHandleRequests
* Extend this method if the module is supposed to process POST requests.
* Doesn't display any content
*/
public static function post();
public function post();
/**
* Called after post()
*
* Unknown purpose
*/
public static function afterpost();
public function afterpost();
/**
* Module PUT method to process submitted data
@ -71,7 +69,7 @@ interface ICanHandleRequests
* Extend this method if the module is supposed to process PUT requests.
* Doesn't display any content
*/
public static function put();
public function put();
public static function getClassName(): string;
public function getClassName(): string;
}

View file

@ -54,22 +54,22 @@ class LegacyModule extends BaseModule
require_once $file_path;
}
public static function init()
public function init()
{
self::runModuleFunction('init', static::$parameters);
}
public static function content()
public function content(): string
{
return self::runModuleFunction('content', static::$parameters);
}
public static function post()
public function post()
{
self::runModuleFunction('post', static::$parameters);
}
public static function afterpost()
public function afterpost()
{
self::runModuleFunction('afterpost', static::$parameters);
}

View file

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

View file

@ -30,7 +30,7 @@ use Friendica\Model\Contact;
*/
class Acctlink extends BaseModule
{
public static function content()
public function content(): string
{
$addr = trim($_GET['addr'] ?? '');
@ -41,5 +41,7 @@ class Acctlink extends BaseModule
exit();
}
}
return '';
}
}

View file

@ -31,7 +31,7 @@ use Friendica\Protocol\ActivityPub;
*/
class Followers extends BaseModule
{
public static function rawContent()
public function rawContent()
{
if (empty(static::$parameters['nickname'])) {
throw new \Friendica\Network\HTTPException\NotFoundException();

View file

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

View file

@ -35,7 +35,7 @@ use Friendica\Util\Network;
*/
class Inbox extends BaseModule
{
public static function rawContent()
public function rawContent()
{
$postdata = Network::postdata();

View file

@ -41,7 +41,7 @@ use Friendica\Util\Strings;
*/
class Objects extends BaseModule
{
public static function rawContent()
public function rawContent()
{
if (empty(static::$parameters['guid'])) {
throw new HTTPException\BadRequestException();

View file

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

View file

@ -30,7 +30,7 @@ use Friendica\Util\Strings;
class Details extends BaseAdmin
{
public static function post()
public function post()
{
self::checkAdminAccess();
@ -52,7 +52,7 @@ class Details extends BaseAdmin
DI::baseUrl()->redirect($redirect);
}
public static function content()
public function content(): string
{
parent::content();

View file

@ -28,7 +28,7 @@ use Friendica\Module\BaseAdmin;
class Index extends BaseAdmin
{
public static function content()
public function content(): string
{
parent::content();

View file

@ -32,7 +32,7 @@ use Friendica\Util\Network;
class Contact extends BaseAdmin
{
public static function post()
public function post()
{
self::checkAdminAccess();
@ -76,7 +76,7 @@ class Contact extends BaseAdmin
DI::baseUrl()->redirect('admin/blocklist/contact');
}
public static function content()
public function content(): string
{
parent::content();

View file

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

View file

@ -27,7 +27,7 @@ use Friendica\Module\BaseAdmin;
class Index extends BaseAdmin
{
public static function post()
public function post()
{
self::checkAdminAccess();
@ -56,7 +56,7 @@ class Index extends BaseAdmin
DI::baseUrl()->redirect('admin/blocklist/server');
}
public static function content()
public function content(): string
{
parent::content();

View file

@ -30,7 +30,7 @@ use Friendica\Module\BaseAdmin;
class DBSync extends BaseAdmin
{
public static function content()
public function content(): string
{
parent::content();

View file

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

View file

@ -28,7 +28,7 @@ use Friendica\Module\BaseAdmin;
class Federation extends BaseAdmin
{
public static function content()
public function content(): string
{
parent::content();

View file

@ -29,7 +29,7 @@ use Friendica\Util\Strings;
class Delete extends BaseAdmin
{
public static function post()
public function post()
{
self::checkAdminAccess();
@ -55,7 +55,7 @@ class Delete extends BaseAdmin
DI::baseUrl()->redirect('admin/item/delete');
}
public static function content()
public function content(): string
{
parent::content();

View file

@ -29,7 +29,7 @@ use Friendica\Module\BaseAdmin;
class Source extends BaseAdmin
{
public static function content()
public function content(): string
{
parent::content();

View file

@ -29,7 +29,7 @@ use Psr\Log\LogLevel;
class Settings extends BaseAdmin
{
public static function post()
public function post()
{
self::checkAdminAccess();
@ -56,7 +56,7 @@ class Settings extends BaseAdmin
DI::baseUrl()->redirect('admin/logs');
}
public static function content()
public function content(): string
{
parent::content();

View file

@ -31,7 +31,7 @@ class View extends BaseAdmin
{
const LIMIT = 500;
public static function content()
public function content(): string
{
parent::content();

View file

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

View file

@ -38,7 +38,7 @@ use Friendica\Util\DateTimeFormat;
*/
class Queue extends BaseAdmin
{
public static function content()
public function content(): string
{
parent::content();

View file

@ -43,7 +43,7 @@ require_once __DIR__ . '/../../../boot.php';
class Site extends BaseAdmin
{
public static function post()
public function post()
{
self::checkAdminAccess();
@ -384,7 +384,7 @@ class Site extends BaseAdmin
DI::baseUrl()->redirect('admin/site' . $active_panel);
}
public static function content()
public function content(): string
{
parent::content();

View file

@ -31,7 +31,7 @@ use Friendica\Util\Strings;
class Storage extends BaseAdmin
{
public static function post()
public function post()
{
self::checkAdminAccess();
@ -91,7 +91,7 @@ class Storage extends BaseAdmin
DI::baseUrl()->redirect('admin/storage');
}
public static function content()
public function content(): string
{
parent::content();

View file

@ -37,7 +37,7 @@ use Friendica\Util\DateTimeFormat;
class Summary extends BaseAdmin
{
public static function content()
public function content(): string
{
parent::content();

View file

@ -30,7 +30,7 @@ use Friendica\Util\Strings;
class Details extends BaseAdmin
{
public static function content()
public function content(): string
{
parent::content();

View file

@ -28,7 +28,7 @@ use Friendica\Util\Strings;
class Embed extends BaseAdmin
{
public static function init()
public function init()
{
$theme = Strings::sanitizeFilePathItem(static::$parameters['theme']);
if (is_file("view/theme/$theme/config.php")) {
@ -36,7 +36,7 @@ class Embed extends BaseAdmin
}
}
public static function post()
public function post()
{
self::checkAdminAccess();
@ -56,7 +56,7 @@ class Embed extends BaseAdmin
DI::baseUrl()->redirect('admin/themes/' . $theme . '/embed?mode=minimal');
}
public static function content()
public function content(): string
{
parent::content();

View file

@ -29,7 +29,7 @@ use Friendica\Util\Strings;
class Index extends BaseAdmin
{
public static function content()
public function content(): string
{
parent::content();

View file

@ -27,7 +27,7 @@ use Friendica\Module\BaseAdmin;
class Tos extends BaseAdmin
{
public static function post()
public function post()
{
self::checkAdminAccess();
@ -48,7 +48,7 @@ class Tos extends BaseAdmin
DI::baseUrl()->redirect('admin/tos');
}
public static function content()
public function content(): string
{
parent::content();

View file

@ -30,7 +30,7 @@ use Friendica\Module\Admin\BaseUsers;
class Active extends BaseUsers
{
public static function post()
public function post()
{
self::checkAdminAccess();
@ -60,7 +60,7 @@ class Active extends BaseUsers
DI::baseUrl()->redirect(DI::args()->getQueryString());
}
public static function content()
public function content(): string
{
parent::content();

View file

@ -31,7 +31,7 @@ use Friendica\Util\Temporal;
class Blocked extends BaseUsers
{
public static function post()
public function post()
{
self::checkAdminAccess();
@ -61,7 +61,7 @@ class Blocked extends BaseUsers
DI::baseUrl()->redirect('admin/users/blocked');
}
public static function content()
public function content(): string
{
parent::content();

View file

@ -28,7 +28,7 @@ use Friendica\Module\Admin\BaseUsers;
class Create extends BaseUsers
{
public static function post()
public function post()
{
self::checkAdminAccess();
@ -51,7 +51,7 @@ class Create extends BaseUsers
DI::baseUrl()->redirect('admin/users/create');
}
public static function content()
public function content(): string
{
parent::content();

View file

@ -33,7 +33,7 @@ use Friendica\Util\Temporal;
class Deleted extends BaseUsers
{
public static function post()
public function post()
{
self::checkAdminAccess();
@ -44,7 +44,7 @@ class Deleted extends BaseUsers
DI::baseUrl()->redirect('admin/users/deleted');
}
public static function content()
public function content(): string
{
parent::content();

View file

@ -30,7 +30,7 @@ use Friendica\Module\Admin\BaseUsers;
class Index extends BaseUsers
{
public static function post()
public function post()
{
self::checkAdminAccess();
@ -67,7 +67,7 @@ class Index extends BaseUsers
DI::baseUrl()->redirect(DI::args()->getQueryString());
}
public static function content()
public function content(): string
{
parent::content();

View file

@ -33,7 +33,7 @@ use Friendica\Util\Temporal;
class Pending extends BaseUsers
{
public static function post()
public function post()
{
self::checkAdminAccess();
@ -58,7 +58,7 @@ class Pending extends BaseUsers
DI::baseUrl()->redirect('admin/users/pending');
}
public static function content()
public function content(): string
{
parent::content();

View file

@ -40,7 +40,7 @@ use Friendica\Module\BaseApi;
*/
class Activity extends BaseApi
{
public static function rawContent()
public function rawContent()
{
self::checkAllowedScope(self::SCOPE_WRITE);
$uid = self::getCurrentUserID();

View file

@ -30,7 +30,7 @@ use Friendica\Module\BaseApi;
*/
class Setseen extends BaseApi
{
public static function rawContent()
public function rawContent()
{
self::checkAllowedScope(self::SCOPE_WRITE);
$uid = self::getCurrentUserID();

View file

@ -33,7 +33,7 @@ use Friendica\Module\BaseApi;
*/
class Index extends BaseApi
{
public static function rawContent()
public function rawContent()
{
self::checkAllowedScope(self::SCOPE_READ);
$uid = self::getCurrentUserID();

View file

@ -31,17 +31,17 @@ use Friendica\Module\BaseApi;
*/
class Index extends BaseApi
{
public static function post()
public function post()
{
self::checkAllowedScope(self::SCOPE_WRITE);
}
public static function delete()
public function delete()
{
self::checkAllowedScope(self::SCOPE_WRITE);
}
public static function rawContent()
public 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()
public function rawContent()
{
self::checkAllowedScope(self::SCOPE_READ);
$uid = self::getCurrentUserID();

View file

@ -33,7 +33,7 @@ use Friendica\Network\HTTPException\InternalServerErrorException;
*/
class Delete extends BaseApi
{
public static function rawContent()
public function rawContent()
{
self::checkAllowedScope(self::SCOPE_WRITE);
$uid = self::getCurrentUserID();

View file

@ -34,7 +34,7 @@ use Friendica\Network\HTTPException\InternalServerErrorException;
*/
class Delete extends BaseApi
{
public static function rawContent()
public function rawContent()
{
self::checkAllowedScope(self::SCOPE_WRITE);
$uid = self::getCurrentUserID();

View file

@ -32,7 +32,7 @@ use Friendica\Network\HTTPException\InternalServerErrorException;
*/
class Update extends BaseApi
{
public static function rawContent()
public function rawContent()
{
self::checkAllowedScope(self::SCOPE_WRITE);
$uid = self::getCurrentUserID();

View file

@ -34,7 +34,7 @@ use Friendica\Network\HTTPException;
*/
class Show extends BaseApi
{
public static function rawContent()
public function rawContent()
{
self::checkAllowedScope(self::SCOPE_READ);
$uid = self::getCurrentUserID();

View file

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

View file

@ -29,7 +29,7 @@ use Friendica\DI;
*/
class Test extends BaseApi
{
public static function rawContent()
public function rawContent()
{
if (!empty(static::$parameters['extension']) && (static::$parameters['extension'] == 'xml')) {
$ok = 'true';

View file

@ -35,7 +35,7 @@ class Accounts extends BaseApi
/**
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function rawContent()
public function rawContent()
{
$uid = self::getCurrentUserID();

View file

@ -32,7 +32,7 @@ use Friendica\Module\BaseApi;
*/
class Block extends BaseApi
{
public static function post()
public function post()
{
self::checkAllowedScope(self::SCOPE_FOLLOW);
$uid = self::getCurrentUserID();

View file

@ -32,7 +32,7 @@ class FeaturedTags extends BaseApi
/**
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function rawContent()
public function rawContent()
{
self::checkAllowedScope(self::SCOPE_READ);

View file

@ -31,7 +31,7 @@ use Friendica\Module\BaseApi;
*/
class Follow extends BaseApi
{
public static function post()
public function post()
{
self::checkAllowedScope(self::SCOPE_FOLLOW);
$uid = self::getCurrentUserID();

View file

@ -34,7 +34,7 @@ class Followers extends BaseApi
/**
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function rawContent()
public function rawContent()
{
self::checkAllowedScope(self::SCOPE_READ);
$uid = self::getCurrentUserID();

View file

@ -34,7 +34,7 @@ class Following extends BaseApi
/**
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function rawContent()
public function rawContent()
{
self::checkAllowedScope(self::SCOPE_READ);
$uid = self::getCurrentUserID();

View file

@ -32,7 +32,7 @@ class IdentityProofs extends BaseApi
/**
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function rawContent()
public function rawContent()
{
self::checkAllowedScope(self::SCOPE_READ);

View file

@ -35,7 +35,7 @@ class Lists extends BaseApi
/**
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function rawContent()
public function rawContent()
{
self::checkAllowedScope(self::SCOPE_READ);
$uid = self::getCurrentUserID();

View file

@ -31,7 +31,7 @@ use Friendica\Module\BaseApi;
*/
class Mute extends BaseApi
{
public static function post()
public function post()
{
self::checkAllowedScope(self::SCOPE_FOLLOW);
$uid = self::getCurrentUserID();

View file

@ -32,7 +32,7 @@ use Friendica\Module\BaseApi;
*/
class Note extends BaseApi
{
public static function post()
public function post()
{
self::checkAllowedScope(self::SCOPE_WRITE);
$uid = self::getCurrentUserID();

View file

@ -34,7 +34,7 @@ class Relationships extends BaseApi
/**
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function rawContent()
public function rawContent()
{
self::checkAllowedScope(self::SCOPE_READ);
$uid = self::getCurrentUserID();

View file

@ -37,7 +37,7 @@ class Search extends BaseApi
/**
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function rawContent()
public function rawContent()
{
self::checkAllowedScope(self::SCOPE_READ);
$uid = self::getCurrentUserID();

View file

@ -39,7 +39,7 @@ class Statuses extends BaseApi
/**
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function rawContent()
public function rawContent()
{
$uid = self::getCurrentUserID();

View file

@ -31,7 +31,7 @@ use Friendica\Module\BaseApi;
*/
class Unblock extends BaseApi
{
public static function post()
public function post()
{
self::checkAllowedScope(self::SCOPE_FOLLOW);
$uid = self::getCurrentUserID();

View file

@ -31,7 +31,7 @@ use Friendica\Module\BaseApi;
*/
class Unfollow extends BaseApi
{
public static function post()
public function post()
{
self::checkAllowedScope(self::SCOPE_FOLLOW);
$uid = self::getCurrentUserID();

View file

@ -31,7 +31,7 @@ use Friendica\Module\BaseApi;
*/
class Unmute extends BaseApi
{
public static function post()
public function post()
{
self::checkAllowedScope(self::SCOPE_FOLLOW);
$uid = self::getCurrentUserID();

View file

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

View file

@ -35,7 +35,7 @@ class VerifyCredentials extends BaseApi
/**
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function rawContent()
public function rawContent()
{
self::checkAllowedScope(self::SCOPE_READ);
$uid = self::getCurrentUserID();

View file

@ -32,7 +32,7 @@ class Announcements extends BaseApi
/**
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function rawContent()
public function rawContent()
{
self::checkAllowedScope(self::SCOPE_READ);

View file

@ -35,7 +35,7 @@ class Apps extends BaseApi
/**
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function post()
public 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()
public function rawContent()
{
self::checkAllowedScope(self::SCOPE_READ);
$application = self::getCurrentApplication();

View file

@ -34,7 +34,7 @@ class Blocks extends BaseApi
/**
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function rawContent()
public function rawContent()
{
self::checkAllowedScope(self::SCOPE_READ);
$uid = self::getCurrentUserID();

View file

@ -36,7 +36,7 @@ class Bookmarks extends BaseApi
/**
* @throws HTTPException\InternalServerErrorException
*/
public static function rawContent()
public function rawContent()
{
self::checkAllowedScope(self::SCOPE_READ);
$uid = self::getCurrentUserID();

View file

@ -31,7 +31,7 @@ use Friendica\Module\BaseApi;
*/
class Conversations extends BaseApi
{
public static function delete()
public function delete()
{
self::checkAllowedScope(self::SCOPE_WRITE);
$uid = self::getCurrentUserID();
@ -49,7 +49,7 @@ class Conversations extends BaseApi
/**
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function rawContent()
public function rawContent()
{
self::checkAllowedScope(self::SCOPE_READ);
$uid = self::getCurrentUserID();

View file

@ -31,7 +31,7 @@ use Friendica\Module\BaseApi;
*/
class Read extends BaseApi
{
public static function post()
public function post()
{
self::checkAllowedScope(self::SCOPE_WRITE);
$uid = self::getCurrentUserID();

View file

@ -37,7 +37,7 @@ class CustomEmojis extends BaseApi
* @throws \ImagickException
* @see https://docs.joinmastodon.org/methods/accounts/follow_requests#pending-follows
*/
public static function rawContent()
public function rawContent()
{
$emojis = DI::mstdnEmoji()->createCollectionFromSmilies(Smilies::getList());

View file

@ -39,7 +39,7 @@ class Directory extends BaseApi
* @throws \ImagickException
* @see https://docs.joinmastodon.org/methods/instance/directory/
*/
public static function rawContent()
public function rawContent()
{
$request = self::getRequest([
'offset' => 0, // How many accounts to skip before returning results. Default 0.

View file

@ -32,7 +32,7 @@ class Endorsements extends BaseApi
/**
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function rawContent()
public function rawContent()
{
System::jsonExit([]);
}

View file

@ -37,7 +37,7 @@ class Favourited extends BaseApi
/**
* @throws HTTPException\InternalServerErrorException
*/
public static function rawContent()
public 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()
public function post()
{
self::checkAllowedScope(self::SCOPE_WRITE);
@ -41,7 +41,7 @@ class Filters extends BaseApi
/**
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function rawContent()
public function rawContent()
{
self::checkAllowedScope(self::SCOPE_READ);

View file

@ -42,7 +42,7 @@ class FollowRequests extends BaseApi
* @see https://docs.joinmastodon.org/methods/accounts/follow_requests#accept-follow
* @see https://docs.joinmastodon.org/methods/accounts/follow_requests#reject-follow
*/
public static function post()
public function post()
{
self::checkAllowedScope(self::SCOPE_FOLLOW);
$uid = self::getCurrentUserID();
@ -82,7 +82,7 @@ class FollowRequests extends BaseApi
* @throws \ImagickException
* @see https://docs.joinmastodon.org/methods/accounts/follow_requests/
*/
public static function rawContent()
public function rawContent()
{
self::checkAllowedScope(self::SCOPE_READ);
$uid = self::getCurrentUserID();

View file

@ -33,7 +33,7 @@ class Instance extends BaseApi
/**
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function rawContent()
public function rawContent()
{
System::jsonExit(InstanceEntity::get());
}

View file

@ -36,7 +36,7 @@ class Peers extends BaseApi
/**
* @throws HTTPException\InternalServerErrorException
*/
public static function rawContent()
public function rawContent()
{
$return = [];

View file

@ -36,7 +36,7 @@ class Rules extends BaseApi
/**
* @throws HTTPException\InternalServerErrorException
*/
public static function rawContent()
public function rawContent()
{
$rules = [];
$id = 0;

View file

@ -31,7 +31,7 @@ use Friendica\Model\Group;
*/
class Lists extends BaseApi
{
public static function delete()
public function delete()
{
self::checkAllowedScope(self::SCOPE_WRITE);
$uid = self::getCurrentUserID();
@ -51,7 +51,7 @@ class Lists extends BaseApi
System::jsonExit([]);
}
public static function post()
public function post()
{
self::checkAllowedScope(self::SCOPE_WRITE);
$uid = self::getCurrentUserID();
@ -74,7 +74,7 @@ class Lists extends BaseApi
System::jsonExit(DI::mstdnList()->createFromGroupId($id));
}
public static function put()
public function put()
{
$request = self::getRequest([
'title' => '', // The title of the list to be updated.
@ -91,7 +91,7 @@ class Lists extends BaseApi
/**
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function rawContent()
public function rawContent()
{
self::checkAllowedScope(self::SCOPE_READ);
$uid = self::getCurrentUserID();

View file

@ -35,12 +35,12 @@ use Friendica\Module\BaseApi;
*/
class Accounts extends BaseApi
{
public static function delete()
public function delete()
{
DI::apiResponse()->unsupported(Router::DELETE);
}
public static function post()
public function post()
{
DI::apiResponse()->unsupported(Router::POST);
}
@ -48,7 +48,7 @@ class Accounts extends BaseApi
/**
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function rawContent()
public function rawContent()
{
self::checkAllowedScope(self::SCOPE_READ);
$uid = self::getCurrentUserID();

View file

@ -31,7 +31,7 @@ use Friendica\Module\BaseApi;
*/
class Markers extends BaseApi
{
public static function post()
public function post()
{
self::checkAllowedScope(self::SCOPE_WRITE);
@ -41,7 +41,7 @@ class Markers extends BaseApi
/**
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function rawContent()
public 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()
public 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()
public function put()
{
self::checkAllowedScope(self::SCOPE_WRITE);
$uid = self::getCurrentUserID();
@ -82,7 +82,7 @@ class Media extends BaseApi
/**
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function rawContent()
public function rawContent()
{
self::checkAllowedScope(self::SCOPE_READ);
$uid = self::getCurrentUserID();

View file

@ -34,7 +34,7 @@ class Mutes extends BaseApi
/**
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function rawContent()
public function rawContent()
{
self::checkAllowedScope(self::SCOPE_READ);
$uid = self::getCurrentUserID();

View file

@ -40,7 +40,7 @@ class Notifications extends BaseApi
/**
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function rawContent()
public function rawContent()
{
self::checkAllowedScope(self::SCOPE_READ);
$uid = self::getCurrentUserID();

View file

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

View file

@ -32,7 +32,7 @@ use Friendica\Network\HTTPException\ForbiddenException;
*/
class Dismiss extends BaseApi
{
public static function post()
public function post()
{
self::checkAllowedScope(self::SCOPE_WRITE);
$uid = self::getCurrentUserID();

View file

@ -34,7 +34,7 @@ class Preferences extends BaseApi
/**
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function rawContent()
public function rawContent()
{
self::checkAllowedScope(self::SCOPE_READ);
$uid = self::getCurrentUserID();

View file

@ -32,7 +32,7 @@ class Proofs extends BaseApi
/**
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function rawContent()
public 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()
public 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()
public 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()
public function delete()
{
self::checkAllowedScope(self::SCOPE_PUSH);
$uid = self::getCurrentUserID();
@ -112,7 +112,7 @@ class PushSubscription extends BaseApi
System::jsonExit([]);
}
public static function rawContent()
public 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()
public function put()
{
self::checkAllowedScope(self::SCOPE_WRITE);
$uid = self::getCurrentUserID();
@ -42,7 +42,7 @@ class ScheduledStatuses extends BaseApi
DI::apiResponse()->unsupported(Router::PUT);
}
public static function delete()
public function delete()
{
self::checkAllowedScope(self::SCOPE_WRITE);
$uid = self::getCurrentUserID();
@ -63,7 +63,7 @@ class ScheduledStatuses extends BaseApi
/**
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function rawContent()
public function rawContent()
{
self::checkAllowedScope(self::SCOPE_READ);
$uid = self::getCurrentUserID();

View file

@ -40,7 +40,7 @@ class Search extends BaseApi
/**
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function rawContent()
public function rawContent()
{
self::checkAllowedScope(self::SCOPE_READ);
$uid = self::getCurrentUserID();

View file

@ -41,7 +41,7 @@ use Friendica\Util\Images;
*/
class Statuses extends BaseApi
{
public static function post()
public function post()
{
self::checkAllowedScope(self::SCOPE_WRITE);
$uid = self::getCurrentUserID();
@ -207,7 +207,7 @@ class Statuses extends BaseApi
DI::mstdnError()->InternalError();
}
public static function delete()
public function delete()
{
self::checkAllowedScope(self::SCOPE_READ);
$uid = self::getCurrentUserID();
@ -231,7 +231,7 @@ class Statuses extends BaseApi
/**
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function rawContent()
public function rawContent()
{
$uid = self::getCurrentUserID();

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