From f70a64891c34703085f2f598b55e59ef54faa21d Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Wed, 11 Oct 2023 09:05:36 -0400 Subject: [PATCH 01/10] Add Factory\Api\Mastodon\Error dependency to BaseApi - Copy Factory\Api\Mastodon\Error->logError functionality to BaseApi --- .../Api/Friendica/DirectMessages/Search.php | 4 ++-- src/Module/Api/Friendica/Photo.php | 4 ++-- src/Module/Api/Friendica/Photo/Create.php | 4 ++-- src/Module/Api/Friendica/Photo/Lists.php | 4 ++-- src/Module/Api/Friendica/Photo/Update.php | 4 ++-- src/Module/Api/Friendica/Photoalbum/Show.php | 4 ++-- src/Module/Api/Mastodon/Instance.php | 4 ++-- src/Module/Api/Mastodon/InstanceV2.php | 3 ++- src/Module/Api/Mastodon/PushSubscription.php | 11 ++++------ src/Module/Api/Mastodon/Reports.php | 4 ++-- src/Module/Api/Twitter/ContactEndpoint.php | 4 ++-- .../Api/Twitter/DirectMessages/Destroy.php | 4 ++-- .../Api/Twitter/DirectMessages/NewDM.php | 4 ++-- .../Api/Twitter/DirectMessagesEndpoint.php | 4 ++-- .../Api/Twitter/Friendships/Destroy.php | 4 ++-- src/Module/Api/Twitter/Lists/Create.php | 4 ++-- src/Module/Api/Twitter/Lists/Destroy.php | 4 ++-- src/Module/Api/Twitter/Lists/Ownership.php | 4 ++-- src/Module/Api/Twitter/Lists/Statuses.php | 4 ++-- src/Module/Api/Twitter/Lists/Update.php | 4 ++-- src/Module/BaseApi.php | 22 ++++++++++++++++--- 21 files changed, 61 insertions(+), 47 deletions(-) diff --git a/src/Module/Api/Friendica/DirectMessages/Search.php b/src/Module/Api/Friendica/DirectMessages/Search.php index 508f374fd..04c7a405b 100644 --- a/src/Module/Api/Friendica/DirectMessages/Search.php +++ b/src/Module/Api/Friendica/DirectMessages/Search.php @@ -44,9 +44,9 @@ class Search extends BaseApi /** @var DirectMessage */ private $directMessage; - public function __construct(DirectMessage $directMessage, Database $dba, App $app, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, ApiResponse $response, array $server, array $parameters = []) + public function __construct(DirectMessage $directMessage, Database $dba, \Friendica\Factory\Api\Mastodon\Error $errorFactory, App $app, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, ApiResponse $response, array $server, array $parameters = []) { - parent::__construct($app, $l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters); + parent::__construct($errorFactory, $app, $l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters); $this->dba = $dba; $this->directMessage = $directMessage; diff --git a/src/Module/Api/Friendica/Photo.php b/src/Module/Api/Friendica/Photo.php index 7973c3b6e..3653a97fd 100644 --- a/src/Module/Api/Friendica/Photo.php +++ b/src/Module/Api/Friendica/Photo.php @@ -37,9 +37,9 @@ class Photo extends BaseApi private $friendicaPhoto; - public function __construct(FriendicaPhoto $friendicaPhoto, App $app, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, ApiResponse $response, array $server, array $parameters = []) + public function __construct(FriendicaPhoto $friendicaPhoto, \Friendica\Factory\Api\Mastodon\Error $errorFactory, App $app, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, ApiResponse $response, array $server, array $parameters = []) { - parent::__construct($app, $l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters); + parent::__construct($errorFactory, $app, $l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters); $this->friendicaPhoto = $friendicaPhoto; } diff --git a/src/Module/Api/Friendica/Photo/Create.php b/src/Module/Api/Friendica/Photo/Create.php index 780060ca2..b08b37411 100644 --- a/src/Module/Api/Friendica/Photo/Create.php +++ b/src/Module/Api/Friendica/Photo/Create.php @@ -41,9 +41,9 @@ class Create extends BaseApi private $friendicaPhoto; - public function __construct(FriendicaPhoto $friendicaPhoto, App $app, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, ApiResponse $response, array $server, array $parameters = []) + public function __construct(FriendicaPhoto $friendicaPhoto, \Friendica\Factory\Api\Mastodon\Error $errorFactory, App $app, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, ApiResponse $response, array $server, array $parameters = []) { - parent::__construct($app, $l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters); + parent::__construct($errorFactory, $app, $l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters); $this->friendicaPhoto = $friendicaPhoto; } diff --git a/src/Module/Api/Friendica/Photo/Lists.php b/src/Module/Api/Friendica/Photo/Lists.php index 662107f98..8a0a4d7eb 100644 --- a/src/Module/Api/Friendica/Photo/Lists.php +++ b/src/Module/Api/Friendica/Photo/Lists.php @@ -43,9 +43,9 @@ class Lists extends BaseApi private $friendicaPhoto; - public function __construct(FriendicaPhoto $friendicaPhoto, App $app, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, ApiResponse $response, array $server, array $parameters = []) + public function __construct(FriendicaPhoto $friendicaPhoto, \Friendica\Factory\Api\Mastodon\Error $errorFactory, App $app, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, ApiResponse $response, array $server, array $parameters = []) { - parent::__construct($app, $l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters); + parent::__construct($errorFactory, $app, $l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters); $this->friendicaPhoto = $friendicaPhoto; } diff --git a/src/Module/Api/Friendica/Photo/Update.php b/src/Module/Api/Friendica/Photo/Update.php index 208e3eb40..1e40f752c 100644 --- a/src/Module/Api/Friendica/Photo/Update.php +++ b/src/Module/Api/Friendica/Photo/Update.php @@ -41,9 +41,9 @@ class Update extends BaseApi private $friendicaPhoto; - public function __construct(FriendicaPhoto $friendicaPhoto, App $app, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, ApiResponse $response, array $server, array $parameters = []) + public function __construct(FriendicaPhoto $friendicaPhoto, \Friendica\Factory\Api\Mastodon\Error $errorFactory, App $app, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, ApiResponse $response, array $server, array $parameters = []) { - parent::__construct($app, $l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters); + parent::__construct($errorFactory, $app, $l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters); $this->friendicaPhoto = $friendicaPhoto; } diff --git a/src/Module/Api/Friendica/Photoalbum/Show.php b/src/Module/Api/Friendica/Photoalbum/Show.php index 0a7b5ee26..8e6d77ae5 100644 --- a/src/Module/Api/Friendica/Photoalbum/Show.php +++ b/src/Module/Api/Friendica/Photoalbum/Show.php @@ -43,9 +43,9 @@ class Show extends BaseApi private $friendicaPhoto; - public function __construct(FriendicaPhoto $friendicaPhoto, App $app, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, ApiResponse $response, array $server, array $parameters = []) + public function __construct(FriendicaPhoto $friendicaPhoto, \Friendica\Factory\Api\Mastodon\Error $errorFactory, App $app, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, ApiResponse $response, array $server, array $parameters = []) { - parent::__construct($app, $l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters); + parent::__construct($errorFactory, $app, $l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters); $this->friendicaPhoto = $friendicaPhoto; } diff --git a/src/Module/Api/Mastodon/Instance.php b/src/Module/Api/Mastodon/Instance.php index bf968b638..709617478 100644 --- a/src/Module/Api/Mastodon/Instance.php +++ b/src/Module/Api/Mastodon/Instance.php @@ -43,9 +43,9 @@ class Instance extends BaseApi /** @var IManageConfigValues */ private $config; - public function __construct(App $app, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, ApiResponse $response, Database $database, IManageConfigValues $config, array $server, array $parameters = []) + public function __construct(\Friendica\Factory\Api\Mastodon\Error $errorFactory, App $app, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, ApiResponse $response, Database $database, IManageConfigValues $config, array $server, array $parameters = []) { - parent::__construct($app, $l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters); + parent::__construct($errorFactory, $app, $l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters); $this->database = $database; $this->config = $config; diff --git a/src/Module/Api/Mastodon/InstanceV2.php b/src/Module/Api/Mastodon/InstanceV2.php index 5e7511c02..7469e1c63 100644 --- a/src/Module/Api/Mastodon/InstanceV2.php +++ b/src/Module/Api/Mastodon/InstanceV2.php @@ -54,6 +54,7 @@ class InstanceV2 extends BaseApi private $contactHeader; public function __construct( + \Friendica\Factory\Api\Mastodon\Error $errorFactory, App $app, L10n $l10n, App\BaseURL $baseUrl, @@ -66,7 +67,7 @@ class InstanceV2 extends BaseApi array $server, array $parameters = [] ) { - parent::__construct($app, $l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters); + parent::__construct($errorFactory, $app, $l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters); $this->database = $database; $this->config = $config; diff --git a/src/Module/Api/Mastodon/PushSubscription.php b/src/Module/Api/Mastodon/PushSubscription.php index f43d995b6..a80188013 100644 --- a/src/Module/Api/Mastodon/PushSubscription.php +++ b/src/Module/Api/Mastodon/PushSubscription.php @@ -39,15 +39,12 @@ class PushSubscription extends BaseApi { /** @var SubscriptionFactory */ protected $subscriptionFac; - /** @var Error */ - protected $errorFac; - public function __construct(App $app, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, ApiResponse $response, SubscriptionFactory $subscriptionFac, Error $errorFac, array $server, array $parameters = []) + public function __construct(\Friendica\Factory\Api\Mastodon\Error $errorFactory, App $app, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, ApiResponse $response, SubscriptionFactory $subscriptionFac, array $server, array $parameters = []) { - parent::__construct($app, $l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters); + parent::__construct($errorFactory, $app, $l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters); $this->subscriptionFac = $subscriptionFac; - $this->errorFac = $errorFac; } protected function post(array $request = []): void @@ -97,7 +94,7 @@ class PushSubscription extends BaseApi $subscription = Subscription::select($application['id'], $uid, ['id']); if (empty($subscription)) { $this->logger->info('Subscription not found', ['application-id' => $application['id'], 'uid' => $uid]); - $this->errorFac->RecordNotFound(); + $this->errorFactory->RecordNotFound(); } $fields = [ @@ -148,7 +145,7 @@ class PushSubscription extends BaseApi if (!Subscription::exists($application['id'], $uid)) { $this->logger->info('Subscription not found', ['application-id' => $application['id'], 'uid' => $uid]); - $this->errorFac->RecordNotFound(); + $this->errorFactory->RecordNotFound(); } $this->logger->info('Fetch subscription', ['application-id' => $application['id'], 'uid' => $uid]); diff --git a/src/Module/Api/Mastodon/Reports.php b/src/Module/Api/Mastodon/Reports.php index cc9193620..2706aefe3 100644 --- a/src/Module/Api/Mastodon/Reports.php +++ b/src/Module/Api/Mastodon/Reports.php @@ -41,9 +41,9 @@ class Reports extends BaseApi /** @var \Friendica\Moderation\Repository\Report */ private $reportRepo; - public function __construct(\Friendica\Moderation\Repository\Report $reportRepo, \Friendica\Moderation\Factory\Report $reportFactory, App $app, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, ApiResponse $response, array $server, array $parameters = []) + public function __construct(\Friendica\Moderation\Repository\Report $reportRepo, \Friendica\Moderation\Factory\Report $reportFactory, \Friendica\Factory\Api\Mastodon\Error $errorFactory, App $app, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, ApiResponse $response, array $server, array $parameters = []) { - parent::__construct($app, $l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters); + parent::__construct($errorFactory, $app, $l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters); $this->reportFactory = $reportFactory; $this->reportRepo = $reportRepo; diff --git a/src/Module/Api/Twitter/ContactEndpoint.php b/src/Module/Api/Twitter/ContactEndpoint.php index a338d3ce7..1ff9c7833 100644 --- a/src/Module/Api/Twitter/ContactEndpoint.php +++ b/src/Module/Api/Twitter/ContactEndpoint.php @@ -38,9 +38,9 @@ abstract class ContactEndpoint extends BaseApi const DEFAULT_COUNT = 20; const MAX_COUNT = 200; - public function __construct(App $app, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, ApiResponse $response, array $server, array $parameters = []) + public function __construct(\Friendica\Factory\Api\Mastodon\Error $errorFactory, App $app, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, ApiResponse $response, array $server, array $parameters = []) { - parent::__construct($app, $l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters); + parent::__construct($errorFactory, $app, $l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters); self::checkAllowedScope(self::SCOPE_READ); } diff --git a/src/Module/Api/Twitter/DirectMessages/Destroy.php b/src/Module/Api/Twitter/DirectMessages/Destroy.php index 1c07b4e47..7108263ba 100644 --- a/src/Module/Api/Twitter/DirectMessages/Destroy.php +++ b/src/Module/Api/Twitter/DirectMessages/Destroy.php @@ -41,9 +41,9 @@ class Destroy extends BaseApi /** @var Database */ private $dba; - public function __construct(Database $dba, App $app, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, ApiResponse $response, array $server, array $parameters = []) + public function __construct(Database $dba, \Friendica\Factory\Api\Mastodon\Error $errorFactory, App $app, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, ApiResponse $response, array $server, array $parameters = []) { - parent::__construct($app, $l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters); + parent::__construct($errorFactory, $app, $l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters); $this->dba = $dba; } diff --git a/src/Module/Api/Twitter/DirectMessages/NewDM.php b/src/Module/Api/Twitter/DirectMessages/NewDM.php index 30be41be6..d111f98cb 100644 --- a/src/Module/Api/Twitter/DirectMessages/NewDM.php +++ b/src/Module/Api/Twitter/DirectMessages/NewDM.php @@ -46,9 +46,9 @@ class NewDM extends BaseApi /** @var DirectMessage */ private $directMessage; - public function __construct(DirectMessage $directMessage, Database $dba, App $app, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, ApiResponse $response, array $server, array $parameters = []) + public function __construct(DirectMessage $directMessage, Database $dba, \Friendica\Factory\Api\Mastodon\Error $errorFactory, App $app, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, ApiResponse $response, array $server, array $parameters = []) { - parent::__construct($app, $l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters); + parent::__construct($errorFactory, $app, $l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters); $this->dba = $dba; $this->directMessage = $directMessage; diff --git a/src/Module/Api/Twitter/DirectMessagesEndpoint.php b/src/Module/Api/Twitter/DirectMessagesEndpoint.php index 6de21281d..d1c713289 100644 --- a/src/Module/Api/Twitter/DirectMessagesEndpoint.php +++ b/src/Module/Api/Twitter/DirectMessagesEndpoint.php @@ -40,9 +40,9 @@ abstract class DirectMessagesEndpoint extends BaseApi /** @var DirectMessage */ private $directMessage; - public function __construct(DirectMessage $directMessage, Database $dba, App $app, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, ApiResponse $response, array $server, array $parameters = []) + public function __construct(DirectMessage $directMessage, Database $dba, \Friendica\Factory\Api\Mastodon\Error $errorFactory, App $app, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, ApiResponse $response, array $server, array $parameters = []) { - parent::__construct($app, $l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters); + parent::__construct($errorFactory, $app, $l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters); $this->dba = $dba; $this->directMessage = $directMessage; diff --git a/src/Module/Api/Twitter/Friendships/Destroy.php b/src/Module/Api/Twitter/Friendships/Destroy.php index 322d02502..05cc30488 100644 --- a/src/Module/Api/Twitter/Friendships/Destroy.php +++ b/src/Module/Api/Twitter/Friendships/Destroy.php @@ -45,9 +45,9 @@ class Destroy extends ContactEndpoint /** @var TwitterUser */ private $twitterUser; - public function __construct(App $app, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, ApiResponse $response, TwitterUser $twitterUser, array $server, array $parameters = []) + public function __construct(\Friendica\Factory\Api\Mastodon\Error $errorFactory, App $app, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, ApiResponse $response, TwitterUser $twitterUser, array $server, array $parameters = []) { - parent::__construct($app, $l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters); + parent::__construct($errorFactory, $app, $l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters); $this->twitterUser = $twitterUser; } diff --git a/src/Module/Api/Twitter/Lists/Create.php b/src/Module/Api/Twitter/Lists/Create.php index 4943d861a..ed4650adc 100644 --- a/src/Module/Api/Twitter/Lists/Create.php +++ b/src/Module/Api/Twitter/Lists/Create.php @@ -46,9 +46,9 @@ class Create extends BaseApi /** @var Database */ private $dba; - public function __construct(Database $dba, FriendicaCircle $friendicaCircle, App $app, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, ApiResponse $response, array $server, array $parameters = []) + public function __construct(Database $dba, FriendicaCircle $friendicaCircle, \Friendica\Factory\Api\Mastodon\Error $errorFactory, App $app, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, ApiResponse $response, array $server, array $parameters = []) { - parent::__construct($app, $l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters); + parent::__construct($errorFactory, $app, $l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters); $this->dba = $dba; $this->friendicaCircle = $friendicaCircle; diff --git a/src/Module/Api/Twitter/Lists/Destroy.php b/src/Module/Api/Twitter/Lists/Destroy.php index a249e4a81..0e13ac9b2 100644 --- a/src/Module/Api/Twitter/Lists/Destroy.php +++ b/src/Module/Api/Twitter/Lists/Destroy.php @@ -46,9 +46,9 @@ class Destroy extends BaseApi /** @var Database */ private $dba; - public function __construct(Database $dba, FriendicaCirle $friendicaCircle, App $app, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, ApiResponse $response, array $server, array $parameters = []) + public function __construct(Database $dba, FriendicaCirle $friendicaCircle, \Friendica\Factory\Api\Mastodon\Error $errorFactory, App $app, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, ApiResponse $response, array $server, array $parameters = []) { - parent::__construct($app, $l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters); + parent::__construct($errorFactory, $app, $l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters); $this->dba = $dba; $this->friendicaCircle = $friendicaCircle; diff --git a/src/Module/Api/Twitter/Lists/Ownership.php b/src/Module/Api/Twitter/Lists/Ownership.php index aad152c3a..11b85c51a 100644 --- a/src/Module/Api/Twitter/Lists/Ownership.php +++ b/src/Module/Api/Twitter/Lists/Ownership.php @@ -44,9 +44,9 @@ class Ownership extends BaseApi /** @var Database */ private $dba; - public function __construct(Database $dba, FriendicaCircle $friendicaCircle, App $app, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, ApiResponse $response, array $server, array $parameters = []) + public function __construct(Database $dba, FriendicaCircle $friendicaCircle, \Friendica\Factory\Api\Mastodon\Error $errorFactory, App $app, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, ApiResponse $response, array $server, array $parameters = []) { - parent::__construct($app, $l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters); + parent::__construct($errorFactory, $app, $l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters); $this->dba = $dba; $this->friendicaCircle = $friendicaCircle; diff --git a/src/Module/Api/Twitter/Lists/Statuses.php b/src/Module/Api/Twitter/Lists/Statuses.php index 154db631d..6e12f5908 100644 --- a/src/Module/Api/Twitter/Lists/Statuses.php +++ b/src/Module/Api/Twitter/Lists/Statuses.php @@ -48,9 +48,9 @@ class Statuses extends BaseApi /** @var Database */ private $dba; - public function __construct(Database $dba, TwitterStatus $twitterStatus, App $app, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, ApiResponse $response, array $server, array $parameters = []) + public function __construct(Database $dba, TwitterStatus $twitterStatus, \Friendica\Factory\Api\Mastodon\Error $errorFactory, App $app, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, ApiResponse $response, array $server, array $parameters = []) { - parent::__construct($app, $l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters); + parent::__construct($errorFactory, $app, $l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters); $this->dba = $dba; $this->twitterStatus = $twitterStatus; diff --git a/src/Module/Api/Twitter/Lists/Update.php b/src/Module/Api/Twitter/Lists/Update.php index be98f8265..17fd4636b 100644 --- a/src/Module/Api/Twitter/Lists/Update.php +++ b/src/Module/Api/Twitter/Lists/Update.php @@ -46,9 +46,9 @@ class Update extends BaseApi /** @var Database */ private $dba; - public function __construct(Database $dba, FriendicaCircle $friendicaCircle, App $app, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, ApiResponse $response, array $server, array $parameters = []) + public function __construct(Database $dba, FriendicaCircle $friendicaCircle, \Friendica\Factory\Api\Mastodon\Error $errorFactory, App $app, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, ApiResponse $response, array $server, array $parameters = []) { - parent::__construct($app, $l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters); + parent::__construct($errorFactory, $app, $l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters); $this->dba = $dba; $this->friendicaCircle = $friendicaCircle; diff --git a/src/Module/BaseApi.php b/src/Module/BaseApi.php index c73f90aba..d8bf65732 100644 --- a/src/Module/BaseApi.php +++ b/src/Module/BaseApi.php @@ -27,7 +27,6 @@ use Friendica\App\Router; use Friendica\BaseModule; use Friendica\Core\L10n; use Friendica\Core\Logger; -use Friendica\Core\System; use Friendica\Database\DBA; use Friendica\DI; use Friendica\Model\Contact; @@ -37,6 +36,7 @@ use Friendica\Model\User; use Friendica\Module\Api\ApiResponse; use Friendica\Module\Special\HTTPException as ModuleHTTPException; use Friendica\Network\HTTPException; +use Friendica\Object\Api\Mastodon\Error; use Friendica\Object\Api\Mastodon\Status; use Friendica\Object\Api\Mastodon\TimelineOrderByTypes; use Friendica\Security\BasicAuth; @@ -71,11 +71,15 @@ class BaseApi extends BaseModule /** @var ApiResponse */ protected $response; - public function __construct(App $app, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, ApiResponse $response, array $server, array $parameters = []) + /** @var \Friendica\Factory\Api\Mastodon\Error */ + protected $errorFactory; + + public function __construct(\Friendica\Factory\Api\Mastodon\Error $errorFactory, App $app, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, ApiResponse $response, array $server, array $parameters = []) { parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters); - $this->app = $app; + $this->app = $app; + $this->errorFactory = $errorFactory; } /** @@ -515,4 +519,16 @@ class BaseApi extends BaseModule return null; } + + /** + * @param int $errorno + * @param Error $error + * @return void + * @throws HTTPException\InternalServerErrorException + */ + protected function logErrorAndJsonExit(int $errorno, Error $error) + { + $this->logger->info('API Error', ['no' => $errorno, 'error' => $error->toArray(), 'method' => $this->args->getMethod(), 'command' => $this->args->getQueryString(), 'user-agent' => $this->server['HTTP_USER_AGENT'] ?? '']); + $this->jsonError(403, $error->toArray()); + } } From 9e7161071153c7ec5e4df5711521cbcaabcbc353 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Wed, 11 Oct 2023 09:30:42 -0400 Subject: [PATCH 02/10] Make BaseApi->checkAllowedScope into an object method - It isn't called from static contexts anymore --- src/Module/ActivityPub/Inbox.php | 2 +- src/Module/ActivityPub/Outbox.php | 2 +- src/Module/ActivityPub/Whoami.php | 2 +- src/Module/Api/Friendica/Activity.php | 2 +- src/Module/Api/Friendica/Circle/Create.php | 2 +- src/Module/Api/Friendica/Circle/Delete.php | 2 +- src/Module/Api/Friendica/Circle/Show.php | 2 +- src/Module/Api/Friendica/Circle/Update.php | 2 +- src/Module/Api/Friendica/DirectMessages/Search.php | 2 +- src/Module/Api/Friendica/DirectMessages/Setseen.php | 2 +- src/Module/Api/Friendica/Events/Create.php | 2 +- src/Module/Api/Friendica/Events/Delete.php | 2 +- src/Module/Api/Friendica/Events/Index.php | 2 +- src/Module/Api/Friendica/Notification.php | 2 +- src/Module/Api/Friendica/Notification/Seen.php | 2 +- src/Module/Api/Friendica/Photo.php | 2 +- src/Module/Api/Friendica/Photo/Create.php | 2 +- src/Module/Api/Friendica/Photo/Lists.php | 2 +- src/Module/Api/Friendica/Photo/Update.php | 2 +- src/Module/Api/Friendica/Photoalbum/Delete.php | 2 +- src/Module/Api/Friendica/Photoalbum/Index.php | 2 +- src/Module/Api/Friendica/Photoalbum/Show.php | 2 +- src/Module/Api/Friendica/Photoalbum/Update.php | 2 +- src/Module/Api/Friendica/Profile/Show.php | 2 +- src/Module/Api/Friendica/Statuses/Dislike.php | 2 +- src/Module/Api/Friendica/Statuses/Undislike.php | 2 +- src/Module/Api/GNUSocial/Statusnet/Conversation.php | 2 +- src/Module/Api/Mastodon/Accounts/Block.php | 2 +- src/Module/Api/Mastodon/Accounts/FeaturedTags.php | 2 +- src/Module/Api/Mastodon/Accounts/Follow.php | 2 +- src/Module/Api/Mastodon/Accounts/Followers.php | 2 +- src/Module/Api/Mastodon/Accounts/Following.php | 2 +- src/Module/Api/Mastodon/Accounts/IdentityProofs.php | 2 +- src/Module/Api/Mastodon/Accounts/Lists.php | 2 +- src/Module/Api/Mastodon/Accounts/Mute.php | 2 +- src/Module/Api/Mastodon/Accounts/Note.php | 2 +- src/Module/Api/Mastodon/Accounts/Relationships.php | 2 +- src/Module/Api/Mastodon/Accounts/Search.php | 2 +- src/Module/Api/Mastodon/Accounts/Unblock.php | 2 +- src/Module/Api/Mastodon/Accounts/Unfollow.php | 2 +- src/Module/Api/Mastodon/Accounts/Unmute.php | 2 +- src/Module/Api/Mastodon/Accounts/UpdateCredentials.php | 2 +- src/Module/Api/Mastodon/Accounts/VerifyCredentials.php | 2 +- src/Module/Api/Mastodon/Announcements.php | 2 +- src/Module/Api/Mastodon/Apps/VerifyCredentials.php | 2 +- src/Module/Api/Mastodon/Blocks.php | 2 +- src/Module/Api/Mastodon/Bookmarks.php | 2 +- src/Module/Api/Mastodon/Conversations.php | 4 ++-- src/Module/Api/Mastodon/Conversations/Read.php | 2 +- src/Module/Api/Mastodon/Favourited.php | 2 +- src/Module/Api/Mastodon/Filters.php | 4 ++-- src/Module/Api/Mastodon/FollowRequests.php | 4 ++-- src/Module/Api/Mastodon/FollowedTags.php | 2 +- src/Module/Api/Mastodon/Lists.php | 6 +++--- src/Module/Api/Mastodon/Lists/Accounts.php | 6 +++--- src/Module/Api/Mastodon/Markers.php | 4 ++-- src/Module/Api/Mastodon/Media.php | 6 +++--- src/Module/Api/Mastodon/Mutes.php | 2 +- src/Module/Api/Mastodon/Notifications.php | 2 +- src/Module/Api/Mastodon/Notifications/Clear.php | 2 +- src/Module/Api/Mastodon/Notifications/Dismiss.php | 2 +- src/Module/Api/Mastodon/Preferences.php | 2 +- src/Module/Api/Mastodon/PushSubscription.php | 8 ++++---- src/Module/Api/Mastodon/Reports.php | 2 +- src/Module/Api/Mastodon/ScheduledStatuses.php | 6 +++--- src/Module/Api/Mastodon/Search.php | 2 +- src/Module/Api/Mastodon/Statuses.php | 6 +++--- src/Module/Api/Mastodon/Statuses/Bookmark.php | 2 +- src/Module/Api/Mastodon/Statuses/Favourite.php | 2 +- src/Module/Api/Mastodon/Statuses/Mute.php | 2 +- src/Module/Api/Mastodon/Statuses/Pin.php | 2 +- src/Module/Api/Mastodon/Statuses/Reblog.php | 2 +- src/Module/Api/Mastodon/Statuses/Source.php | 2 +- src/Module/Api/Mastodon/Statuses/Unbookmark.php | 2 +- src/Module/Api/Mastodon/Statuses/Unfavourite.php | 2 +- src/Module/Api/Mastodon/Statuses/Unmute.php | 2 +- src/Module/Api/Mastodon/Statuses/Unpin.php | 2 +- src/Module/Api/Mastodon/Statuses/Unreblog.php | 2 +- src/Module/Api/Mastodon/Suggestions.php | 2 +- src/Module/Api/Mastodon/Tags.php | 2 +- src/Module/Api/Mastodon/Tags/Follow.php | 2 +- src/Module/Api/Mastodon/Tags/Unfollow.php | 2 +- src/Module/Api/Mastodon/Timelines/Direct.php | 2 +- src/Module/Api/Mastodon/Timelines/Home.php | 2 +- src/Module/Api/Mastodon/Timelines/ListTimeline.php | 2 +- src/Module/Api/Mastodon/Timelines/Tag.php | 2 +- src/Module/Api/Twitter/Account/UpdateProfile.php | 2 +- src/Module/Api/Twitter/Account/UpdateProfileImage.php | 2 +- src/Module/Api/Twitter/Account/VerifyCredentials.php | 2 +- src/Module/Api/Twitter/Blocks/Ids.php | 2 +- src/Module/Api/Twitter/Blocks/Lists.php | 2 +- src/Module/Api/Twitter/ContactEndpoint.php | 2 +- src/Module/Api/Twitter/DirectMessages/All.php | 2 +- src/Module/Api/Twitter/DirectMessages/Conversation.php | 2 +- src/Module/Api/Twitter/DirectMessages/Destroy.php | 2 +- src/Module/Api/Twitter/DirectMessages/Inbox.php | 2 +- src/Module/Api/Twitter/DirectMessages/NewDM.php | 2 +- src/Module/Api/Twitter/DirectMessages/Sent.php | 2 +- src/Module/Api/Twitter/Favorites.php | 2 +- src/Module/Api/Twitter/Favorites/Create.php | 2 +- src/Module/Api/Twitter/Favorites/Destroy.php | 2 +- src/Module/Api/Twitter/Followers/Ids.php | 2 +- src/Module/Api/Twitter/Followers/Lists.php | 2 +- src/Module/Api/Twitter/Friends/Ids.php | 2 +- src/Module/Api/Twitter/Friends/Lists.php | 2 +- src/Module/Api/Twitter/Friendships/Destroy.php | 2 +- src/Module/Api/Twitter/Friendships/Incoming.php | 2 +- src/Module/Api/Twitter/Friendships/Show.php | 2 +- src/Module/Api/Twitter/Lists/Create.php | 2 +- src/Module/Api/Twitter/Lists/Destroy.php | 2 +- src/Module/Api/Twitter/Lists/Lists.php | 2 +- src/Module/Api/Twitter/Lists/Ownership.php | 2 +- src/Module/Api/Twitter/Lists/Statuses.php | 2 +- src/Module/Api/Twitter/Lists/Update.php | 2 +- src/Module/Api/Twitter/Media/Metadata/Create.php | 2 +- src/Module/Api/Twitter/Media/Upload.php | 2 +- src/Module/Api/Twitter/SavedSearches.php | 2 +- src/Module/Api/Twitter/Search/Tweets.php | 2 +- src/Module/Api/Twitter/Statuses/Destroy.php | 2 +- src/Module/Api/Twitter/Statuses/HomeTimeline.php | 2 +- src/Module/Api/Twitter/Statuses/Mentions.php | 2 +- .../Api/Twitter/Statuses/NetworkPublicTimeline.php | 2 +- src/Module/Api/Twitter/Statuses/PublicTimeline.php | 2 +- src/Module/Api/Twitter/Statuses/Retweet.php | 2 +- src/Module/Api/Twitter/Statuses/Show.php | 2 +- src/Module/Api/Twitter/Statuses/Update.php | 2 +- src/Module/Api/Twitter/Statuses/UserTimeline.php | 2 +- src/Module/Api/Twitter/Users/Lookup.php | 2 +- src/Module/Api/Twitter/Users/Search.php | 2 +- src/Module/Api/Twitter/Users/Show.php | 2 +- src/Module/BaseApi.php | 10 +++++----- 131 files changed, 152 insertions(+), 152 deletions(-) diff --git a/src/Module/ActivityPub/Inbox.php b/src/Module/ActivityPub/Inbox.php index 10e4c9db0..ee9d098da 100644 --- a/src/Module/ActivityPub/Inbox.php +++ b/src/Module/ActivityPub/Inbox.php @@ -45,7 +45,7 @@ class Inbox extends BaseApi protected function rawContent(array $request = []) { - self::checkAllowedScope(self::SCOPE_READ); + $this->checkAllowedScope(self::SCOPE_READ); $uid = self::getCurrentUserID(); $page = $request['page'] ?? null; diff --git a/src/Module/ActivityPub/Outbox.php b/src/Module/ActivityPub/Outbox.php index 3dc0f00e7..e637a8e55 100644 --- a/src/Module/ActivityPub/Outbox.php +++ b/src/Module/ActivityPub/Outbox.php @@ -58,7 +58,7 @@ class Outbox extends BaseApi protected function post(array $request = []) { - self::checkAllowedScope(self::SCOPE_WRITE); + $this->checkAllowedScope(self::SCOPE_WRITE); $uid = self::getCurrentUserID(); $postdata = Network::postdata(); diff --git a/src/Module/ActivityPub/Whoami.php b/src/Module/ActivityPub/Whoami.php index 67128d99c..d78f6e83f 100644 --- a/src/Module/ActivityPub/Whoami.php +++ b/src/Module/ActivityPub/Whoami.php @@ -38,7 +38,7 @@ class Whoami extends BaseApi */ protected function rawContent(array $request = []) { - self::checkAllowedScope(self::SCOPE_READ); + $this->checkAllowedScope(self::SCOPE_READ); $uid = self::getCurrentUserID(); $owner = User::getOwnerDataById($uid); diff --git a/src/Module/Api/Friendica/Activity.php b/src/Module/Api/Friendica/Activity.php index d8edfd1a3..e0935c8ef 100644 --- a/src/Module/Api/Friendica/Activity.php +++ b/src/Module/Api/Friendica/Activity.php @@ -44,7 +44,7 @@ class Activity extends BaseApi { protected function post(array $request = []) { - self::checkAllowedScope(self::SCOPE_WRITE); + $this->checkAllowedScope(self::SCOPE_WRITE); $uid = self::getCurrentUserID(); $request = $this->getRequest([ diff --git a/src/Module/Api/Friendica/Circle/Create.php b/src/Module/Api/Friendica/Circle/Create.php index 8998dbdd9..ab38950ae 100644 --- a/src/Module/Api/Friendica/Circle/Create.php +++ b/src/Module/Api/Friendica/Circle/Create.php @@ -34,7 +34,7 @@ class Create extends BaseApi { protected function post(array $request = []) { - BaseApi::checkAllowedScope(BaseApi::SCOPE_WRITE); + $this->checkAllowedScope(BaseApi::SCOPE_WRITE); $uid = BaseApi::getCurrentUserID(); // params diff --git a/src/Module/Api/Friendica/Circle/Delete.php b/src/Module/Api/Friendica/Circle/Delete.php index 3bbe5bc7b..3e40ecf6d 100644 --- a/src/Module/Api/Friendica/Circle/Delete.php +++ b/src/Module/Api/Friendica/Circle/Delete.php @@ -34,7 +34,7 @@ class Delete extends BaseApi { protected function post(array $request = []) { - self::checkAllowedScope(self::SCOPE_WRITE); + $this->checkAllowedScope(self::SCOPE_WRITE); $uid = self::getCurrentUserID(); $request = $this->getRequest([ diff --git a/src/Module/Api/Friendica/Circle/Show.php b/src/Module/Api/Friendica/Circle/Show.php index c6936dbe3..c9e6f981d 100644 --- a/src/Module/Api/Friendica/Circle/Show.php +++ b/src/Module/Api/Friendica/Circle/Show.php @@ -35,7 +35,7 @@ class Show extends BaseApi { protected function rawContent(array $request = []) { - BaseApi::checkAllowedScope(BaseApi::SCOPE_READ); + $this->checkAllowedScope(BaseApi::SCOPE_READ); $uid = BaseApi::getCurrentUserID(); $type = $this->getRequestValue($this->parameters, 'extension', 'json'); diff --git a/src/Module/Api/Friendica/Circle/Update.php b/src/Module/Api/Friendica/Circle/Update.php index d43082c79..b44d14290 100644 --- a/src/Module/Api/Friendica/Circle/Update.php +++ b/src/Module/Api/Friendica/Circle/Update.php @@ -35,7 +35,7 @@ class Update extends BaseApi { protected function post(array $request = []) { - BaseApi::checkAllowedScope(BaseApi::SCOPE_WRITE); + $this->checkAllowedScope(BaseApi::SCOPE_WRITE); $uid = BaseApi::getCurrentUserID(); // params diff --git a/src/Module/Api/Friendica/DirectMessages/Search.php b/src/Module/Api/Friendica/DirectMessages/Search.php index 04c7a405b..dd83e6185 100644 --- a/src/Module/Api/Friendica/DirectMessages/Search.php +++ b/src/Module/Api/Friendica/DirectMessages/Search.php @@ -54,7 +54,7 @@ class Search extends BaseApi protected function rawContent(array $request = []) { - self::checkAllowedScope(self::SCOPE_READ); + $this->checkAllowedScope(self::SCOPE_READ); $uid = self::getCurrentUserID(); $request = $this->getRequest([ diff --git a/src/Module/Api/Friendica/DirectMessages/Setseen.php b/src/Module/Api/Friendica/DirectMessages/Setseen.php index aa9fc0dac..eff809685 100644 --- a/src/Module/Api/Friendica/DirectMessages/Setseen.php +++ b/src/Module/Api/Friendica/DirectMessages/Setseen.php @@ -32,7 +32,7 @@ class Setseen extends BaseApi { protected function post(array $request = []) { - self::checkAllowedScope(self::SCOPE_WRITE); + $this->checkAllowedScope(self::SCOPE_WRITE); $uid = self::getCurrentUserID(); $request = $this->getRequest([ diff --git a/src/Module/Api/Friendica/Events/Create.php b/src/Module/Api/Friendica/Events/Create.php index edc1c5936..57bfe15b8 100644 --- a/src/Module/Api/Friendica/Events/Create.php +++ b/src/Module/Api/Friendica/Events/Create.php @@ -40,7 +40,7 @@ class Create extends BaseApi { protected function post(array $request = []) { - BaseApi::checkAllowedScope(BaseApi::SCOPE_WRITE); + $this->checkAllowedScope(BaseApi::SCOPE_WRITE); $uid = BaseApi::getCurrentUserID(); // params diff --git a/src/Module/Api/Friendica/Events/Delete.php b/src/Module/Api/Friendica/Events/Delete.php index b148c94e3..94d040aa1 100644 --- a/src/Module/Api/Friendica/Events/Delete.php +++ b/src/Module/Api/Friendica/Events/Delete.php @@ -35,7 +35,7 @@ class Delete extends BaseApi { protected function post(array $request = []) { - self::checkAllowedScope(self::SCOPE_WRITE); + $this->checkAllowedScope(self::SCOPE_WRITE); $uid = self::getCurrentUserID(); $request = $this->getRequest([ diff --git a/src/Module/Api/Friendica/Events/Index.php b/src/Module/Api/Friendica/Events/Index.php index a0986d8b0..dd349205a 100644 --- a/src/Module/Api/Friendica/Events/Index.php +++ b/src/Module/Api/Friendica/Events/Index.php @@ -34,7 +34,7 @@ class Index extends BaseApi { protected function rawContent(array $request = []) { - self::checkAllowedScope(self::SCOPE_READ); + $this->checkAllowedScope(self::SCOPE_READ); $uid = self::getCurrentUserID(); $request = $this->getRequest([ diff --git a/src/Module/Api/Friendica/Notification.php b/src/Module/Api/Friendica/Notification.php index f61d3451c..896b719d7 100644 --- a/src/Module/Api/Friendica/Notification.php +++ b/src/Module/Api/Friendica/Notification.php @@ -33,7 +33,7 @@ class Notification extends BaseApi { protected function rawContent(array $request = []) { - self::checkAllowedScope(self::SCOPE_READ); + $this->checkAllowedScope(self::SCOPE_READ); $uid = self::getCurrentUserID(); $Notifies = DI::notify()->selectAllForUser($uid, 50); diff --git a/src/Module/Api/Friendica/Notification/Seen.php b/src/Module/Api/Friendica/Notification/Seen.php index c0c50dbe7..5699b1588 100644 --- a/src/Module/Api/Friendica/Notification/Seen.php +++ b/src/Module/Api/Friendica/Notification/Seen.php @@ -40,7 +40,7 @@ class Seen extends BaseApi { protected function post(array $request = []) { - BaseApi::checkAllowedScope(BaseApi::SCOPE_WRITE); + $this->checkAllowedScope(BaseApi::SCOPE_WRITE); $uid = BaseApi::getCurrentUserID(); if (DI::args()->getArgc() !== 4) { diff --git a/src/Module/Api/Friendica/Photo.php b/src/Module/Api/Friendica/Photo.php index 3653a97fd..d9031a755 100644 --- a/src/Module/Api/Friendica/Photo.php +++ b/src/Module/Api/Friendica/Photo.php @@ -46,7 +46,7 @@ class Photo extends BaseApi protected function rawContent(array $request = []) { - BaseApi::checkAllowedScope(BaseApi::SCOPE_READ); + $this->checkAllowedScope(BaseApi::SCOPE_READ); $uid = BaseApi::getCurrentUserID(); $type = $this->getRequestValue($this->parameters, 'extension', 'json'); diff --git a/src/Module/Api/Friendica/Photo/Create.php b/src/Module/Api/Friendica/Photo/Create.php index b08b37411..771a35c2c 100644 --- a/src/Module/Api/Friendica/Photo/Create.php +++ b/src/Module/Api/Friendica/Photo/Create.php @@ -50,7 +50,7 @@ class Create extends BaseApi protected function post(array $request = []) { - BaseApi::checkAllowedScope(BaseApi::SCOPE_WRITE); + $this->checkAllowedScope(BaseApi::SCOPE_WRITE); $uid = BaseApi::getCurrentUserID(); $type = $this->getRequestValue($this->parameters, 'extension', 'json'); diff --git a/src/Module/Api/Friendica/Photo/Lists.php b/src/Module/Api/Friendica/Photo/Lists.php index 8a0a4d7eb..b8ba72514 100644 --- a/src/Module/Api/Friendica/Photo/Lists.php +++ b/src/Module/Api/Friendica/Photo/Lists.php @@ -52,7 +52,7 @@ class Lists extends BaseApi protected function rawContent(array $request = []) { - BaseApi::checkAllowedScope(BaseApi::SCOPE_READ); + $this->checkAllowedScope(BaseApi::SCOPE_READ); $uid = BaseApi::getCurrentUserID(); $type = $this->getRequestValue($this->parameters, 'extension', 'json'); diff --git a/src/Module/Api/Friendica/Photo/Update.php b/src/Module/Api/Friendica/Photo/Update.php index 1e40f752c..d9441bd19 100644 --- a/src/Module/Api/Friendica/Photo/Update.php +++ b/src/Module/Api/Friendica/Photo/Update.php @@ -50,7 +50,7 @@ class Update extends BaseApi protected function post(array $request = []) { - BaseApi::checkAllowedScope(BaseApi::SCOPE_WRITE); + $this->checkAllowedScope(BaseApi::SCOPE_WRITE); $uid = BaseApi::getCurrentUserID(); $type = $this->getRequestValue($this->parameters, 'extension', 'json'); diff --git a/src/Module/Api/Friendica/Photoalbum/Delete.php b/src/Module/Api/Friendica/Photoalbum/Delete.php index 023d96797..2058edff5 100644 --- a/src/Module/Api/Friendica/Photoalbum/Delete.php +++ b/src/Module/Api/Friendica/Photoalbum/Delete.php @@ -36,7 +36,7 @@ class Delete extends BaseApi { protected function post(array $request = []) { - self::checkAllowedScope(self::SCOPE_WRITE); + $this->checkAllowedScope(self::SCOPE_WRITE); $uid = self::getCurrentUserID(); $request = $this->getRequest([ diff --git a/src/Module/Api/Friendica/Photoalbum/Index.php b/src/Module/Api/Friendica/Photoalbum/Index.php index af294585e..12de0df41 100644 --- a/src/Module/Api/Friendica/Photoalbum/Index.php +++ b/src/Module/Api/Friendica/Photoalbum/Index.php @@ -33,7 +33,7 @@ class Index extends BaseApi { protected function rawContent(array $request = []) { - self::checkAllowedScope(self::SCOPE_READ); + $this->checkAllowedScope(self::SCOPE_READ); $uid = self::getCurrentUserID(); $albums = Photo::getAlbums($uid); diff --git a/src/Module/Api/Friendica/Photoalbum/Show.php b/src/Module/Api/Friendica/Photoalbum/Show.php index 8e6d77ae5..66cd56cf0 100644 --- a/src/Module/Api/Friendica/Photoalbum/Show.php +++ b/src/Module/Api/Friendica/Photoalbum/Show.php @@ -52,7 +52,7 @@ class Show extends BaseApi protected function rawContent(array $request = []) { - BaseApi::checkAllowedScope(BaseApi::SCOPE_READ); + $this->checkAllowedScope(BaseApi::SCOPE_READ); $uid = BaseApi::getCurrentUserID(); $type = $this->getRequestValue($this->parameters, 'extension', 'json'); $request = $this->getRequest([ diff --git a/src/Module/Api/Friendica/Photoalbum/Update.php b/src/Module/Api/Friendica/Photoalbum/Update.php index cba99b436..2ea498c39 100644 --- a/src/Module/Api/Friendica/Photoalbum/Update.php +++ b/src/Module/Api/Friendica/Photoalbum/Update.php @@ -34,7 +34,7 @@ class Update extends BaseApi { protected function post(array $request = []) { - self::checkAllowedScope(self::SCOPE_WRITE); + $this->checkAllowedScope(self::SCOPE_WRITE); $uid = self::getCurrentUserID(); $request = $this->getRequest([ diff --git a/src/Module/Api/Friendica/Profile/Show.php b/src/Module/Api/Friendica/Profile/Show.php index 6aa2e8b66..8e68421f4 100644 --- a/src/Module/Api/Friendica/Profile/Show.php +++ b/src/Module/Api/Friendica/Profile/Show.php @@ -36,7 +36,7 @@ class Show extends BaseApi { protected function rawContent(array $request = []) { - self::checkAllowedScope(self::SCOPE_READ); + $this->checkAllowedScope(self::SCOPE_READ); $uid = self::getCurrentUserID(); // retrieve general information about profiles for user diff --git a/src/Module/Api/Friendica/Statuses/Dislike.php b/src/Module/Api/Friendica/Statuses/Dislike.php index 01bfeba90..5491bf189 100644 --- a/src/Module/Api/Friendica/Statuses/Dislike.php +++ b/src/Module/Api/Friendica/Statuses/Dislike.php @@ -35,7 +35,7 @@ class Dislike extends BaseApi { protected function post(array $request = []) { - self::checkAllowedScope(self::SCOPE_WRITE); + $this->checkAllowedScope(self::SCOPE_WRITE); $uid = self::getCurrentUserID(); if (empty($this->parameters['id'])) { diff --git a/src/Module/Api/Friendica/Statuses/Undislike.php b/src/Module/Api/Friendica/Statuses/Undislike.php index 4ede1fd94..a646045e5 100644 --- a/src/Module/Api/Friendica/Statuses/Undislike.php +++ b/src/Module/Api/Friendica/Statuses/Undislike.php @@ -35,7 +35,7 @@ class Undislike extends BaseApi { protected function post(array $request = []) { - self::checkAllowedScope(self::SCOPE_WRITE); + $this->checkAllowedScope(self::SCOPE_WRITE); $uid = self::getCurrentUserID(); if (empty($this->parameters['id'])) { diff --git a/src/Module/Api/GNUSocial/Statusnet/Conversation.php b/src/Module/Api/GNUSocial/Statusnet/Conversation.php index 522b237b6..b7dff6f8c 100644 --- a/src/Module/Api/GNUSocial/Statusnet/Conversation.php +++ b/src/Module/Api/GNUSocial/Statusnet/Conversation.php @@ -37,7 +37,7 @@ class Conversation extends BaseApi { protected function rawContent(array $request = []) { - BaseApi::checkAllowedScope(BaseApi::SCOPE_READ); + $this->checkAllowedScope(BaseApi::SCOPE_READ); $uid = BaseApi::getCurrentUserID(); // params diff --git a/src/Module/Api/Mastodon/Accounts/Block.php b/src/Module/Api/Mastodon/Accounts/Block.php index c4afb74a3..1ddafda56 100644 --- a/src/Module/Api/Mastodon/Accounts/Block.php +++ b/src/Module/Api/Mastodon/Accounts/Block.php @@ -34,7 +34,7 @@ class Block extends BaseApi { protected function post(array $request = []) { - self::checkAllowedScope(self::SCOPE_FOLLOW); + $this->checkAllowedScope(self::SCOPE_FOLLOW); $uid = self::getCurrentUserID(); if (empty($this->parameters['id'])) { diff --git a/src/Module/Api/Mastodon/Accounts/FeaturedTags.php b/src/Module/Api/Mastodon/Accounts/FeaturedTags.php index 52c0c2831..c57b63cf6 100644 --- a/src/Module/Api/Mastodon/Accounts/FeaturedTags.php +++ b/src/Module/Api/Mastodon/Accounts/FeaturedTags.php @@ -34,7 +34,7 @@ class FeaturedTags extends BaseApi */ protected function rawContent(array $request = []) { - self::checkAllowedScope(self::SCOPE_READ); + $this->checkAllowedScope(self::SCOPE_READ); $this->jsonExit([]); } diff --git a/src/Module/Api/Mastodon/Accounts/Follow.php b/src/Module/Api/Mastodon/Accounts/Follow.php index ad290f5ab..a666f2f91 100644 --- a/src/Module/Api/Mastodon/Accounts/Follow.php +++ b/src/Module/Api/Mastodon/Accounts/Follow.php @@ -33,7 +33,7 @@ class Follow extends BaseApi { protected function post(array $request = []) { - self::checkAllowedScope(self::SCOPE_FOLLOW); + $this->checkAllowedScope(self::SCOPE_FOLLOW); $uid = self::getCurrentUserID(); if (empty($this->parameters['id'])) { diff --git a/src/Module/Api/Mastodon/Accounts/Followers.php b/src/Module/Api/Mastodon/Accounts/Followers.php index 65c7ac42d..e433943c8 100644 --- a/src/Module/Api/Mastodon/Accounts/Followers.php +++ b/src/Module/Api/Mastodon/Accounts/Followers.php @@ -37,7 +37,7 @@ class Followers extends BaseApi */ protected function rawContent(array $request = []) { - self::checkAllowedScope(self::SCOPE_READ); + $this->checkAllowedScope(self::SCOPE_READ); $uid = self::getCurrentUserID(); if (empty($this->parameters['id'])) { diff --git a/src/Module/Api/Mastodon/Accounts/Following.php b/src/Module/Api/Mastodon/Accounts/Following.php index 5da678d9d..3b19e1eed 100644 --- a/src/Module/Api/Mastodon/Accounts/Following.php +++ b/src/Module/Api/Mastodon/Accounts/Following.php @@ -37,7 +37,7 @@ class Following extends BaseApi */ protected function rawContent(array $request = []) { - self::checkAllowedScope(self::SCOPE_READ); + $this->checkAllowedScope(self::SCOPE_READ); $uid = self::getCurrentUserID(); if (empty($this->parameters['id'])) { diff --git a/src/Module/Api/Mastodon/Accounts/IdentityProofs.php b/src/Module/Api/Mastodon/Accounts/IdentityProofs.php index ac2f2ab55..97ec4ecbd 100644 --- a/src/Module/Api/Mastodon/Accounts/IdentityProofs.php +++ b/src/Module/Api/Mastodon/Accounts/IdentityProofs.php @@ -34,7 +34,7 @@ class IdentityProofs extends BaseApi */ protected function rawContent(array $request = []) { - self::checkAllowedScope(self::SCOPE_READ); + $this->checkAllowedScope(self::SCOPE_READ); $this->jsonExit([]); } diff --git a/src/Module/Api/Mastodon/Accounts/Lists.php b/src/Module/Api/Mastodon/Accounts/Lists.php index d39f79081..4a494838b 100644 --- a/src/Module/Api/Mastodon/Accounts/Lists.php +++ b/src/Module/Api/Mastodon/Accounts/Lists.php @@ -37,7 +37,7 @@ class Lists extends BaseApi */ protected function rawContent(array $request = []) { - self::checkAllowedScope(self::SCOPE_READ); + $this->checkAllowedScope(self::SCOPE_READ); $uid = self::getCurrentUserID(); if (empty($this->parameters['id'])) { diff --git a/src/Module/Api/Mastodon/Accounts/Mute.php b/src/Module/Api/Mastodon/Accounts/Mute.php index f08e48154..4169cb90f 100644 --- a/src/Module/Api/Mastodon/Accounts/Mute.php +++ b/src/Module/Api/Mastodon/Accounts/Mute.php @@ -33,7 +33,7 @@ class Mute extends BaseApi { protected function post(array $request = []) { - self::checkAllowedScope(self::SCOPE_FOLLOW); + $this->checkAllowedScope(self::SCOPE_FOLLOW); $uid = self::getCurrentUserID(); if (empty($this->parameters['id'])) { diff --git a/src/Module/Api/Mastodon/Accounts/Note.php b/src/Module/Api/Mastodon/Accounts/Note.php index fc7e72247..24df3b357 100644 --- a/src/Module/Api/Mastodon/Accounts/Note.php +++ b/src/Module/Api/Mastodon/Accounts/Note.php @@ -34,7 +34,7 @@ class Note extends BaseApi { protected function post(array $request = []) { - self::checkAllowedScope(self::SCOPE_WRITE); + $this->checkAllowedScope(self::SCOPE_WRITE); $uid = self::getCurrentUserID(); if (empty($this->parameters['id'])) { diff --git a/src/Module/Api/Mastodon/Accounts/Relationships.php b/src/Module/Api/Mastodon/Accounts/Relationships.php index 531fcadd1..4ae5b0669 100644 --- a/src/Module/Api/Mastodon/Accounts/Relationships.php +++ b/src/Module/Api/Mastodon/Accounts/Relationships.php @@ -36,7 +36,7 @@ class Relationships extends BaseApi */ protected function rawContent(array $request = []) { - self::checkAllowedScope(self::SCOPE_READ); + $this->checkAllowedScope(self::SCOPE_READ); $uid = self::getCurrentUserID(); $request = $this->getRequest([ diff --git a/src/Module/Api/Mastodon/Accounts/Search.php b/src/Module/Api/Mastodon/Accounts/Search.php index a4936092c..70b42494f 100644 --- a/src/Module/Api/Mastodon/Accounts/Search.php +++ b/src/Module/Api/Mastodon/Accounts/Search.php @@ -38,7 +38,7 @@ class Search extends BaseApi */ protected function rawContent(array $request = []) { - self::checkAllowedScope(self::SCOPE_READ); + $this->checkAllowedScope(self::SCOPE_READ); $uid = self::getCurrentUserID(); $request = $this->getRequest([ diff --git a/src/Module/Api/Mastodon/Accounts/Unblock.php b/src/Module/Api/Mastodon/Accounts/Unblock.php index 35b532012..8d8fb3e39 100644 --- a/src/Module/Api/Mastodon/Accounts/Unblock.php +++ b/src/Module/Api/Mastodon/Accounts/Unblock.php @@ -33,7 +33,7 @@ class Unblock extends BaseApi { protected function post(array $request = []) { - self::checkAllowedScope(self::SCOPE_FOLLOW); + $this->checkAllowedScope(self::SCOPE_FOLLOW); $uid = self::getCurrentUserID(); if (empty($this->parameters['id'])) { diff --git a/src/Module/Api/Mastodon/Accounts/Unfollow.php b/src/Module/Api/Mastodon/Accounts/Unfollow.php index c4bc17200..83676f25a 100644 --- a/src/Module/Api/Mastodon/Accounts/Unfollow.php +++ b/src/Module/Api/Mastodon/Accounts/Unfollow.php @@ -33,7 +33,7 @@ class Unfollow extends BaseApi { protected function post(array $request = []) { - self::checkAllowedScope(self::SCOPE_FOLLOW); + $this->checkAllowedScope(self::SCOPE_FOLLOW); $uid = self::getCurrentUserID(); if (empty($this->parameters['id'])) { diff --git a/src/Module/Api/Mastodon/Accounts/Unmute.php b/src/Module/Api/Mastodon/Accounts/Unmute.php index a2cf90820..7708e1472 100644 --- a/src/Module/Api/Mastodon/Accounts/Unmute.php +++ b/src/Module/Api/Mastodon/Accounts/Unmute.php @@ -33,7 +33,7 @@ class Unmute extends BaseApi { protected function post(array $request = []) { - self::checkAllowedScope(self::SCOPE_FOLLOW); + $this->checkAllowedScope(self::SCOPE_FOLLOW); $uid = self::getCurrentUserID(); if (empty($this->parameters['id'])) { diff --git a/src/Module/Api/Mastodon/Accounts/UpdateCredentials.php b/src/Module/Api/Mastodon/Accounts/UpdateCredentials.php index 170861461..69c992c48 100644 --- a/src/Module/Api/Mastodon/Accounts/UpdateCredentials.php +++ b/src/Module/Api/Mastodon/Accounts/UpdateCredentials.php @@ -36,7 +36,7 @@ class UpdateCredentials extends BaseApi { protected function patch(array $request = []) { - self::checkAllowedScope(self::SCOPE_WRITE); + $this->checkAllowedScope(self::SCOPE_WRITE); $uid = self::getCurrentUserID(); $owner = User::getOwnerDataById($uid); diff --git a/src/Module/Api/Mastodon/Accounts/VerifyCredentials.php b/src/Module/Api/Mastodon/Accounts/VerifyCredentials.php index d59549ae8..2e6d64ff6 100644 --- a/src/Module/Api/Mastodon/Accounts/VerifyCredentials.php +++ b/src/Module/Api/Mastodon/Accounts/VerifyCredentials.php @@ -37,7 +37,7 @@ class VerifyCredentials extends BaseApi */ protected function rawContent(array $request = []) { - self::checkAllowedScope(self::SCOPE_READ); + $this->checkAllowedScope(self::SCOPE_READ); $uid = self::getCurrentUserID(); $self = User::getOwnerDataById($uid); diff --git a/src/Module/Api/Mastodon/Announcements.php b/src/Module/Api/Mastodon/Announcements.php index 8e0565947..10f6037e7 100644 --- a/src/Module/Api/Mastodon/Announcements.php +++ b/src/Module/Api/Mastodon/Announcements.php @@ -34,7 +34,7 @@ class Announcements extends BaseApi */ protected function rawContent(array $request = []) { - self::checkAllowedScope(self::SCOPE_READ); + $this->checkAllowedScope(self::SCOPE_READ); // @todo Possibly use the message from the pageheader addon for this $this->jsonExit([]); diff --git a/src/Module/Api/Mastodon/Apps/VerifyCredentials.php b/src/Module/Api/Mastodon/Apps/VerifyCredentials.php index c21e1e438..82e0016ef 100644 --- a/src/Module/Api/Mastodon/Apps/VerifyCredentials.php +++ b/src/Module/Api/Mastodon/Apps/VerifyCredentials.php @@ -32,7 +32,7 @@ class VerifyCredentials extends BaseApi { protected function rawContent(array $request = []) { - self::checkAllowedScope(self::SCOPE_READ); + $this->checkAllowedScope(self::SCOPE_READ); $application = self::getCurrentApplication(); if (empty($application['id'])) { diff --git a/src/Module/Api/Mastodon/Blocks.php b/src/Module/Api/Mastodon/Blocks.php index 1495b7635..f4256f165 100644 --- a/src/Module/Api/Mastodon/Blocks.php +++ b/src/Module/Api/Mastodon/Blocks.php @@ -36,7 +36,7 @@ class Blocks extends BaseApi */ protected function rawContent(array $request = []) { - self::checkAllowedScope(self::SCOPE_READ); + $this->checkAllowedScope(self::SCOPE_READ); $uid = self::getCurrentUserID(); $request = $this->getRequest([ diff --git a/src/Module/Api/Mastodon/Bookmarks.php b/src/Module/Api/Mastodon/Bookmarks.php index dab072b30..fb4694055 100644 --- a/src/Module/Api/Mastodon/Bookmarks.php +++ b/src/Module/Api/Mastodon/Bookmarks.php @@ -39,7 +39,7 @@ class Bookmarks extends BaseApi */ protected function rawContent(array $request = []) { - self::checkAllowedScope(self::SCOPE_READ); + $this->checkAllowedScope(self::SCOPE_READ); $uid = self::getCurrentUserID(); $request = $this->getRequest([ diff --git a/src/Module/Api/Mastodon/Conversations.php b/src/Module/Api/Mastodon/Conversations.php index abffff9ed..71239a0ff 100644 --- a/src/Module/Api/Mastodon/Conversations.php +++ b/src/Module/Api/Mastodon/Conversations.php @@ -33,7 +33,7 @@ class Conversations extends BaseApi { protected function delete(array $request = []) { - self::checkAllowedScope(self::SCOPE_WRITE); + $this->checkAllowedScope(self::SCOPE_WRITE); $uid = self::getCurrentUserID(); if (!empty($this->parameters['id'])) { @@ -51,7 +51,7 @@ class Conversations extends BaseApi */ protected function rawContent(array $request = []) { - self::checkAllowedScope(self::SCOPE_READ); + $this->checkAllowedScope(self::SCOPE_READ); $uid = self::getCurrentUserID(); $request = $this->getRequest([ diff --git a/src/Module/Api/Mastodon/Conversations/Read.php b/src/Module/Api/Mastodon/Conversations/Read.php index e8b101634..5bb7b3526 100644 --- a/src/Module/Api/Mastodon/Conversations/Read.php +++ b/src/Module/Api/Mastodon/Conversations/Read.php @@ -33,7 +33,7 @@ class Read extends BaseApi { protected function post(array $request = []) { - self::checkAllowedScope(self::SCOPE_WRITE); + $this->checkAllowedScope(self::SCOPE_WRITE); $uid = self::getCurrentUserID(); if (!empty($this->parameters['id'])) { diff --git a/src/Module/Api/Mastodon/Favourited.php b/src/Module/Api/Mastodon/Favourited.php index 56beb93be..141099edd 100644 --- a/src/Module/Api/Mastodon/Favourited.php +++ b/src/Module/Api/Mastodon/Favourited.php @@ -41,7 +41,7 @@ class Favourited extends BaseApi */ protected function rawContent(array $request = []) { - self::checkAllowedScope(self::SCOPE_READ); + $this->checkAllowedScope(self::SCOPE_READ); $uid = self::getCurrentUserID(); $request = $this->getRequest([ diff --git a/src/Module/Api/Mastodon/Filters.php b/src/Module/Api/Mastodon/Filters.php index 3af93d24c..5a40574a4 100644 --- a/src/Module/Api/Mastodon/Filters.php +++ b/src/Module/Api/Mastodon/Filters.php @@ -33,7 +33,7 @@ class Filters extends BaseApi { protected function post(array $request = []) { - self::checkAllowedScope(self::SCOPE_WRITE); + $this->checkAllowedScope(self::SCOPE_WRITE); $this->response->unsupported(Router::POST, $request); } @@ -43,7 +43,7 @@ class Filters extends BaseApi */ protected function rawContent(array $request = []) { - self::checkAllowedScope(self::SCOPE_READ); + $this->checkAllowedScope(self::SCOPE_READ); $this->jsonExit([]); } diff --git a/src/Module/Api/Mastodon/FollowRequests.php b/src/Module/Api/Mastodon/FollowRequests.php index 78efa4819..9947e8d48 100644 --- a/src/Module/Api/Mastodon/FollowRequests.php +++ b/src/Module/Api/Mastodon/FollowRequests.php @@ -44,7 +44,7 @@ class FollowRequests extends BaseApi */ protected function post(array $request = []) { - self::checkAllowedScope(self::SCOPE_FOLLOW); + $this->checkAllowedScope(self::SCOPE_FOLLOW); $uid = self::getCurrentUserID(); $cdata = Contact::getPublicAndUserContactID($this->parameters['id'], $uid); @@ -89,7 +89,7 @@ class FollowRequests extends BaseApi */ protected function rawContent(array $request = []) { - self::checkAllowedScope(self::SCOPE_READ); + $this->checkAllowedScope(self::SCOPE_READ); $uid = self::getCurrentUserID(); $request = $this->getRequest([ diff --git a/src/Module/Api/Mastodon/FollowedTags.php b/src/Module/Api/Mastodon/FollowedTags.php index 905229006..a327db727 100644 --- a/src/Module/Api/Mastodon/FollowedTags.php +++ b/src/Module/Api/Mastodon/FollowedTags.php @@ -32,7 +32,7 @@ class FollowedTags extends BaseApi { protected function rawContent(array $request = []) { - self::checkAllowedScope(self::SCOPE_READ); + $this->checkAllowedScope(self::SCOPE_READ); $uid = self::getCurrentUserID(); $request = $this->getRequest([ diff --git a/src/Module/Api/Mastodon/Lists.php b/src/Module/Api/Mastodon/Lists.php index 296009cc0..571927a16 100644 --- a/src/Module/Api/Mastodon/Lists.php +++ b/src/Module/Api/Mastodon/Lists.php @@ -33,7 +33,7 @@ class Lists extends BaseApi { protected function delete(array $request = []) { - self::checkAllowedScope(self::SCOPE_WRITE); + $this->checkAllowedScope(self::SCOPE_WRITE); $uid = self::getCurrentUserID(); if (empty($this->parameters['id'])) { @@ -53,7 +53,7 @@ class Lists extends BaseApi protected function post(array $request = []) { - self::checkAllowedScope(self::SCOPE_WRITE); + $this->checkAllowedScope(self::SCOPE_WRITE); $uid = self::getCurrentUserID(); $request = $this->getRequest([ @@ -93,7 +93,7 @@ class Lists extends BaseApi */ protected function rawContent(array $request = []) { - self::checkAllowedScope(self::SCOPE_READ); + $this->checkAllowedScope(self::SCOPE_READ); $uid = self::getCurrentUserID(); if (empty($this->parameters['id'])) { diff --git a/src/Module/Api/Mastodon/Lists/Accounts.php b/src/Module/Api/Mastodon/Lists/Accounts.php index 2d202c34d..135701904 100644 --- a/src/Module/Api/Mastodon/Lists/Accounts.php +++ b/src/Module/Api/Mastodon/Lists/Accounts.php @@ -36,7 +36,7 @@ class Accounts extends BaseApi { protected function delete(array $request = []) { - self::checkAllowedScope(self::SCOPE_WRITE); + $this->checkAllowedScope(self::SCOPE_WRITE); $request = $this->getRequest([ 'account_ids' => [], // Array of account IDs to remove from the list @@ -51,7 +51,7 @@ class Accounts extends BaseApi protected function post(array $request = []) { - self::checkAllowedScope(self::SCOPE_WRITE); + $this->checkAllowedScope(self::SCOPE_WRITE); $request = $this->getRequest([ 'account_ids' => [], // Array of account IDs to add to the list @@ -69,7 +69,7 @@ class Accounts extends BaseApi */ protected function rawContent(array $request = []) { - self::checkAllowedScope(self::SCOPE_READ); + $this->checkAllowedScope(self::SCOPE_READ); $uid = self::getCurrentUserID(); if (empty($this->parameters['id'])) { diff --git a/src/Module/Api/Mastodon/Markers.php b/src/Module/Api/Mastodon/Markers.php index 2f0a6b6b7..eb19acf8e 100644 --- a/src/Module/Api/Mastodon/Markers.php +++ b/src/Module/Api/Mastodon/Markers.php @@ -34,7 +34,7 @@ class Markers extends BaseApi { protected function post(array $request = []) { - self::checkAllowedScope(self::SCOPE_WRITE); + $this->checkAllowedScope(self::SCOPE_WRITE); $uid = self::getCurrentUserID(); $application = self::getCurrentApplication(); @@ -69,7 +69,7 @@ class Markers extends BaseApi */ protected function rawContent(array $request = []) { - self::checkAllowedScope(self::SCOPE_READ); + $this->checkAllowedScope(self::SCOPE_READ); $uid = self::getCurrentUserID(); $application = self::getCurrentApplication(); diff --git a/src/Module/Api/Mastodon/Media.php b/src/Module/Api/Mastodon/Media.php index 3fe8dfa3d..b2424f022 100644 --- a/src/Module/Api/Mastodon/Media.php +++ b/src/Module/Api/Mastodon/Media.php @@ -35,7 +35,7 @@ class Media extends BaseApi { protected function post(array $request = []) { - self::checkAllowedScope(self::SCOPE_WRITE); + $this->checkAllowedScope(self::SCOPE_WRITE); $uid = self::getCurrentUserID(); $request = $this->getRequest([ @@ -63,7 +63,7 @@ class Media extends BaseApi public function put(array $request = []) { - self::checkAllowedScope(self::SCOPE_WRITE); + $this->checkAllowedScope(self::SCOPE_WRITE); $uid = self::getCurrentUserID(); $request = $this->getRequest([ @@ -100,7 +100,7 @@ class Media extends BaseApi */ protected function rawContent(array $request = []) { - self::checkAllowedScope(self::SCOPE_READ); + $this->checkAllowedScope(self::SCOPE_READ); $uid = self::getCurrentUserID(); if (empty($this->parameters['id'])) { diff --git a/src/Module/Api/Mastodon/Mutes.php b/src/Module/Api/Mastodon/Mutes.php index 71c17cc51..177b61877 100644 --- a/src/Module/Api/Mastodon/Mutes.php +++ b/src/Module/Api/Mastodon/Mutes.php @@ -36,7 +36,7 @@ class Mutes extends BaseApi */ protected function rawContent(array $request = []) { - self::checkAllowedScope(self::SCOPE_READ); + $this->checkAllowedScope(self::SCOPE_READ); $uid = self::getCurrentUserID(); if (empty($this->parameters['id'])) { diff --git a/src/Module/Api/Mastodon/Notifications.php b/src/Module/Api/Mastodon/Notifications.php index 94247b80b..ee3a253b3 100644 --- a/src/Module/Api/Mastodon/Notifications.php +++ b/src/Module/Api/Mastodon/Notifications.php @@ -41,7 +41,7 @@ class Notifications extends BaseApi */ protected function rawContent(array $request = []) { - self::checkAllowedScope(self::SCOPE_READ); + $this->checkAllowedScope(self::SCOPE_READ); $uid = self::getCurrentUserID(); if (!empty($this->parameters['id'])) { diff --git a/src/Module/Api/Mastodon/Notifications/Clear.php b/src/Module/Api/Mastodon/Notifications/Clear.php index cb2604337..1f843f048 100644 --- a/src/Module/Api/Mastodon/Notifications/Clear.php +++ b/src/Module/Api/Mastodon/Notifications/Clear.php @@ -32,7 +32,7 @@ class Clear extends BaseApi { protected function post(array $request = []) { - self::checkAllowedScope(self::SCOPE_WRITE); + $this->checkAllowedScope(self::SCOPE_WRITE); $uid = self::getCurrentUserID(); DI::notification()->setAllDismissedForUser($uid); diff --git a/src/Module/Api/Mastodon/Notifications/Dismiss.php b/src/Module/Api/Mastodon/Notifications/Dismiss.php index 753c0ac5d..50d1be27b 100644 --- a/src/Module/Api/Mastodon/Notifications/Dismiss.php +++ b/src/Module/Api/Mastodon/Notifications/Dismiss.php @@ -34,7 +34,7 @@ class Dismiss extends BaseApi { protected function post(array $request = []) { - self::checkAllowedScope(self::SCOPE_WRITE); + $this->checkAllowedScope(self::SCOPE_WRITE); $uid = self::getCurrentUserID(); if (empty($this->parameters['id'])) { diff --git a/src/Module/Api/Mastodon/Preferences.php b/src/Module/Api/Mastodon/Preferences.php index d1f9d2d30..7a8eb1175 100644 --- a/src/Module/Api/Mastodon/Preferences.php +++ b/src/Module/Api/Mastodon/Preferences.php @@ -36,7 +36,7 @@ class Preferences extends BaseApi */ protected function rawContent(array $request = []) { - self::checkAllowedScope(self::SCOPE_READ); + $this->checkAllowedScope(self::SCOPE_READ); $uid = self::getCurrentUserID(); $user = User::getById($uid, ['language', 'allow_cid', 'allow_gid', 'deny_cid', 'deny_gid']); diff --git a/src/Module/Api/Mastodon/PushSubscription.php b/src/Module/Api/Mastodon/PushSubscription.php index a80188013..a03d0250c 100644 --- a/src/Module/Api/Mastodon/PushSubscription.php +++ b/src/Module/Api/Mastodon/PushSubscription.php @@ -49,7 +49,7 @@ class PushSubscription extends BaseApi protected function post(array $request = []): void { - self::checkAllowedScope(self::SCOPE_PUSH); + $this->checkAllowedScope(self::SCOPE_PUSH); $uid = self::getCurrentUserID(); $application = self::getCurrentApplication(); @@ -83,7 +83,7 @@ class PushSubscription extends BaseApi public function put(array $request = []): void { - self::checkAllowedScope(self::SCOPE_PUSH); + $this->checkAllowedScope(self::SCOPE_PUSH); $uid = self::getCurrentUserID(); $application = self::getCurrentApplication(); @@ -122,7 +122,7 @@ class PushSubscription extends BaseApi protected function delete(array $request = []): void { - self::checkAllowedScope(self::SCOPE_PUSH); + $this->checkAllowedScope(self::SCOPE_PUSH); $uid = self::getCurrentUserID(); $application = self::getCurrentApplication(); @@ -139,7 +139,7 @@ class PushSubscription extends BaseApi protected function rawContent(array $request = []): void { - self::checkAllowedScope(self::SCOPE_PUSH); + $this->checkAllowedScope(self::SCOPE_PUSH); $uid = self::getCurrentUserID(); $application = self::getCurrentApplication(); diff --git a/src/Module/Api/Mastodon/Reports.php b/src/Module/Api/Mastodon/Reports.php index 2706aefe3..324fe49d8 100644 --- a/src/Module/Api/Mastodon/Reports.php +++ b/src/Module/Api/Mastodon/Reports.php @@ -51,7 +51,7 @@ class Reports extends BaseApi public function post(array $request = []) { - self::checkAllowedScope(self::SCOPE_WRITE); + $this->checkAllowedScope(self::SCOPE_WRITE); $request = $this->getRequest([ 'account_id' => '', // ID of the account to report diff --git a/src/Module/Api/Mastodon/ScheduledStatuses.php b/src/Module/Api/Mastodon/ScheduledStatuses.php index 6ac9430c6..5204ab556 100644 --- a/src/Module/Api/Mastodon/ScheduledStatuses.php +++ b/src/Module/Api/Mastodon/ScheduledStatuses.php @@ -35,7 +35,7 @@ class ScheduledStatuses extends BaseApi { public function put(array $request = []) { - self::checkAllowedScope(self::SCOPE_WRITE); + $this->checkAllowedScope(self::SCOPE_WRITE); $uid = self::getCurrentUserID(); $this->response->unsupported(Router::PUT, $request); @@ -43,7 +43,7 @@ class ScheduledStatuses extends BaseApi protected function delete(array $request = []) { - self::checkAllowedScope(self::SCOPE_WRITE); + $this->checkAllowedScope(self::SCOPE_WRITE); $uid = self::getCurrentUserID(); if (empty($this->parameters['id'])) { @@ -64,7 +64,7 @@ class ScheduledStatuses extends BaseApi */ protected function rawContent(array $request = []) { - self::checkAllowedScope(self::SCOPE_READ); + $this->checkAllowedScope(self::SCOPE_READ); $uid = self::getCurrentUserID(); if (isset($this->parameters['id'])) { diff --git a/src/Module/Api/Mastodon/Search.php b/src/Module/Api/Mastodon/Search.php index e0f629527..ec4527f00 100644 --- a/src/Module/Api/Mastodon/Search.php +++ b/src/Module/Api/Mastodon/Search.php @@ -43,7 +43,7 @@ class Search extends BaseApi */ protected function rawContent(array $request = []) { - self::checkAllowedScope(self::SCOPE_READ); + $this->checkAllowedScope(self::SCOPE_READ); $uid = self::getCurrentUserID(); $request = $this->getRequest([ diff --git a/src/Module/Api/Mastodon/Statuses.php b/src/Module/Api/Mastodon/Statuses.php index 0369d2026..749e0aa39 100644 --- a/src/Module/Api/Mastodon/Statuses.php +++ b/src/Module/Api/Mastodon/Statuses.php @@ -49,7 +49,7 @@ class Statuses extends BaseApi { public function put(array $request = []) { - self::checkAllowedScope(self::SCOPE_WRITE); + $this->checkAllowedScope(self::SCOPE_WRITE); $uid = self::getCurrentUserID(); $request = $this->getRequest([ @@ -164,7 +164,7 @@ class Statuses extends BaseApi protected function post(array $request = []) { - self::checkAllowedScope(self::SCOPE_WRITE); + $this->checkAllowedScope(self::SCOPE_WRITE); $uid = self::getCurrentUserID(); $request = $this->getRequest([ @@ -315,7 +315,7 @@ class Statuses extends BaseApi protected function delete(array $request = []) { - self::checkAllowedScope(self::SCOPE_READ); + $this->checkAllowedScope(self::SCOPE_READ); $uid = self::getCurrentUserID(); if (empty($this->parameters['id'])) { diff --git a/src/Module/Api/Mastodon/Statuses/Bookmark.php b/src/Module/Api/Mastodon/Statuses/Bookmark.php index ff34a8529..f2e5ff40d 100644 --- a/src/Module/Api/Mastodon/Statuses/Bookmark.php +++ b/src/Module/Api/Mastodon/Statuses/Bookmark.php @@ -35,7 +35,7 @@ class Bookmark extends BaseApi { protected function post(array $request = []) { - self::checkAllowedScope(self::SCOPE_WRITE); + $this->checkAllowedScope(self::SCOPE_WRITE); $uid = self::getCurrentUserID(); if (empty($this->parameters['id'])) { diff --git a/src/Module/Api/Mastodon/Statuses/Favourite.php b/src/Module/Api/Mastodon/Statuses/Favourite.php index da698c72f..d8cf8054e 100644 --- a/src/Module/Api/Mastodon/Statuses/Favourite.php +++ b/src/Module/Api/Mastodon/Statuses/Favourite.php @@ -35,7 +35,7 @@ class Favourite extends BaseApi { protected function post(array $request = []) { - self::checkAllowedScope(self::SCOPE_WRITE); + $this->checkAllowedScope(self::SCOPE_WRITE); $uid = self::getCurrentUserID(); if (empty($this->parameters['id'])) { diff --git a/src/Module/Api/Mastodon/Statuses/Mute.php b/src/Module/Api/Mastodon/Statuses/Mute.php index 56c352b34..d282770df 100644 --- a/src/Module/Api/Mastodon/Statuses/Mute.php +++ b/src/Module/Api/Mastodon/Statuses/Mute.php @@ -35,7 +35,7 @@ class Mute extends BaseApi { protected function post(array $request = []) { - self::checkAllowedScope(self::SCOPE_WRITE); + $this->checkAllowedScope(self::SCOPE_WRITE); $uid = self::getCurrentUserID(); if (empty($this->parameters['id'])) { diff --git a/src/Module/Api/Mastodon/Statuses/Pin.php b/src/Module/Api/Mastodon/Statuses/Pin.php index c95f02e9b..d9f95132c 100644 --- a/src/Module/Api/Mastodon/Statuses/Pin.php +++ b/src/Module/Api/Mastodon/Statuses/Pin.php @@ -34,7 +34,7 @@ class Pin extends BaseApi { protected function post(array $request = []) { - self::checkAllowedScope(self::SCOPE_WRITE); + $this->checkAllowedScope(self::SCOPE_WRITE); $uid = self::getCurrentUserID(); if (empty($this->parameters['id'])) { diff --git a/src/Module/Api/Mastodon/Statuses/Reblog.php b/src/Module/Api/Mastodon/Statuses/Reblog.php index d0cf46b06..6c368b019 100644 --- a/src/Module/Api/Mastodon/Statuses/Reblog.php +++ b/src/Module/Api/Mastodon/Statuses/Reblog.php @@ -38,7 +38,7 @@ class Reblog extends BaseApi { protected function post(array $request = []) { - self::checkAllowedScope(self::SCOPE_WRITE); + $this->checkAllowedScope(self::SCOPE_WRITE); $uid = self::getCurrentUserID(); if (empty($this->parameters['id'])) { diff --git a/src/Module/Api/Mastodon/Statuses/Source.php b/src/Module/Api/Mastodon/Statuses/Source.php index db997b0a3..408df3aad 100644 --- a/src/Module/Api/Mastodon/Statuses/Source.php +++ b/src/Module/Api/Mastodon/Statuses/Source.php @@ -37,7 +37,7 @@ class Source extends BaseApi */ protected function rawContent(array $request = []) { - self::checkAllowedScope(self::SCOPE_READ); + $this->checkAllowedScope(self::SCOPE_READ); $uid = self::getCurrentUserID(); if (empty($this->parameters['id'])) { diff --git a/src/Module/Api/Mastodon/Statuses/Unbookmark.php b/src/Module/Api/Mastodon/Statuses/Unbookmark.php index 3bda450e4..36902fb21 100644 --- a/src/Module/Api/Mastodon/Statuses/Unbookmark.php +++ b/src/Module/Api/Mastodon/Statuses/Unbookmark.php @@ -35,7 +35,7 @@ class Unbookmark extends BaseApi { protected function post(array $request = []) { - self::checkAllowedScope(self::SCOPE_WRITE); + $this->checkAllowedScope(self::SCOPE_WRITE); $uid = self::getCurrentUserID(); if (empty($this->parameters['id'])) { diff --git a/src/Module/Api/Mastodon/Statuses/Unfavourite.php b/src/Module/Api/Mastodon/Statuses/Unfavourite.php index c41ed8d89..c6a924b2a 100644 --- a/src/Module/Api/Mastodon/Statuses/Unfavourite.php +++ b/src/Module/Api/Mastodon/Statuses/Unfavourite.php @@ -35,7 +35,7 @@ class Unfavourite extends BaseApi { protected function post(array $request = []) { - self::checkAllowedScope(self::SCOPE_WRITE); + $this->checkAllowedScope(self::SCOPE_WRITE); $uid = self::getCurrentUserID(); if (empty($this->parameters['id'])) { diff --git a/src/Module/Api/Mastodon/Statuses/Unmute.php b/src/Module/Api/Mastodon/Statuses/Unmute.php index 3668cb945..edf14925d 100644 --- a/src/Module/Api/Mastodon/Statuses/Unmute.php +++ b/src/Module/Api/Mastodon/Statuses/Unmute.php @@ -35,7 +35,7 @@ class Unmute extends BaseApi { protected function post(array $request = []) { - self::checkAllowedScope(self::SCOPE_WRITE); + $this->checkAllowedScope(self::SCOPE_WRITE); $uid = self::getCurrentUserID(); if (empty($this->parameters['id'])) { diff --git a/src/Module/Api/Mastodon/Statuses/Unpin.php b/src/Module/Api/Mastodon/Statuses/Unpin.php index fd23e3014..0f5d44afa 100644 --- a/src/Module/Api/Mastodon/Statuses/Unpin.php +++ b/src/Module/Api/Mastodon/Statuses/Unpin.php @@ -34,7 +34,7 @@ class Unpin extends BaseApi { protected function post(array $request = []) { - self::checkAllowedScope(self::SCOPE_WRITE); + $this->checkAllowedScope(self::SCOPE_WRITE); $uid = self::getCurrentUserID(); if (empty($this->parameters['id'])) { diff --git a/src/Module/Api/Mastodon/Statuses/Unreblog.php b/src/Module/Api/Mastodon/Statuses/Unreblog.php index 3d1f7ea9a..4f72eac25 100644 --- a/src/Module/Api/Mastodon/Statuses/Unreblog.php +++ b/src/Module/Api/Mastodon/Statuses/Unreblog.php @@ -37,7 +37,7 @@ class Unreblog extends BaseApi { protected function post(array $request = []) { - self::checkAllowedScope(self::SCOPE_WRITE); + $this->checkAllowedScope(self::SCOPE_WRITE); $uid = self::getCurrentUserID(); if (empty($this->parameters['id'])) { diff --git a/src/Module/Api/Mastodon/Suggestions.php b/src/Module/Api/Mastodon/Suggestions.php index f18637b3d..7c5d53449 100644 --- a/src/Module/Api/Mastodon/Suggestions.php +++ b/src/Module/Api/Mastodon/Suggestions.php @@ -36,7 +36,7 @@ class Suggestions extends BaseApi */ protected function rawContent(array $request = []) { - self::checkAllowedScope(self::SCOPE_READ); + $this->checkAllowedScope(self::SCOPE_READ); $uid = self::getCurrentUserID(); $request = $this->getRequest([ diff --git a/src/Module/Api/Mastodon/Tags.php b/src/Module/Api/Mastodon/Tags.php index 474bbe079..d636dd912 100644 --- a/src/Module/Api/Mastodon/Tags.php +++ b/src/Module/Api/Mastodon/Tags.php @@ -36,7 +36,7 @@ class Tags extends BaseApi */ protected function rawContent(array $request = []) { - self::checkAllowedScope(self::SCOPE_READ); + $this->checkAllowedScope(self::SCOPE_READ); $uid = self::getCurrentUserID(); if (empty($this->parameters['hashtag'])) { diff --git a/src/Module/Api/Mastodon/Tags/Follow.php b/src/Module/Api/Mastodon/Tags/Follow.php index ec27ea733..a450b2248 100644 --- a/src/Module/Api/Mastodon/Tags/Follow.php +++ b/src/Module/Api/Mastodon/Tags/Follow.php @@ -33,7 +33,7 @@ class Follow extends BaseApi { protected function post(array $request = []) { - self::checkAllowedScope(self::SCOPE_WRITE); + $this->checkAllowedScope(self::SCOPE_WRITE); $uid = self::getCurrentUserID(); if (empty($this->parameters['hashtag'])) { diff --git a/src/Module/Api/Mastodon/Tags/Unfollow.php b/src/Module/Api/Mastodon/Tags/Unfollow.php index 02847f1fd..b4a1a7e73 100644 --- a/src/Module/Api/Mastodon/Tags/Unfollow.php +++ b/src/Module/Api/Mastodon/Tags/Unfollow.php @@ -33,7 +33,7 @@ class Unfollow extends BaseApi { protected function post(array $request = []) { - self::checkAllowedScope(self::SCOPE_WRITE); + $this->checkAllowedScope(self::SCOPE_WRITE); $uid = self::getCurrentUserID(); if (empty($this->parameters['hashtag'])) { diff --git a/src/Module/Api/Mastodon/Timelines/Direct.php b/src/Module/Api/Mastodon/Timelines/Direct.php index e326bc7a1..c1e710970 100644 --- a/src/Module/Api/Mastodon/Timelines/Direct.php +++ b/src/Module/Api/Mastodon/Timelines/Direct.php @@ -37,7 +37,7 @@ class Direct extends BaseApi */ protected function rawContent(array $request = []) { - self::checkAllowedScope(self::SCOPE_READ); + $this->checkAllowedScope(self::SCOPE_READ); $uid = self::getCurrentUserID(); $request = $this->getRequest([ diff --git a/src/Module/Api/Mastodon/Timelines/Home.php b/src/Module/Api/Mastodon/Timelines/Home.php index e9985508c..d92a87636 100644 --- a/src/Module/Api/Mastodon/Timelines/Home.php +++ b/src/Module/Api/Mastodon/Timelines/Home.php @@ -41,7 +41,7 @@ class Home extends BaseApi */ protected function rawContent(array $request = []) { - self::checkAllowedScope(self::SCOPE_READ); + $this->checkAllowedScope(self::SCOPE_READ); $uid = self::getCurrentUserID(); $request = $this->getRequest([ diff --git a/src/Module/Api/Mastodon/Timelines/ListTimeline.php b/src/Module/Api/Mastodon/Timelines/ListTimeline.php index fa4605128..2834b63fc 100644 --- a/src/Module/Api/Mastodon/Timelines/ListTimeline.php +++ b/src/Module/Api/Mastodon/Timelines/ListTimeline.php @@ -41,7 +41,7 @@ class ListTimeline extends BaseApi */ protected function rawContent(array $request = []) { - self::checkAllowedScope(self::SCOPE_READ); + $this->checkAllowedScope(self::SCOPE_READ); $uid = self::getCurrentUserID(); if (empty($this->parameters['id'])) { diff --git a/src/Module/Api/Mastodon/Timelines/Tag.php b/src/Module/Api/Mastodon/Timelines/Tag.php index 5b3e82508..9bbafd587 100644 --- a/src/Module/Api/Mastodon/Timelines/Tag.php +++ b/src/Module/Api/Mastodon/Timelines/Tag.php @@ -41,7 +41,7 @@ class Tag extends BaseApi */ protected function rawContent(array $request = []) { - self::checkAllowedScope(self::SCOPE_READ); + $this->checkAllowedScope(self::SCOPE_READ); $uid = self::getCurrentUserID(); if (empty($this->parameters['hashtag'])) { diff --git a/src/Module/Api/Twitter/Account/UpdateProfile.php b/src/Module/Api/Twitter/Account/UpdateProfile.php index c58b8d24c..2dfd2fb24 100644 --- a/src/Module/Api/Twitter/Account/UpdateProfile.php +++ b/src/Module/Api/Twitter/Account/UpdateProfile.php @@ -34,7 +34,7 @@ class UpdateProfile extends BaseApi { protected function post(array $request = []) { - BaseApi::checkAllowedScope(BaseApi::SCOPE_WRITE); + $this->checkAllowedScope(BaseApi::SCOPE_WRITE); $uid = BaseApi::getCurrentUserID(); $api_user = DI::twitterUser()->createFromUserId($uid, true)->toArray(); diff --git a/src/Module/Api/Twitter/Account/UpdateProfileImage.php b/src/Module/Api/Twitter/Account/UpdateProfileImage.php index f6ac2d198..421963a48 100644 --- a/src/Module/Api/Twitter/Account/UpdateProfileImage.php +++ b/src/Module/Api/Twitter/Account/UpdateProfileImage.php @@ -35,7 +35,7 @@ class UpdateProfileImage extends BaseApi { protected function post(array $request = []) { - BaseApi::checkAllowedScope(BaseApi::SCOPE_WRITE); + $this->checkAllowedScope(BaseApi::SCOPE_WRITE); $uid = BaseApi::getCurrentUserID(); // get mediadata from image or media (Twitter call api/account/update_profile_image provides image) diff --git a/src/Module/Api/Twitter/Account/VerifyCredentials.php b/src/Module/Api/Twitter/Account/VerifyCredentials.php index 738c08e5a..b6f608a83 100644 --- a/src/Module/Api/Twitter/Account/VerifyCredentials.php +++ b/src/Module/Api/Twitter/Account/VerifyCredentials.php @@ -34,7 +34,7 @@ class VerifyCredentials extends BaseApi { protected function rawContent(array $request = []) { - BaseApi::checkAllowedScope(BaseApi::SCOPE_READ); + $this->checkAllowedScope(BaseApi::SCOPE_READ); $uid = BaseApi::getCurrentUserID(); $skip_status = $this->getRequestValue($request, 'skip_status', false); diff --git a/src/Module/Api/Twitter/Blocks/Ids.php b/src/Module/Api/Twitter/Blocks/Ids.php index e08dcf40f..d4798b2f3 100644 --- a/src/Module/Api/Twitter/Blocks/Ids.php +++ b/src/Module/Api/Twitter/Blocks/Ids.php @@ -33,7 +33,7 @@ class Ids extends ContactEndpoint { protected function rawContent(array $request = []) { - self::checkAllowedScope(self::SCOPE_READ); + $this->checkAllowedScope(self::SCOPE_READ); $uid = BaseApi::getCurrentUserID(); // Expected value for user_id parameter: public/user contact id diff --git a/src/Module/Api/Twitter/Blocks/Lists.php b/src/Module/Api/Twitter/Blocks/Lists.php index ec5d71120..51d682ec1 100644 --- a/src/Module/Api/Twitter/Blocks/Lists.php +++ b/src/Module/Api/Twitter/Blocks/Lists.php @@ -33,7 +33,7 @@ class Lists extends ContactEndpoint { protected function rawContent(array $request = []) { - self::checkAllowedScope(self::SCOPE_READ); + $this->checkAllowedScope(self::SCOPE_READ); $uid = BaseApi::getCurrentUserID(); // Expected value for user_id parameter: public/user contact id diff --git a/src/Module/Api/Twitter/ContactEndpoint.php b/src/Module/Api/Twitter/ContactEndpoint.php index 1ff9c7833..948e4980e 100644 --- a/src/Module/Api/Twitter/ContactEndpoint.php +++ b/src/Module/Api/Twitter/ContactEndpoint.php @@ -42,7 +42,7 @@ abstract class ContactEndpoint extends BaseApi { parent::__construct($errorFactory, $app, $l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters); - self::checkAllowedScope(self::SCOPE_READ); + $this->checkAllowedScope(self::SCOPE_READ); } /** diff --git a/src/Module/Api/Twitter/DirectMessages/All.php b/src/Module/Api/Twitter/DirectMessages/All.php index cfd43ed84..8df751677 100644 --- a/src/Module/Api/Twitter/DirectMessages/All.php +++ b/src/Module/Api/Twitter/DirectMessages/All.php @@ -31,7 +31,7 @@ class All extends DirectMessagesEndpoint { protected function rawContent(array $request = []) { - BaseApi::checkAllowedScope(BaseApi::SCOPE_READ); + $this->checkAllowedScope(BaseApi::SCOPE_READ); $uid = BaseApi::getCurrentUserID(); $this->getMessages($request, $uid, []); diff --git a/src/Module/Api/Twitter/DirectMessages/Conversation.php b/src/Module/Api/Twitter/DirectMessages/Conversation.php index 91157e970..6b3e0a1d3 100644 --- a/src/Module/Api/Twitter/DirectMessages/Conversation.php +++ b/src/Module/Api/Twitter/DirectMessages/Conversation.php @@ -31,7 +31,7 @@ class Conversation extends DirectMessagesEndpoint { protected function rawContent(array $request = []) { - BaseApi::checkAllowedScope(BaseApi::SCOPE_READ); + $this->checkAllowedScope(BaseApi::SCOPE_READ); $uid = BaseApi::getCurrentUserID(); $this->getMessages($request, $uid, ["`parent-uri` = ?", $this->getRequestValue($request, 'uri', '')]); diff --git a/src/Module/Api/Twitter/DirectMessages/Destroy.php b/src/Module/Api/Twitter/DirectMessages/Destroy.php index 7108263ba..06879a659 100644 --- a/src/Module/Api/Twitter/DirectMessages/Destroy.php +++ b/src/Module/Api/Twitter/DirectMessages/Destroy.php @@ -49,7 +49,7 @@ class Destroy extends BaseApi } protected function rawContent(array $request = []) { - BaseApi::checkAllowedScope(BaseApi::SCOPE_WRITE); + $this->checkAllowedScope(BaseApi::SCOPE_WRITE); $uid = BaseApi::getCurrentUserID(); $id = $this->getRequestValue($request, 'id', 0); diff --git a/src/Module/Api/Twitter/DirectMessages/Inbox.php b/src/Module/Api/Twitter/DirectMessages/Inbox.php index 798cceb41..b163ca29b 100644 --- a/src/Module/Api/Twitter/DirectMessages/Inbox.php +++ b/src/Module/Api/Twitter/DirectMessages/Inbox.php @@ -34,7 +34,7 @@ class Inbox extends DirectMessagesEndpoint { protected function rawContent(array $request = []) { - BaseApi::checkAllowedScope(BaseApi::SCOPE_READ); + $this->checkAllowedScope(BaseApi::SCOPE_READ); $uid = BaseApi::getCurrentUserID(); $pcid = Contact::getPublicIdByUserId($uid); diff --git a/src/Module/Api/Twitter/DirectMessages/NewDM.php b/src/Module/Api/Twitter/DirectMessages/NewDM.php index d111f98cb..f452560b6 100644 --- a/src/Module/Api/Twitter/DirectMessages/NewDM.php +++ b/src/Module/Api/Twitter/DirectMessages/NewDM.php @@ -56,7 +56,7 @@ class NewDM extends BaseApi protected function rawContent(array $request = []) { - BaseApi::checkAllowedScope(BaseApi::SCOPE_WRITE); + $this->checkAllowedScope(BaseApi::SCOPE_WRITE); $uid = BaseApi::getCurrentUserID(); if (empty($request['text']) || empty($request['screen_name']) && empty($request['user_id'])) { diff --git a/src/Module/Api/Twitter/DirectMessages/Sent.php b/src/Module/Api/Twitter/DirectMessages/Sent.php index 2db0d4834..03f62406b 100644 --- a/src/Module/Api/Twitter/DirectMessages/Sent.php +++ b/src/Module/Api/Twitter/DirectMessages/Sent.php @@ -34,7 +34,7 @@ class Sent extends DirectMessagesEndpoint { protected function rawContent(array $request = []) { - BaseApi::checkAllowedScope(BaseApi::SCOPE_READ); + $this->checkAllowedScope(BaseApi::SCOPE_READ); $uid = BaseApi::getCurrentUserID(); $pcid = Contact::getPublicIdByUserId($uid); diff --git a/src/Module/Api/Twitter/Favorites.php b/src/Module/Api/Twitter/Favorites.php index 771e0ef48..fbb0a9641 100644 --- a/src/Module/Api/Twitter/Favorites.php +++ b/src/Module/Api/Twitter/Favorites.php @@ -38,7 +38,7 @@ class Favorites extends BaseApi { protected function rawContent(array $request = []) { - BaseApi::checkAllowedScope(BaseApi::SCOPE_READ); + $this->checkAllowedScope(BaseApi::SCOPE_READ); $uid = BaseApi::getCurrentUserID(); // in friendica starred item are private diff --git a/src/Module/Api/Twitter/Favorites/Create.php b/src/Module/Api/Twitter/Favorites/Create.php index 86a398804..28c4adced 100644 --- a/src/Module/Api/Twitter/Favorites/Create.php +++ b/src/Module/Api/Twitter/Favorites/Create.php @@ -34,7 +34,7 @@ class Create extends BaseApi { protected function post(array $request = []) { - self::checkAllowedScope(self::SCOPE_WRITE); + $this->checkAllowedScope(self::SCOPE_WRITE); $uid = self::getCurrentUserID(); $id = $this->getRequestValue($request, 'id', 0); diff --git a/src/Module/Api/Twitter/Favorites/Destroy.php b/src/Module/Api/Twitter/Favorites/Destroy.php index e481f8a9f..0c7f9acae 100644 --- a/src/Module/Api/Twitter/Favorites/Destroy.php +++ b/src/Module/Api/Twitter/Favorites/Destroy.php @@ -34,7 +34,7 @@ class Destroy extends BaseApi { protected function post(array $request = []) { - self::checkAllowedScope(self::SCOPE_WRITE); + $this->checkAllowedScope(self::SCOPE_WRITE); $uid = self::getCurrentUserID(); $id = $this->getRequestValue($request, 'id', 0); diff --git a/src/Module/Api/Twitter/Followers/Ids.php b/src/Module/Api/Twitter/Followers/Ids.php index 21adc682b..7b7104c70 100644 --- a/src/Module/Api/Twitter/Followers/Ids.php +++ b/src/Module/Api/Twitter/Followers/Ids.php @@ -34,7 +34,7 @@ class Ids extends ContactEndpoint { protected function rawContent(array $request = []) { - self::checkAllowedScope(self::SCOPE_READ); + $this->checkAllowedScope(self::SCOPE_READ); $uid = BaseApi::getCurrentUserID(); // Expected value for user_id parameter: public/user contact id diff --git a/src/Module/Api/Twitter/Followers/Lists.php b/src/Module/Api/Twitter/Followers/Lists.php index b4064fc27..48201134f 100644 --- a/src/Module/Api/Twitter/Followers/Lists.php +++ b/src/Module/Api/Twitter/Followers/Lists.php @@ -33,7 +33,7 @@ class Lists extends ContactEndpoint { protected function rawContent(array $request = []) { - self::checkAllowedScope(self::SCOPE_READ); + $this->checkAllowedScope(self::SCOPE_READ); $uid = BaseApi::getCurrentUserID(); // Expected value for user_id parameter: public/user contact id diff --git a/src/Module/Api/Twitter/Friends/Ids.php b/src/Module/Api/Twitter/Friends/Ids.php index e12d67aae..4b4a0e128 100644 --- a/src/Module/Api/Twitter/Friends/Ids.php +++ b/src/Module/Api/Twitter/Friends/Ids.php @@ -34,7 +34,7 @@ class Ids extends ContactEndpoint { protected function rawContent(array $request = []) { - self::checkAllowedScope(self::SCOPE_READ); + $this->checkAllowedScope(self::SCOPE_READ); $uid = BaseApi::getCurrentUserID(); // Expected value for user_id parameter: public/user contact id diff --git a/src/Module/Api/Twitter/Friends/Lists.php b/src/Module/Api/Twitter/Friends/Lists.php index 617d70e4d..216e299f3 100644 --- a/src/Module/Api/Twitter/Friends/Lists.php +++ b/src/Module/Api/Twitter/Friends/Lists.php @@ -33,7 +33,7 @@ class Lists extends ContactEndpoint { protected function rawContent(array $request = []) { - self::checkAllowedScope(self::SCOPE_READ); + $this->checkAllowedScope(self::SCOPE_READ); $uid = BaseApi::getCurrentUserID(); // Expected value for user_id parameter: public/user contact id diff --git a/src/Module/Api/Twitter/Friendships/Destroy.php b/src/Module/Api/Twitter/Friendships/Destroy.php index 05cc30488..2323c5003 100644 --- a/src/Module/Api/Twitter/Friendships/Destroy.php +++ b/src/Module/Api/Twitter/Friendships/Destroy.php @@ -54,7 +54,7 @@ class Destroy extends ContactEndpoint protected function post(array $request = []) { - BaseApi::checkAllowedScope(BaseApi::SCOPE_WRITE); + $this->checkAllowedScope(BaseApi::SCOPE_WRITE); $uid = BaseApi::getCurrentUserID(); $owner = User::getOwnerDataById($uid); diff --git a/src/Module/Api/Twitter/Friendships/Incoming.php b/src/Module/Api/Twitter/Friendships/Incoming.php index 62c372fa2..47980608c 100644 --- a/src/Module/Api/Twitter/Friendships/Incoming.php +++ b/src/Module/Api/Twitter/Friendships/Incoming.php @@ -32,7 +32,7 @@ class Incoming extends ContactEndpoint { protected function rawContent(array $request = []) { - self::checkAllowedScope(self::SCOPE_READ); + $this->checkAllowedScope(self::SCOPE_READ); $uid = BaseApi::getCurrentUserID(); // Expected value for user_id parameter: public/user contact id diff --git a/src/Module/Api/Twitter/Friendships/Show.php b/src/Module/Api/Twitter/Friendships/Show.php index 6dd1c1d20..950cac488 100644 --- a/src/Module/Api/Twitter/Friendships/Show.php +++ b/src/Module/Api/Twitter/Friendships/Show.php @@ -35,7 +35,7 @@ class Show extends ContactEndpoint { protected function rawContent(array $request = []) { - self::checkAllowedScope(self::SCOPE_READ); + $this->checkAllowedScope(self::SCOPE_READ); $uid = BaseApi::getCurrentUserID(); $source_cid = BaseApi::getContactIDForSearchterm($this->getRequestValue($request, 'source_screen_name', ''), '', $this->getRequestValue($request, 'source_id', 0), $uid); diff --git a/src/Module/Api/Twitter/Lists/Create.php b/src/Module/Api/Twitter/Lists/Create.php index ed4650adc..aa5f385e1 100644 --- a/src/Module/Api/Twitter/Lists/Create.php +++ b/src/Module/Api/Twitter/Lists/Create.php @@ -56,7 +56,7 @@ class Create extends BaseApi protected function rawContent(array $request = []) { - BaseApi::checkAllowedScope(BaseApi::SCOPE_WRITE); + $this->checkAllowedScope(BaseApi::SCOPE_WRITE); $uid = BaseApi::getCurrentUserID(); // params diff --git a/src/Module/Api/Twitter/Lists/Destroy.php b/src/Module/Api/Twitter/Lists/Destroy.php index 0e13ac9b2..d0277bcb7 100644 --- a/src/Module/Api/Twitter/Lists/Destroy.php +++ b/src/Module/Api/Twitter/Lists/Destroy.php @@ -56,7 +56,7 @@ class Destroy extends BaseApi protected function rawContent(array $request = []) { - BaseApi::checkAllowedScope(BaseApi::SCOPE_WRITE); + $this->checkAllowedScope(BaseApi::SCOPE_WRITE); $uid = BaseApi::getCurrentUserID(); // params diff --git a/src/Module/Api/Twitter/Lists/Lists.php b/src/Module/Api/Twitter/Lists/Lists.php index 8ebef3789..dbb7e820b 100644 --- a/src/Module/Api/Twitter/Lists/Lists.php +++ b/src/Module/Api/Twitter/Lists/Lists.php @@ -33,7 +33,7 @@ class Lists extends BaseApi { protected function rawContent(array $request = []) { - BaseApi::checkAllowedScope(BaseApi::SCOPE_READ); + $this->checkAllowedScope(BaseApi::SCOPE_READ); $uid = BaseApi::getCurrentUserID(); // This is a dummy endpoint diff --git a/src/Module/Api/Twitter/Lists/Ownership.php b/src/Module/Api/Twitter/Lists/Ownership.php index 11b85c51a..4cb7ba26a 100644 --- a/src/Module/Api/Twitter/Lists/Ownership.php +++ b/src/Module/Api/Twitter/Lists/Ownership.php @@ -53,7 +53,7 @@ class Ownership extends BaseApi } protected function rawContent(array $request = []) { - BaseApi::checkAllowedScope(BaseApi::SCOPE_READ); + $this->checkAllowedScope(BaseApi::SCOPE_READ); $uid = BaseApi::getCurrentUserID(); $circles = $this->dba->select('group', [], ['deleted' => false, 'uid' => $uid, 'cid' => null]); diff --git a/src/Module/Api/Twitter/Lists/Statuses.php b/src/Module/Api/Twitter/Lists/Statuses.php index 6e12f5908..4a7ada4b3 100644 --- a/src/Module/Api/Twitter/Lists/Statuses.php +++ b/src/Module/Api/Twitter/Lists/Statuses.php @@ -58,7 +58,7 @@ class Statuses extends BaseApi protected function rawContent(array $request = []) { - BaseApi::checkAllowedScope(BaseApi::SCOPE_READ); + $this->checkAllowedScope(BaseApi::SCOPE_READ); $uid = BaseApi::getCurrentUserID(); if (empty($request['list_id'])) { diff --git a/src/Module/Api/Twitter/Lists/Update.php b/src/Module/Api/Twitter/Lists/Update.php index 17fd4636b..59292fa16 100644 --- a/src/Module/Api/Twitter/Lists/Update.php +++ b/src/Module/Api/Twitter/Lists/Update.php @@ -56,7 +56,7 @@ class Update extends BaseApi protected function rawContent(array $request = []) { - BaseApi::checkAllowedScope(BaseApi::SCOPE_WRITE); + $this->checkAllowedScope(BaseApi::SCOPE_WRITE); $uid = BaseApi::getCurrentUserID(); // params diff --git a/src/Module/Api/Twitter/Media/Metadata/Create.php b/src/Module/Api/Twitter/Media/Metadata/Create.php index be7963637..68ac12f0c 100644 --- a/src/Module/Api/Twitter/Media/Metadata/Create.php +++ b/src/Module/Api/Twitter/Media/Metadata/Create.php @@ -36,7 +36,7 @@ class Create extends BaseApi { protected function post(array $request = []) { - BaseApi::checkAllowedScope(BaseApi::SCOPE_WRITE); + $this->checkAllowedScope(BaseApi::SCOPE_WRITE); $uid = BaseApi::getCurrentUserID(); $postdata = Network::postdata(); diff --git a/src/Module/Api/Twitter/Media/Upload.php b/src/Module/Api/Twitter/Media/Upload.php index 0ea93f87b..d7400e68b 100644 --- a/src/Module/Api/Twitter/Media/Upload.php +++ b/src/Module/Api/Twitter/Media/Upload.php @@ -37,7 +37,7 @@ class Upload extends BaseApi { protected function post(array $request = []) { - BaseApi::checkAllowedScope(BaseApi::SCOPE_WRITE); + $this->checkAllowedScope(BaseApi::SCOPE_WRITE); $uid = BaseApi::getCurrentUserID(); if (empty($_FILES['media'])) { diff --git a/src/Module/Api/Twitter/SavedSearches.php b/src/Module/Api/Twitter/SavedSearches.php index 8a6e5ced8..7a0d6fdb1 100644 --- a/src/Module/Api/Twitter/SavedSearches.php +++ b/src/Module/Api/Twitter/SavedSearches.php @@ -32,7 +32,7 @@ class SavedSearches extends BaseApi { protected function rawContent(array $request = []) { - self::checkAllowedScope(self::SCOPE_READ); + $this->checkAllowedScope(self::SCOPE_READ); $uid = self::getCurrentUserID(); $terms = DBA::select('search', ['id', 'term'], ['uid' => $uid]); diff --git a/src/Module/Api/Twitter/Search/Tweets.php b/src/Module/Api/Twitter/Search/Tweets.php index ec13f00dc..9bf8ac282 100644 --- a/src/Module/Api/Twitter/Search/Tweets.php +++ b/src/Module/Api/Twitter/Search/Tweets.php @@ -38,7 +38,7 @@ class Tweets extends BaseApi { protected function rawContent(array $request = []) { - BaseApi::checkAllowedScope(BaseApi::SCOPE_READ); + $this->checkAllowedScope(BaseApi::SCOPE_READ); $uid = BaseApi::getCurrentUserID(); if (empty($request['q'])) { diff --git a/src/Module/Api/Twitter/Statuses/Destroy.php b/src/Module/Api/Twitter/Statuses/Destroy.php index bde3ee678..8d86e0614 100644 --- a/src/Module/Api/Twitter/Statuses/Destroy.php +++ b/src/Module/Api/Twitter/Statuses/Destroy.php @@ -37,7 +37,7 @@ class Destroy extends BaseApi { protected function post(array $request = []) { - BaseApi::checkAllowedScope(BaseApi::SCOPE_READ); + $this->checkAllowedScope(BaseApi::SCOPE_READ); $uid = BaseApi::getCurrentUserID(); $id = $this->getRequestValue($request, 'id', 0); diff --git a/src/Module/Api/Twitter/Statuses/HomeTimeline.php b/src/Module/Api/Twitter/Statuses/HomeTimeline.php index d7caea65d..22715a371 100644 --- a/src/Module/Api/Twitter/Statuses/HomeTimeline.php +++ b/src/Module/Api/Twitter/Statuses/HomeTimeline.php @@ -37,7 +37,7 @@ class HomeTimeline extends BaseApi { protected function rawContent(array $request = []) { - BaseApi::checkAllowedScope(BaseApi::SCOPE_READ); + $this->checkAllowedScope(BaseApi::SCOPE_READ); $uid = BaseApi::getCurrentUserID(); // get last network messages diff --git a/src/Module/Api/Twitter/Statuses/Mentions.php b/src/Module/Api/Twitter/Statuses/Mentions.php index 18d56f1a1..aaacb9f06 100644 --- a/src/Module/Api/Twitter/Statuses/Mentions.php +++ b/src/Module/Api/Twitter/Statuses/Mentions.php @@ -37,7 +37,7 @@ class Mentions extends BaseApi { protected function rawContent(array $request = []) { - BaseApi::checkAllowedScope(BaseApi::SCOPE_READ); + $this->checkAllowedScope(BaseApi::SCOPE_READ); $uid = BaseApi::getCurrentUserID(); // get last network messages diff --git a/src/Module/Api/Twitter/Statuses/NetworkPublicTimeline.php b/src/Module/Api/Twitter/Statuses/NetworkPublicTimeline.php index 1f4cbc1b4..6069bc96e 100644 --- a/src/Module/Api/Twitter/Statuses/NetworkPublicTimeline.php +++ b/src/Module/Api/Twitter/Statuses/NetworkPublicTimeline.php @@ -35,7 +35,7 @@ class NetworkPublicTimeline extends BaseApi { protected function rawContent(array $request = []) { - BaseApi::checkAllowedScope(BaseApi::SCOPE_READ); + $this->checkAllowedScope(BaseApi::SCOPE_READ); $uid = BaseApi::getCurrentUserID(); $count = $this->getRequestValue($request, 'count', 20, 1, 100); diff --git a/src/Module/Api/Twitter/Statuses/PublicTimeline.php b/src/Module/Api/Twitter/Statuses/PublicTimeline.php index 49b9c986f..511e4465b 100644 --- a/src/Module/Api/Twitter/Statuses/PublicTimeline.php +++ b/src/Module/Api/Twitter/Statuses/PublicTimeline.php @@ -35,7 +35,7 @@ class PublicTimeline extends BaseApi { protected function rawContent(array $request = []) { - BaseApi::checkAllowedScope(BaseApi::SCOPE_READ); + $this->checkAllowedScope(BaseApi::SCOPE_READ); $uid = BaseApi::getCurrentUserID(); // get last network messages diff --git a/src/Module/Api/Twitter/Statuses/Retweet.php b/src/Module/Api/Twitter/Statuses/Retweet.php index 6640f880c..e94632b65 100644 --- a/src/Module/Api/Twitter/Statuses/Retweet.php +++ b/src/Module/Api/Twitter/Statuses/Retweet.php @@ -41,7 +41,7 @@ class Retweet extends BaseApi { protected function post(array $request = []) { - self::checkAllowedScope(self::SCOPE_WRITE); + $this->checkAllowedScope(self::SCOPE_WRITE); $uid = self::getCurrentUserID(); $id = $this->getRequestValue($request, 'id', 0); diff --git a/src/Module/Api/Twitter/Statuses/Show.php b/src/Module/Api/Twitter/Statuses/Show.php index 67a0b31af..4d37420a3 100644 --- a/src/Module/Api/Twitter/Statuses/Show.php +++ b/src/Module/Api/Twitter/Statuses/Show.php @@ -39,7 +39,7 @@ class Show extends BaseApi { protected function rawContent(array $request = []) { - BaseApi::checkAllowedScope(BaseApi::SCOPE_READ); + $this->checkAllowedScope(BaseApi::SCOPE_READ); $uid = BaseApi::getCurrentUserID(); $id = $this->getRequestValue($request, 'id', 0); diff --git a/src/Module/Api/Twitter/Statuses/Update.php b/src/Module/Api/Twitter/Statuses/Update.php index b3f0dd8a6..064eac08a 100644 --- a/src/Module/Api/Twitter/Statuses/Update.php +++ b/src/Module/Api/Twitter/Statuses/Update.php @@ -46,7 +46,7 @@ class Update extends BaseApi { public function post(array $request = []) { - self::checkAllowedScope(self::SCOPE_WRITE); + $this->checkAllowedScope(self::SCOPE_WRITE); $uid = self::getCurrentUserID(); $owner = User::getOwnerDataById($uid); diff --git a/src/Module/Api/Twitter/Statuses/UserTimeline.php b/src/Module/Api/Twitter/Statuses/UserTimeline.php index 2c58fd6af..361c8dba2 100644 --- a/src/Module/Api/Twitter/Statuses/UserTimeline.php +++ b/src/Module/Api/Twitter/Statuses/UserTimeline.php @@ -38,7 +38,7 @@ class UserTimeline extends BaseApi { protected function rawContent(array $request = []) { - BaseApi::checkAllowedScope(BaseApi::SCOPE_READ); + $this->checkAllowedScope(BaseApi::SCOPE_READ); $uid = BaseApi::getCurrentUserID(); Logger::info('api_statuses_user_timeline', ['api_user' => $uid, '_REQUEST' => $request]); diff --git a/src/Module/Api/Twitter/Users/Lookup.php b/src/Module/Api/Twitter/Users/Lookup.php index 960239f22..4c39ae92b 100644 --- a/src/Module/Api/Twitter/Users/Lookup.php +++ b/src/Module/Api/Twitter/Users/Lookup.php @@ -34,7 +34,7 @@ class Lookup extends BaseApi { protected function rawContent(array $request = []) { - BaseApi::checkAllowedScope(BaseApi::SCOPE_READ); + $this->checkAllowedScope(BaseApi::SCOPE_READ); $uid = BaseApi::getCurrentUserID(); $users = []; diff --git a/src/Module/Api/Twitter/Users/Search.php b/src/Module/Api/Twitter/Users/Search.php index 2ca30afac..6f26488e6 100644 --- a/src/Module/Api/Twitter/Users/Search.php +++ b/src/Module/Api/Twitter/Users/Search.php @@ -37,7 +37,7 @@ class Search extends BaseApi { protected function rawContent(array $request = []) { - BaseApi::checkAllowedScope(BaseApi::SCOPE_READ); + $this->checkAllowedScope(BaseApi::SCOPE_READ); $uid = BaseApi::getCurrentUserID(); $userlist = []; diff --git a/src/Module/Api/Twitter/Users/Show.php b/src/Module/Api/Twitter/Users/Show.php index 158c3f18d..25e6012bf 100644 --- a/src/Module/Api/Twitter/Users/Show.php +++ b/src/Module/Api/Twitter/Users/Show.php @@ -34,7 +34,7 @@ class Show extends BaseApi { protected function rawContent(array $request = []) { - BaseApi::checkAllowedScope(BaseApi::SCOPE_READ); + $this->checkAllowedScope(BaseApi::SCOPE_READ); $uid = BaseApi::getCurrentUserID(); if (empty($this->parameters['id'])) { diff --git a/src/Module/BaseApi.php b/src/Module/BaseApi.php index d8bf65732..95eb8f042 100644 --- a/src/Module/BaseApi.php +++ b/src/Module/BaseApi.php @@ -97,7 +97,7 @@ class BaseApi extends BaseModule case Router::PATCH: case Router::POST: case Router::PUT: - self::checkAllowedScope(self::SCOPE_WRITE); + $this->checkAllowedScope(self::SCOPE_WRITE); if (!self::getCurrentUserID()) { throw new HTTPException\ForbiddenException($this->t('Permission denied.')); @@ -418,22 +418,22 @@ class BaseApi extends BaseModule * * @param string $scope the requested scope (read, write, follow, push) */ - public static function checkAllowedScope(string $scope) + public function checkAllowedScope(string $scope) { $token = self::getCurrentApplication(); if (empty($token)) { - Logger::notice('Empty application token'); + $this->logger->notice('Empty application token'); DI::mstdnError()->Forbidden(); } if (!isset($token[$scope])) { - Logger::warning('The requested scope does not exist', ['scope' => $scope, 'application' => $token]); + $this->logger->warning('The requested scope does not exist', ['scope' => $scope, 'application' => $token]); DI::mstdnError()->Forbidden(); } if (empty($token[$scope])) { - Logger::warning('The requested scope is not allowed', ['scope' => $scope, 'application' => $token]); + $this->logger->warning('The requested scope is not allowed', ['scope' => $scope, 'application' => $token]); DI::mstdnError()->Forbidden(); } } From 7f846f153d6abf8ed4c0f9a5b81bd45a6ac8e4a2 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Wed, 11 Oct 2023 09:16:03 -0400 Subject: [PATCH 03/10] Move jsonError out of Factory\Api\Mastodon\Error->RecordNotFound --- src/Factory/Api/Mastodon/Error.php | 7 ++----- src/Factory/Api/Mastodon/Status.php | 2 +- src/Module/Api/Friendica/Statuses/Dislike.php | 2 +- src/Module/Api/Friendica/Statuses/DislikedBy.php | 2 +- src/Module/Api/Friendica/Statuses/Undislike.php | 2 +- src/Module/Api/Mastodon/Accounts.php | 4 ++-- src/Module/Api/Mastodon/Accounts/Followers.php | 2 +- src/Module/Api/Mastodon/Accounts/Following.php | 2 +- src/Module/Api/Mastodon/Accounts/Lists.php | 2 +- src/Module/Api/Mastodon/Accounts/Note.php | 2 +- src/Module/Api/Mastodon/Accounts/Statuses.php | 2 +- src/Module/Api/Mastodon/Accounts/Unfollow.php | 2 +- src/Module/Api/Mastodon/Conversations.php | 11 ++++++++--- src/Module/Api/Mastodon/Conversations/Read.php | 7 ++++++- src/Module/Api/Mastodon/Lists.php | 4 ++-- src/Module/Api/Mastodon/Lists/Accounts.php | 2 +- src/Module/Api/Mastodon/Media.php | 6 +++--- src/Module/Api/Mastodon/Mutes.php | 2 +- src/Module/Api/Mastodon/Notifications.php | 2 +- src/Module/Api/Mastodon/PushSubscription.php | 4 ++-- src/Module/Api/Mastodon/ScheduledStatuses.php | 2 +- src/Module/Api/Mastodon/Statuses.php | 4 ++-- src/Module/Api/Mastodon/Statuses/Bookmark.php | 6 +++--- src/Module/Api/Mastodon/Statuses/Context.php | 2 +- src/Module/Api/Mastodon/Statuses/Favourite.php | 2 +- src/Module/Api/Mastodon/Statuses/FavouritedBy.php | 2 +- src/Module/Api/Mastodon/Statuses/Mute.php | 2 +- src/Module/Api/Mastodon/Statuses/Pin.php | 2 +- src/Module/Api/Mastodon/Statuses/Reblog.php | 2 +- src/Module/Api/Mastodon/Statuses/RebloggedBy.php | 2 +- src/Module/Api/Mastodon/Statuses/Unbookmark.php | 6 +++--- src/Module/Api/Mastodon/Statuses/Unfavourite.php | 2 +- src/Module/Api/Mastodon/Statuses/Unmute.php | 2 +- src/Module/Api/Mastodon/Statuses/Unpin.php | 2 +- src/Module/Api/Mastodon/Statuses/Unreblog.php | 6 +++--- src/Module/Api/Mastodon/Timelines/Direct.php | 11 ++++++++--- 36 files changed, 68 insertions(+), 56 deletions(-) diff --git a/src/Factory/Api/Mastodon/Error.php b/src/Factory/Api/Mastodon/Error.php index 68172d632..dec56ba90 100644 --- a/src/Factory/Api/Mastodon/Error.php +++ b/src/Factory/Api/Mastodon/Error.php @@ -50,14 +50,11 @@ class Error extends BaseFactory $this->logger->info('API Error', ['no' => $errorno, 'error' => $error, 'method' => $this->args->getMethod(), 'command' => $this->args->getQueryString(), 'user-agent' => $this->server['HTTP_USER_AGENT'] ?? '']); } - public function RecordNotFound() + public function RecordNotFound(): \Friendica\Object\Api\Mastodon\Error { $error = $this->l10n->t('Record not found'); $error_description = ''; - $errorObj = new \Friendica\Object\Api\Mastodon\Error($error, $error_description); - - $this->logError(404, $error); - $this->jsonError(404, $errorObj->toArray()); + return new \Friendica\Object\Api\Mastodon\Error($error, $error_description); } public function UnprocessableEntity(string $error = '') diff --git a/src/Factory/Api/Mastodon/Status.php b/src/Factory/Api/Mastodon/Status.php index b53d846fc..4bf5609b9 100644 --- a/src/Factory/Api/Mastodon/Status.php +++ b/src/Factory/Api/Mastodon/Status.php @@ -359,7 +359,7 @@ class Status extends BaseFactory { $item = ActivityPub\Transmitter::getItemArrayFromMail($id, true); if (empty($item)) { - $this->mstdnErrorFactory->RecordNotFound(); + throw new HTTPException\NotFoundException('Mail record not found with id: ' . $id); } $account = $this->mstdnAccountFactory->createFromContactId($item['author-id']); diff --git a/src/Module/Api/Friendica/Statuses/Dislike.php b/src/Module/Api/Friendica/Statuses/Dislike.php index 5491bf189..a0dcd7077 100644 --- a/src/Module/Api/Friendica/Statuses/Dislike.php +++ b/src/Module/Api/Friendica/Statuses/Dislike.php @@ -44,7 +44,7 @@ class Dislike extends BaseApi $item = Post::selectFirstForUser($uid, ['id'], ['uri-id' => $this->parameters['id'], 'uid' => [$uid, 0]]); if (!DBA::isResult($item)) { - DI::mstdnError()->RecordNotFound(); + $this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound()); } Item::performActivity($item['id'], 'dislike', $uid); diff --git a/src/Module/Api/Friendica/Statuses/DislikedBy.php b/src/Module/Api/Friendica/Statuses/DislikedBy.php index bb7888483..fcae9990c 100644 --- a/src/Module/Api/Friendica/Statuses/DislikedBy.php +++ b/src/Module/Api/Friendica/Statuses/DislikedBy.php @@ -46,7 +46,7 @@ class DislikedBy extends BaseApi $id = $this->parameters['id']; if (!Post::exists(['uri-id' => $id, 'uid' => [0, $uid]])) { - DI::mstdnError()->RecordNotFound(); + $this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound()); } $activities = Post::selectPosts(['author-id'], ['thr-parent-id' => $id, 'gravity' => Item::GRAVITY_ACTIVITY, 'verb' => Activity::DISLIKE, 'deleted' => false]); diff --git a/src/Module/Api/Friendica/Statuses/Undislike.php b/src/Module/Api/Friendica/Statuses/Undislike.php index a646045e5..f304fb9db 100644 --- a/src/Module/Api/Friendica/Statuses/Undislike.php +++ b/src/Module/Api/Friendica/Statuses/Undislike.php @@ -44,7 +44,7 @@ class Undislike extends BaseApi $item = Post::selectFirstForUser($uid, ['id'], ['uri-id' => $this->parameters['id'], 'uid' => [$uid, 0]]); if (!DBA::isResult($item)) { - DI::mstdnError()->RecordNotFound(); + $this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound()); } Item::performActivity($item['id'], 'undislike', $uid); diff --git a/src/Module/Api/Mastodon/Accounts.php b/src/Module/Api/Mastodon/Accounts.php index bd215e387..4ebd0d4bd 100644 --- a/src/Module/Api/Mastodon/Accounts.php +++ b/src/Module/Api/Mastodon/Accounts.php @@ -46,14 +46,14 @@ class Accounts extends BaseApi if (!empty($this->parameters['id'])) { $id = $this->parameters['id']; if (!DBA::exists('contact', ['id' => $id, 'uid' => 0])) { - DI::mstdnError()->RecordNotFound(); + $this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound()); } } else { $contact = Contact::selectFirst(['id'], ['nick' => $this->parameters['name'], 'uid' => 0]); if (!empty($contact['id'])) { $id = $contact['id']; } elseif (!($id = Contact::getIdForURL($this->parameters['name'], 0, false))) { - DI::mstdnError()->RecordNotFound(); + $this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound()); } } diff --git a/src/Module/Api/Mastodon/Accounts/Followers.php b/src/Module/Api/Mastodon/Accounts/Followers.php index e433943c8..22b99ee4d 100644 --- a/src/Module/Api/Mastodon/Accounts/Followers.php +++ b/src/Module/Api/Mastodon/Accounts/Followers.php @@ -46,7 +46,7 @@ class Followers extends BaseApi $id = $this->parameters['id']; if (!DBA::exists('contact', ['id' => $id, 'uid' => 0])) { - DI::mstdnError()->RecordNotFound(); + $this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound()); } $request = $this->getRequest([ diff --git a/src/Module/Api/Mastodon/Accounts/Following.php b/src/Module/Api/Mastodon/Accounts/Following.php index 3b19e1eed..0fde1404e 100644 --- a/src/Module/Api/Mastodon/Accounts/Following.php +++ b/src/Module/Api/Mastodon/Accounts/Following.php @@ -46,7 +46,7 @@ class Following extends BaseApi $id = $this->parameters['id']; if (!DBA::exists('contact', ['id' => $id, 'uid' => 0])) { - DI::mstdnError()->RecordNotFound(); + $this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound()); } $request = $this->getRequest([ diff --git a/src/Module/Api/Mastodon/Accounts/Lists.php b/src/Module/Api/Mastodon/Accounts/Lists.php index 4a494838b..f0187a286 100644 --- a/src/Module/Api/Mastodon/Accounts/Lists.php +++ b/src/Module/Api/Mastodon/Accounts/Lists.php @@ -46,7 +46,7 @@ class Lists extends BaseApi $id = $this->parameters['id']; if (!DBA::exists('contact', ['id' => $id, 'uid' => 0])) { - DI::mstdnError()->RecordNotFound(); + $this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound()); } $lists = []; diff --git a/src/Module/Api/Mastodon/Accounts/Note.php b/src/Module/Api/Mastodon/Accounts/Note.php index 24df3b357..52c76ab69 100644 --- a/src/Module/Api/Mastodon/Accounts/Note.php +++ b/src/Module/Api/Mastodon/Accounts/Note.php @@ -47,7 +47,7 @@ class Note extends BaseApi $cdata = Contact::getPublicAndUserContactID($this->parameters['id'], $uid); if (empty($cdata['user'])) { - DI::mstdnError()->RecordNotFound(); + $this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound()); } Contact::update(['info' => $request['comment']], ['id' => $cdata['user']]); diff --git a/src/Module/Api/Mastodon/Accounts/Statuses.php b/src/Module/Api/Mastodon/Accounts/Statuses.php index 93b642cd6..599a2eff8 100644 --- a/src/Module/Api/Mastodon/Accounts/Statuses.php +++ b/src/Module/Api/Mastodon/Accounts/Statuses.php @@ -52,7 +52,7 @@ class Statuses extends BaseApi $id = $this->parameters['id']; if (!DBA::exists('contact', ['id' => $id, 'uid' => 0])) { - DI::mstdnError()->RecordNotFound(); + $this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound()); } $request = $this->getRequest([ diff --git a/src/Module/Api/Mastodon/Accounts/Unfollow.php b/src/Module/Api/Mastodon/Accounts/Unfollow.php index 83676f25a..cfe3b3cb1 100644 --- a/src/Module/Api/Mastodon/Accounts/Unfollow.php +++ b/src/Module/Api/Mastodon/Accounts/Unfollow.php @@ -42,7 +42,7 @@ class Unfollow extends BaseApi $cdata = Contact::getPublicAndUserContactID($this->parameters['id'], $uid); if (empty($cdata['user'])) { - DI::mstdnError()->RecordNotFound(); + $this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound()); } $contact = Contact::getById($cdata['user']); diff --git a/src/Module/Api/Mastodon/Conversations.php b/src/Module/Api/Mastodon/Conversations.php index 71239a0ff..c45144c98 100644 --- a/src/Module/Api/Mastodon/Conversations.php +++ b/src/Module/Api/Mastodon/Conversations.php @@ -25,6 +25,7 @@ use Friendica\Core\System; use Friendica\Database\DBA; use Friendica\DI; use Friendica\Module\BaseApi; +use Friendica\Network\HTTPException\NotFoundException; /** * @see https://docs.joinmastodon.org/methods/timelines/conversations/ @@ -83,9 +84,13 @@ class Conversations extends BaseApi $conversations = []; - while ($conv = DBA::fetch($convs)) { - self::setBoundaries($conv['id']); - $conversations[] = DI::mstdnConversation()->createFromConvId($conv['id']); + try { + while ($conv = DBA::fetch($convs)) { + self::setBoundaries($conv['id']); + $conversations[] = DI::mstdnConversation()->createFromConvId($conv['id']); + } + } catch (NotFoundException $e) { + $this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound()); } DBA::close($convs); diff --git a/src/Module/Api/Mastodon/Conversations/Read.php b/src/Module/Api/Mastodon/Conversations/Read.php index 5bb7b3526..86a5090e3 100644 --- a/src/Module/Api/Mastodon/Conversations/Read.php +++ b/src/Module/Api/Mastodon/Conversations/Read.php @@ -25,6 +25,7 @@ use Friendica\Core\System; use Friendica\Database\DBA; use Friendica\DI; use Friendica\Module\BaseApi; +use Friendica\Network\HTTPException\NotFoundException; /** * @see https://docs.joinmastodon.org/methods/timelines/conversations/ @@ -42,6 +43,10 @@ class Read extends BaseApi DBA::update('mail', ['seen' => true], ['convid' => $this->parameters['id'], 'uid' => $uid]); - $this->jsonExit(DI::mstdnConversation()->createFromConvId($this->parameters['id'])->toArray()); + try { + $this->jsonExit(DI::mstdnConversation()->createFromConvId($this->parameters['id'])->toArray()); + } catch (NotFoundException $e) { + $this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound()); + } } } diff --git a/src/Module/Api/Mastodon/Lists.php b/src/Module/Api/Mastodon/Lists.php index 571927a16..9d9e6955b 100644 --- a/src/Module/Api/Mastodon/Lists.php +++ b/src/Module/Api/Mastodon/Lists.php @@ -41,7 +41,7 @@ class Lists extends BaseApi } if (!Circle::exists($this->parameters['id'], $uid)) { - DI::mstdnError()->RecordNotFound(); + $this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound()); } if (!Circle::remove($this->parameters['id'])) { @@ -106,7 +106,7 @@ class Lists extends BaseApi $id = $this->parameters['id']; if (!Circle::exists($id, $uid)) { - DI::mstdnError()->RecordNotFound(); + $this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound()); } $lists = DI::mstdnList()->createFromCircleId($id); } diff --git a/src/Module/Api/Mastodon/Lists/Accounts.php b/src/Module/Api/Mastodon/Lists/Accounts.php index 135701904..ffa63caf4 100644 --- a/src/Module/Api/Mastodon/Lists/Accounts.php +++ b/src/Module/Api/Mastodon/Lists/Accounts.php @@ -78,7 +78,7 @@ class Accounts extends BaseApi $id = $this->parameters['id']; if (!DBA::exists('group', ['id' => $id, 'uid' => $uid])) { - DI::mstdnError()->RecordNotFound(); + $this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound()); } $request = $this->getRequest([ diff --git a/src/Module/Api/Mastodon/Media.php b/src/Module/Api/Mastodon/Media.php index b2424f022..91c88ee18 100644 --- a/src/Module/Api/Mastodon/Media.php +++ b/src/Module/Api/Mastodon/Media.php @@ -81,10 +81,10 @@ class Media extends BaseApi if (empty($photo['resource-id'])) { $media = Post\Media::getById($this->parameters['id']); if (empty($media['uri-id'])) { - DI::mstdnError()->RecordNotFound(); + $this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound()); } if (!Post::exists(['uri-id' => $media['uri-id'], 'uid' => $uid, 'origin' => true])) { - DI::mstdnError()->RecordNotFound(); + $this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound()); } Post\Media::updateById(['description' => $request['description']], $this->parameters['id']); $this->jsonExit(DI::mstdnAttachment()->createFromId($this->parameters['id'])); @@ -109,7 +109,7 @@ class Media extends BaseApi $id = $this->parameters['id']; if (!Photo::exists(['id' => $id, 'uid' => $uid])) { - DI::mstdnError()->RecordNotFound(); + $this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound()); } $this->jsonExit(DI::mstdnAttachment()->createFromPhoto($id)); diff --git a/src/Module/Api/Mastodon/Mutes.php b/src/Module/Api/Mastodon/Mutes.php index 177b61877..71b1949f5 100644 --- a/src/Module/Api/Mastodon/Mutes.php +++ b/src/Module/Api/Mastodon/Mutes.php @@ -45,7 +45,7 @@ class Mutes extends BaseApi $id = $this->parameters['id']; if (!DBA::exists('contact', ['id' => $id, 'uid' => 0])) { - DI::mstdnError()->RecordNotFound(); + $this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound()); } $request = $this->getRequest([ diff --git a/src/Module/Api/Mastodon/Notifications.php b/src/Module/Api/Mastodon/Notifications.php index ee3a253b3..6045d2465 100644 --- a/src/Module/Api/Mastodon/Notifications.php +++ b/src/Module/Api/Mastodon/Notifications.php @@ -50,7 +50,7 @@ class Notifications extends BaseApi $notification = DI::notification()->selectOneForUser($uid, ['id' => $id]); $this->jsonExit(DI::mstdnNotification()->createFromNotification($notification, self::appSupportsQuotes())); } catch (\Exception $e) { - DI::mstdnError()->RecordNotFound(); + $this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound()); } } diff --git a/src/Module/Api/Mastodon/PushSubscription.php b/src/Module/Api/Mastodon/PushSubscription.php index a03d0250c..b91f8e7ba 100644 --- a/src/Module/Api/Mastodon/PushSubscription.php +++ b/src/Module/Api/Mastodon/PushSubscription.php @@ -94,7 +94,7 @@ class PushSubscription extends BaseApi $subscription = Subscription::select($application['id'], $uid, ['id']); if (empty($subscription)) { $this->logger->info('Subscription not found', ['application-id' => $application['id'], 'uid' => $uid]); - $this->errorFactory->RecordNotFound(); + $this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound()); } $fields = [ @@ -145,7 +145,7 @@ class PushSubscription extends BaseApi if (!Subscription::exists($application['id'], $uid)) { $this->logger->info('Subscription not found', ['application-id' => $application['id'], 'uid' => $uid]); - $this->errorFactory->RecordNotFound(); + $this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound()); } $this->logger->info('Fetch subscription', ['application-id' => $application['id'], 'uid' => $uid]); diff --git a/src/Module/Api/Mastodon/ScheduledStatuses.php b/src/Module/Api/Mastodon/ScheduledStatuses.php index 5204ab556..f136c2708 100644 --- a/src/Module/Api/Mastodon/ScheduledStatuses.php +++ b/src/Module/Api/Mastodon/ScheduledStatuses.php @@ -51,7 +51,7 @@ class ScheduledStatuses extends BaseApi } if (!DBA::exists('delayed-post', ['id' => $this->parameters['id'], 'uid' => $uid])) { - DI::mstdnError()->RecordNotFound(); + $this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound()); } Post\Delayed::deleteById($this->parameters['id']); diff --git a/src/Module/Api/Mastodon/Statuses.php b/src/Module/Api/Mastodon/Statuses.php index 749e0aa39..0940befba 100644 --- a/src/Module/Api/Mastodon/Statuses.php +++ b/src/Module/Api/Mastodon/Statuses.php @@ -324,11 +324,11 @@ class Statuses extends BaseApi $item = Post::selectFirstForUser($uid, ['id'], ['uri-id' => $this->parameters['id'], 'uid' => $uid]); if (empty($item['id'])) { - DI::mstdnError()->RecordNotFound(); + $this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound()); } if (!Item::markForDeletionById($item['id'])) { - DI::mstdnError()->RecordNotFound(); + $this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound()); } $this->jsonExit([]); diff --git a/src/Module/Api/Mastodon/Statuses/Bookmark.php b/src/Module/Api/Mastodon/Statuses/Bookmark.php index f2e5ff40d..1ba0d6e04 100644 --- a/src/Module/Api/Mastodon/Statuses/Bookmark.php +++ b/src/Module/Api/Mastodon/Statuses/Bookmark.php @@ -44,7 +44,7 @@ class Bookmark extends BaseApi $item = Post::selectOriginal(['uid', 'id', 'uri-id', 'gravity'], ['uri-id' => $this->parameters['id'], 'uid' => [$uid, 0]], ['order' => ['uid' => true]]); if (!DBA::isResult($item)) { - DI::mstdnError()->RecordNotFound(); + $this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound()); } if ($item['gravity'] != Item::GRAVITY_PARENT) { @@ -56,10 +56,10 @@ class Bookmark extends BaseApi if (!empty($stored)) { $item = Post::selectFirst(['id', 'gravity'], ['id' => $stored]); if (!DBA::isResult($item)) { - DI::mstdnError()->RecordNotFound(); + $this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound()); } } else { - DI::mstdnError()->RecordNotFound(); + $this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound()); } } diff --git a/src/Module/Api/Mastodon/Statuses/Context.php b/src/Module/Api/Mastodon/Statuses/Context.php index 3a73569f4..c171c0cca 100644 --- a/src/Module/Api/Mastodon/Statuses/Context.php +++ b/src/Module/Api/Mastodon/Statuses/Context.php @@ -116,7 +116,7 @@ class Context extends BaseApi } DBA::close($posts); } else { - DI::mstdnError()->RecordNotFound(); + $this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound()); } } diff --git a/src/Module/Api/Mastodon/Statuses/Favourite.php b/src/Module/Api/Mastodon/Statuses/Favourite.php index d8cf8054e..384abc3d8 100644 --- a/src/Module/Api/Mastodon/Statuses/Favourite.php +++ b/src/Module/Api/Mastodon/Statuses/Favourite.php @@ -44,7 +44,7 @@ class Favourite extends BaseApi $item = Post::selectOriginalForUser($uid, ['id', 'uri-id'], ['uri-id' => $this->parameters['id'], 'uid' => [$uid, 0]]); if (!DBA::isResult($item)) { - DI::mstdnError()->RecordNotFound(); + $this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound()); } Item::performActivity($item['id'], 'like', $uid); diff --git a/src/Module/Api/Mastodon/Statuses/FavouritedBy.php b/src/Module/Api/Mastodon/Statuses/FavouritedBy.php index b6902a1c0..bce95610a 100644 --- a/src/Module/Api/Mastodon/Statuses/FavouritedBy.php +++ b/src/Module/Api/Mastodon/Statuses/FavouritedBy.php @@ -45,7 +45,7 @@ class FavouritedBy extends BaseApi } if (!$post = Post::selectOriginal(['uri-id'], ['uri-id' => $this->parameters['id'], 'uid' => [0, $uid]])) { - DI::mstdnError()->RecordNotFound(); + $this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound()); } $activities = Post::selectPosts(['author-id'], ['thr-parent-id' => $post['uri-id'], 'gravity' => Item::GRAVITY_ACTIVITY, 'verb' => Activity::LIKE, 'deleted' => false]); diff --git a/src/Module/Api/Mastodon/Statuses/Mute.php b/src/Module/Api/Mastodon/Statuses/Mute.php index d282770df..68491c8b7 100644 --- a/src/Module/Api/Mastodon/Statuses/Mute.php +++ b/src/Module/Api/Mastodon/Statuses/Mute.php @@ -44,7 +44,7 @@ class Mute extends BaseApi $item = Post::selectOriginalForUser($uid, ['uri-id', 'gravity'], ['uri-id' => $this->parameters['id'], 'uid' => [$uid, 0]]); if (!DBA::isResult($item)) { - DI::mstdnError()->RecordNotFound(); + $this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound()); } if ($item['gravity'] != Item::GRAVITY_PARENT) { diff --git a/src/Module/Api/Mastodon/Statuses/Pin.php b/src/Module/Api/Mastodon/Statuses/Pin.php index d9f95132c..99f097740 100644 --- a/src/Module/Api/Mastodon/Statuses/Pin.php +++ b/src/Module/Api/Mastodon/Statuses/Pin.php @@ -43,7 +43,7 @@ class Pin extends BaseApi $item = Post::selectOriginalForUser($uid, ['uri-id', 'gravity', 'author-id'], ['uri-id' => $this->parameters['id'], 'uid' => [$uid, 0]]); if (!DBA::isResult($item)) { - DI::mstdnError()->RecordNotFound(); + $this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound()); } Post\Collection::add($item['uri-id'], Post\Collection::FEATURED, $item['author-id'], $uid); diff --git a/src/Module/Api/Mastodon/Statuses/Reblog.php b/src/Module/Api/Mastodon/Statuses/Reblog.php index 6c368b019..3e37a94a7 100644 --- a/src/Module/Api/Mastodon/Statuses/Reblog.php +++ b/src/Module/Api/Mastodon/Statuses/Reblog.php @@ -47,7 +47,7 @@ class Reblog extends BaseApi $item = Post::selectOriginalForUser($uid, ['id', 'uri-id', 'network'], ['uri-id' => $this->parameters['id'], 'uid' => [$uid, 0]]); if (!DBA::isResult($item)) { - DI::mstdnError()->RecordNotFound(); + $this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound()); } if ($item['network'] == Protocol::DIASPORA) { diff --git a/src/Module/Api/Mastodon/Statuses/RebloggedBy.php b/src/Module/Api/Mastodon/Statuses/RebloggedBy.php index ff0e1ba94..9c508e42a 100644 --- a/src/Module/Api/Mastodon/Statuses/RebloggedBy.php +++ b/src/Module/Api/Mastodon/Statuses/RebloggedBy.php @@ -45,7 +45,7 @@ class RebloggedBy extends BaseApi } if (!$post = Post::selectOriginal(['uri-id'], ['uri-id' => $this->parameters['id'], 'uid' => [0, $uid]])) { - DI::mstdnError()->RecordNotFound(); + $this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound()); } $activities = Post::selectPosts(['author-id'], ['thr-parent-id' => $post['uri-id'], 'gravity' => Item::GRAVITY_ACTIVITY, 'verb' => Activity::ANNOUNCE]); diff --git a/src/Module/Api/Mastodon/Statuses/Unbookmark.php b/src/Module/Api/Mastodon/Statuses/Unbookmark.php index 36902fb21..4eccc97b2 100644 --- a/src/Module/Api/Mastodon/Statuses/Unbookmark.php +++ b/src/Module/Api/Mastodon/Statuses/Unbookmark.php @@ -44,7 +44,7 @@ class Unbookmark extends BaseApi $item = Post::selectOriginal(['uid', 'id', 'uri-id', 'gravity'], ['uri-id' => $this->parameters['id'], 'uid' => [$uid, 0]], ['order' => ['uid' => true]]); if (!DBA::isResult($item)) { - DI::mstdnError()->RecordNotFound(); + $this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound()); } if ($item['gravity'] != Item::GRAVITY_PARENT) { @@ -56,10 +56,10 @@ class Unbookmark extends BaseApi if (!empty($stored)) { $item = Post::selectFirst(['id', 'gravity'], ['id' => $stored]); if (!DBA::isResult($item)) { - DI::mstdnError()->RecordNotFound(); + $this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound()); } } else { - DI::mstdnError()->RecordNotFound(); + $this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound()); } } diff --git a/src/Module/Api/Mastodon/Statuses/Unfavourite.php b/src/Module/Api/Mastodon/Statuses/Unfavourite.php index c6a924b2a..ada587b2f 100644 --- a/src/Module/Api/Mastodon/Statuses/Unfavourite.php +++ b/src/Module/Api/Mastodon/Statuses/Unfavourite.php @@ -44,7 +44,7 @@ class Unfavourite extends BaseApi $item = Post::selectOriginalForUser($uid, ['id', 'uri-id'], ['uri-id' => $this->parameters['id'], 'uid' => [$uid, 0]]); if (!DBA::isResult($item)) { - DI::mstdnError()->RecordNotFound(); + $this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound()); } Item::performActivity($item['id'], 'unlike', $uid); diff --git a/src/Module/Api/Mastodon/Statuses/Unmute.php b/src/Module/Api/Mastodon/Statuses/Unmute.php index edf14925d..511ae1540 100644 --- a/src/Module/Api/Mastodon/Statuses/Unmute.php +++ b/src/Module/Api/Mastodon/Statuses/Unmute.php @@ -44,7 +44,7 @@ class Unmute extends BaseApi $item = Post::selectOriginalForUser($uid, ['uri-id', 'gravity'], ['uri-id' => $this->parameters['id'], 'uid' => [$uid, 0]]); if (!DBA::isResult($item)) { - DI::mstdnError()->RecordNotFound(); + $this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound()); } if ($item['gravity'] != Item::GRAVITY_PARENT) { diff --git a/src/Module/Api/Mastodon/Statuses/Unpin.php b/src/Module/Api/Mastodon/Statuses/Unpin.php index 0f5d44afa..c11f89f6e 100644 --- a/src/Module/Api/Mastodon/Statuses/Unpin.php +++ b/src/Module/Api/Mastodon/Statuses/Unpin.php @@ -43,7 +43,7 @@ class Unpin extends BaseApi $item = Post::selectOriginalForUser($uid, ['uri-id', 'gravity'], ['uri-id' => $this->parameters['id'], 'uid' => [$uid, 0]]); if (!DBA::isResult($item)) { - DI::mstdnError()->RecordNotFound(); + $this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound()); } Post\Collection::remove($item['uri-id'], Post\Collection::FEATURED, $uid); diff --git a/src/Module/Api/Mastodon/Statuses/Unreblog.php b/src/Module/Api/Mastodon/Statuses/Unreblog.php index 4f72eac25..c99011ae4 100644 --- a/src/Module/Api/Mastodon/Statuses/Unreblog.php +++ b/src/Module/Api/Mastodon/Statuses/Unreblog.php @@ -46,17 +46,17 @@ class Unreblog extends BaseApi $item = Post::selectOriginalForUser($uid, ['id', 'uri-id', 'network'], ['uri-id' => $this->parameters['id'], 'uid' => [$uid, 0]]); if (!DBA::isResult($item)) { - DI::mstdnError()->RecordNotFound(); + $this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound()); } if ($item['network'] == Protocol::DIASPORA) { $item = Post::selectFirstForUser($uid, ['id'], ['quote-uri-id' => $this->parameters['id'], 'body' => '', 'origin' => true, 'uid' => $uid]); if (empty($item['id'])) { - DI::mstdnError()->RecordNotFound(); + $this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound()); } if (!Item::markForDeletionById($item['id'])) { - DI::mstdnError()->RecordNotFound(); + $this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound()); } } elseif (!in_array($item['network'], [Protocol::DFRN, Protocol::ACTIVITYPUB, Protocol::TWITTER])) { DI::mstdnError()->UnprocessableEntity(DI::l10n()->t("Posts from %s can't be unshared", ContactSelector::networkToName($item['network']))); diff --git a/src/Module/Api/Mastodon/Timelines/Direct.php b/src/Module/Api/Mastodon/Timelines/Direct.php index c1e710970..730b63910 100644 --- a/src/Module/Api/Mastodon/Timelines/Direct.php +++ b/src/Module/Api/Mastodon/Timelines/Direct.php @@ -26,6 +26,7 @@ use Friendica\Database\DBA; use Friendica\DI; use Friendica\Module\BaseApi; use Friendica\Network\HTTPException; +use Friendica\Network\HTTPException\NotFoundException; /** * @see https://docs.joinmastodon.org/methods/timelines/ @@ -76,9 +77,13 @@ class Direct extends BaseApi $statuses = []; - while ($mail = DBA::fetch($mails)) { - self::setBoundaries($mail['uri-id']); - $statuses[] = DI::mstdnStatus()->createFromMailId($mail['id']); + try { + while ($mail = DBA::fetch($mails)) { + self::setBoundaries($mail['uri-id']); + $statuses[] = DI::mstdnStatus()->createFromMailId($mail['id']); + } + } catch (NotFoundException $e) { + $this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound()); } if (!empty($request['min_id'])) { From 7486ebdc10715b7204b70ce262052d28cb61c69e Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Wed, 11 Oct 2023 09:20:49 -0400 Subject: [PATCH 04/10] Move jsonError out of Factory\Api\Mastodon\Error->UnprocessableEntity --- src/Factory/Api/Mastodon/Error.php | 7 ++----- src/Module/Api/Friendica/Statuses/Dislike.php | 2 +- src/Module/Api/Friendica/Statuses/DislikedBy.php | 2 +- src/Module/Api/Friendica/Statuses/Undislike.php | 2 +- src/Module/Api/Mastodon/Accounts.php | 2 +- src/Module/Api/Mastodon/Accounts/Block.php | 2 +- src/Module/Api/Mastodon/Accounts/Follow.php | 2 +- src/Module/Api/Mastodon/Accounts/Followers.php | 2 +- src/Module/Api/Mastodon/Accounts/Following.php | 2 +- src/Module/Api/Mastodon/Accounts/Lists.php | 2 +- src/Module/Api/Mastodon/Accounts/Mute.php | 2 +- src/Module/Api/Mastodon/Accounts/Note.php | 2 +- src/Module/Api/Mastodon/Accounts/Relationships.php | 2 +- src/Module/Api/Mastodon/Accounts/Statuses.php | 2 +- src/Module/Api/Mastodon/Accounts/Unblock.php | 2 +- src/Module/Api/Mastodon/Accounts/Unfollow.php | 2 +- src/Module/Api/Mastodon/Accounts/Unmute.php | 2 +- src/Module/Api/Mastodon/Apps.php | 2 +- src/Module/Api/Mastodon/Conversations.php | 2 +- src/Module/Api/Mastodon/Conversations/Read.php | 2 +- src/Module/Api/Mastodon/Lists.php | 6 +++--- src/Module/Api/Mastodon/Lists/Accounts.php | 6 +++--- src/Module/Api/Mastodon/Markers.php | 2 +- src/Module/Api/Mastodon/Media.php | 8 ++++---- src/Module/Api/Mastodon/Mutes.php | 2 +- src/Module/Api/Mastodon/Notifications/Dismiss.php | 2 +- src/Module/Api/Mastodon/Polls.php | 2 +- src/Module/Api/Mastodon/ScheduledStatuses.php | 2 +- src/Module/Api/Mastodon/Search.php | 2 +- src/Module/Api/Mastodon/Statuses.php | 4 ++-- src/Module/Api/Mastodon/Statuses/Bookmark.php | 4 ++-- src/Module/Api/Mastodon/Statuses/Card.php | 2 +- src/Module/Api/Mastodon/Statuses/Context.php | 2 +- src/Module/Api/Mastodon/Statuses/Favourite.php | 2 +- src/Module/Api/Mastodon/Statuses/FavouritedBy.php | 2 +- src/Module/Api/Mastodon/Statuses/Mute.php | 4 ++-- src/Module/Api/Mastodon/Statuses/Pin.php | 2 +- src/Module/Api/Mastodon/Statuses/Reblog.php | 7 +++++-- src/Module/Api/Mastodon/Statuses/RebloggedBy.php | 2 +- src/Module/Api/Mastodon/Statuses/Source.php | 2 +- src/Module/Api/Mastodon/Statuses/Unbookmark.php | 4 ++-- src/Module/Api/Mastodon/Statuses/Unfavourite.php | 2 +- src/Module/Api/Mastodon/Statuses/Unmute.php | 4 ++-- src/Module/Api/Mastodon/Statuses/Unpin.php | 2 +- src/Module/Api/Mastodon/Statuses/Unreblog.php | 7 +++++-- src/Module/Api/Mastodon/Tags.php | 2 +- src/Module/Api/Mastodon/Tags/Follow.php | 2 +- src/Module/Api/Mastodon/Tags/Unfollow.php | 2 +- src/Module/Api/Mastodon/Timelines/ListTimeline.php | 2 +- src/Module/Api/Mastodon/Timelines/Tag.php | 2 +- src/Module/OAuth/Authorize.php | 8 ++++---- src/Module/OAuth/Token.php | 2 +- 52 files changed, 76 insertions(+), 73 deletions(-) diff --git a/src/Factory/Api/Mastodon/Error.php b/src/Factory/Api/Mastodon/Error.php index dec56ba90..1dad4d9c8 100644 --- a/src/Factory/Api/Mastodon/Error.php +++ b/src/Factory/Api/Mastodon/Error.php @@ -57,14 +57,11 @@ class Error extends BaseFactory return new \Friendica\Object\Api\Mastodon\Error($error, $error_description); } - public function UnprocessableEntity(string $error = '') + public function UnprocessableEntity(string $error = ''): \Friendica\Object\Api\Mastodon\Error { $error = $error ?: $this->l10n->t('Unprocessable Entity'); $error_description = ''; - $errorObj = new \Friendica\Object\Api\Mastodon\Error($error, $error_description); - - $this->logError(422, $error); - $this->jsonError(422, $errorObj->toArray()); + return new \Friendica\Object\Api\Mastodon\Error($error, $error_description); } public function Unauthorized(string $error = '', string $error_description = '') diff --git a/src/Module/Api/Friendica/Statuses/Dislike.php b/src/Module/Api/Friendica/Statuses/Dislike.php index a0dcd7077..99c8eb857 100644 --- a/src/Module/Api/Friendica/Statuses/Dislike.php +++ b/src/Module/Api/Friendica/Statuses/Dislike.php @@ -39,7 +39,7 @@ class Dislike extends BaseApi $uid = self::getCurrentUserID(); if (empty($this->parameters['id'])) { - DI::mstdnError()->UnprocessableEntity(); + $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity()); } $item = Post::selectFirstForUser($uid, ['id'], ['uri-id' => $this->parameters['id'], 'uid' => [$uid, 0]]); diff --git a/src/Module/Api/Friendica/Statuses/DislikedBy.php b/src/Module/Api/Friendica/Statuses/DislikedBy.php index fcae9990c..3c1312087 100644 --- a/src/Module/Api/Friendica/Statuses/DislikedBy.php +++ b/src/Module/Api/Friendica/Statuses/DislikedBy.php @@ -41,7 +41,7 @@ class DislikedBy extends BaseApi $uid = self::getCurrentUserID(); if (empty($this->parameters['id'])) { - DI::mstdnError()->UnprocessableEntity(); + $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity()); } $id = $this->parameters['id']; diff --git a/src/Module/Api/Friendica/Statuses/Undislike.php b/src/Module/Api/Friendica/Statuses/Undislike.php index f304fb9db..5387f1b10 100644 --- a/src/Module/Api/Friendica/Statuses/Undislike.php +++ b/src/Module/Api/Friendica/Statuses/Undislike.php @@ -39,7 +39,7 @@ class Undislike extends BaseApi $uid = self::getCurrentUserID(); if (empty($this->parameters['id'])) { - DI::mstdnError()->UnprocessableEntity(); + $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity()); } $item = Post::selectFirstForUser($uid, ['id'], ['uri-id' => $this->parameters['id'], 'uid' => [$uid, 0]]); diff --git a/src/Module/Api/Mastodon/Accounts.php b/src/Module/Api/Mastodon/Accounts.php index 4ebd0d4bd..6b88b84ef 100644 --- a/src/Module/Api/Mastodon/Accounts.php +++ b/src/Module/Api/Mastodon/Accounts.php @@ -40,7 +40,7 @@ class Accounts extends BaseApi $uid = self::getCurrentUserID(); if (empty($this->parameters['id']) && empty($this->parameters['name'])) { - DI::mstdnError()->UnprocessableEntity(); + $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity()); } if (!empty($this->parameters['id'])) { diff --git a/src/Module/Api/Mastodon/Accounts/Block.php b/src/Module/Api/Mastodon/Accounts/Block.php index 1ddafda56..1582f3299 100644 --- a/src/Module/Api/Mastodon/Accounts/Block.php +++ b/src/Module/Api/Mastodon/Accounts/Block.php @@ -38,7 +38,7 @@ class Block extends BaseApi $uid = self::getCurrentUserID(); if (empty($this->parameters['id'])) { - DI::mstdnError()->UnprocessableEntity(); + $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity()); } Contact\User::setBlocked($this->parameters['id'], $uid, true); diff --git a/src/Module/Api/Mastodon/Accounts/Follow.php b/src/Module/Api/Mastodon/Accounts/Follow.php index a666f2f91..272b989ee 100644 --- a/src/Module/Api/Mastodon/Accounts/Follow.php +++ b/src/Module/Api/Mastodon/Accounts/Follow.php @@ -37,7 +37,7 @@ class Follow extends BaseApi $uid = self::getCurrentUserID(); if (empty($this->parameters['id'])) { - DI::mstdnError()->UnprocessableEntity(); + $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity()); } $request = $this->getRequest([ diff --git a/src/Module/Api/Mastodon/Accounts/Followers.php b/src/Module/Api/Mastodon/Accounts/Followers.php index 22b99ee4d..19f2a4388 100644 --- a/src/Module/Api/Mastodon/Accounts/Followers.php +++ b/src/Module/Api/Mastodon/Accounts/Followers.php @@ -41,7 +41,7 @@ class Followers extends BaseApi $uid = self::getCurrentUserID(); if (empty($this->parameters['id'])) { - DI::mstdnError()->UnprocessableEntity(); + $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity()); } $id = $this->parameters['id']; diff --git a/src/Module/Api/Mastodon/Accounts/Following.php b/src/Module/Api/Mastodon/Accounts/Following.php index 0fde1404e..061e22663 100644 --- a/src/Module/Api/Mastodon/Accounts/Following.php +++ b/src/Module/Api/Mastodon/Accounts/Following.php @@ -41,7 +41,7 @@ class Following extends BaseApi $uid = self::getCurrentUserID(); if (empty($this->parameters['id'])) { - DI::mstdnError()->UnprocessableEntity(); + $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity()); } $id = $this->parameters['id']; diff --git a/src/Module/Api/Mastodon/Accounts/Lists.php b/src/Module/Api/Mastodon/Accounts/Lists.php index f0187a286..8fdcade66 100644 --- a/src/Module/Api/Mastodon/Accounts/Lists.php +++ b/src/Module/Api/Mastodon/Accounts/Lists.php @@ -41,7 +41,7 @@ class Lists extends BaseApi $uid = self::getCurrentUserID(); if (empty($this->parameters['id'])) { - DI::mstdnError()->UnprocessableEntity(); + $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity()); } $id = $this->parameters['id']; diff --git a/src/Module/Api/Mastodon/Accounts/Mute.php b/src/Module/Api/Mastodon/Accounts/Mute.php index 4169cb90f..ea8d0ce30 100644 --- a/src/Module/Api/Mastodon/Accounts/Mute.php +++ b/src/Module/Api/Mastodon/Accounts/Mute.php @@ -37,7 +37,7 @@ class Mute extends BaseApi $uid = self::getCurrentUserID(); if (empty($this->parameters['id'])) { - DI::mstdnError()->UnprocessableEntity(); + $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity()); } Contact\User::setIgnored($this->parameters['id'], $uid, true); diff --git a/src/Module/Api/Mastodon/Accounts/Note.php b/src/Module/Api/Mastodon/Accounts/Note.php index 52c76ab69..72a7e0838 100644 --- a/src/Module/Api/Mastodon/Accounts/Note.php +++ b/src/Module/Api/Mastodon/Accounts/Note.php @@ -38,7 +38,7 @@ class Note extends BaseApi $uid = self::getCurrentUserID(); if (empty($this->parameters['id'])) { - DI::mstdnError()->UnprocessableEntity(); + $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity()); } $request = $this->getRequest([ diff --git a/src/Module/Api/Mastodon/Accounts/Relationships.php b/src/Module/Api/Mastodon/Accounts/Relationships.php index 4ae5b0669..f75715172 100644 --- a/src/Module/Api/Mastodon/Accounts/Relationships.php +++ b/src/Module/Api/Mastodon/Accounts/Relationships.php @@ -44,7 +44,7 @@ class Relationships extends BaseApi ], $request); if (empty($request['id'])) { - DI::mstdnError()->UnprocessableEntity(); + $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity()); } if (!is_array($request['id'])) { diff --git a/src/Module/Api/Mastodon/Accounts/Statuses.php b/src/Module/Api/Mastodon/Accounts/Statuses.php index 599a2eff8..fd8fbcdab 100644 --- a/src/Module/Api/Mastodon/Accounts/Statuses.php +++ b/src/Module/Api/Mastodon/Accounts/Statuses.php @@ -47,7 +47,7 @@ class Statuses extends BaseApi $uid = self::getCurrentUserID(); if (empty($this->parameters['id'])) { - DI::mstdnError()->UnprocessableEntity(); + $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity()); } $id = $this->parameters['id']; diff --git a/src/Module/Api/Mastodon/Accounts/Unblock.php b/src/Module/Api/Mastodon/Accounts/Unblock.php index 8d8fb3e39..f2e2f2e41 100644 --- a/src/Module/Api/Mastodon/Accounts/Unblock.php +++ b/src/Module/Api/Mastodon/Accounts/Unblock.php @@ -37,7 +37,7 @@ class Unblock extends BaseApi $uid = self::getCurrentUserID(); if (empty($this->parameters['id'])) { - DI::mstdnError()->UnprocessableEntity(); + $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity()); } Contact\User::setBlocked($this->parameters['id'], $uid, false); diff --git a/src/Module/Api/Mastodon/Accounts/Unfollow.php b/src/Module/Api/Mastodon/Accounts/Unfollow.php index cfe3b3cb1..6a3c68cb3 100644 --- a/src/Module/Api/Mastodon/Accounts/Unfollow.php +++ b/src/Module/Api/Mastodon/Accounts/Unfollow.php @@ -37,7 +37,7 @@ class Unfollow extends BaseApi $uid = self::getCurrentUserID(); if (empty($this->parameters['id'])) { - DI::mstdnError()->UnprocessableEntity(); + $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity()); } $cdata = Contact::getPublicAndUserContactID($this->parameters['id'], $uid); diff --git a/src/Module/Api/Mastodon/Accounts/Unmute.php b/src/Module/Api/Mastodon/Accounts/Unmute.php index 7708e1472..651233dae 100644 --- a/src/Module/Api/Mastodon/Accounts/Unmute.php +++ b/src/Module/Api/Mastodon/Accounts/Unmute.php @@ -37,7 +37,7 @@ class Unmute extends BaseApi $uid = self::getCurrentUserID(); if (empty($this->parameters['id'])) { - DI::mstdnError()->UnprocessableEntity(); + $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity()); } Contact\User::setIgnored($this->parameters['id'], $uid, false); diff --git a/src/Module/Api/Mastodon/Apps.php b/src/Module/Api/Mastodon/Apps.php index d51a8e7b0..9d6729216 100644 --- a/src/Module/Api/Mastodon/Apps.php +++ b/src/Module/Api/Mastodon/Apps.php @@ -70,7 +70,7 @@ class Apps extends BaseApi } if (empty($request['client_name']) || empty($request['redirect_uris'])) { - DI::mstdnError()->UnprocessableEntity(DI::l10n()->t('Missing parameters')); + $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity($this->t('Missing parameters'))); } $client_id = bin2hex(random_bytes(32)); diff --git a/src/Module/Api/Mastodon/Conversations.php b/src/Module/Api/Mastodon/Conversations.php index c45144c98..532db4bcd 100644 --- a/src/Module/Api/Mastodon/Conversations.php +++ b/src/Module/Api/Mastodon/Conversations.php @@ -38,7 +38,7 @@ class Conversations extends BaseApi $uid = self::getCurrentUserID(); if (!empty($this->parameters['id'])) { - DI::mstdnError()->UnprocessableEntity(); + $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity()); } DBA::delete('conv', ['id' => $this->parameters['id'], 'uid' => $uid]); diff --git a/src/Module/Api/Mastodon/Conversations/Read.php b/src/Module/Api/Mastodon/Conversations/Read.php index 86a5090e3..2e876fcb5 100644 --- a/src/Module/Api/Mastodon/Conversations/Read.php +++ b/src/Module/Api/Mastodon/Conversations/Read.php @@ -38,7 +38,7 @@ class Read extends BaseApi $uid = self::getCurrentUserID(); if (!empty($this->parameters['id'])) { - DI::mstdnError()->UnprocessableEntity(); + $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity()); } DBA::update('mail', ['seen' => true], ['convid' => $this->parameters['id'], 'uid' => $uid]); diff --git a/src/Module/Api/Mastodon/Lists.php b/src/Module/Api/Mastodon/Lists.php index 9d9e6955b..beb1a3b9a 100644 --- a/src/Module/Api/Mastodon/Lists.php +++ b/src/Module/Api/Mastodon/Lists.php @@ -37,7 +37,7 @@ class Lists extends BaseApi $uid = self::getCurrentUserID(); if (empty($this->parameters['id'])) { - DI::mstdnError()->UnprocessableEntity(); + $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity()); } if (!Circle::exists($this->parameters['id'], $uid)) { @@ -61,7 +61,7 @@ class Lists extends BaseApi ], $request); if (empty($request['title'])) { - DI::mstdnError()->UnprocessableEntity(); + $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity()); } Circle::create($uid, $request['title']); @@ -82,7 +82,7 @@ class Lists extends BaseApi ], $request); if (empty($request['title']) || empty($this->parameters['id'])) { - DI::mstdnError()->UnprocessableEntity(); + $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity()); } Circle::update($this->parameters['id'], $request['title']); diff --git a/src/Module/Api/Mastodon/Lists/Accounts.php b/src/Module/Api/Mastodon/Lists/Accounts.php index ffa63caf4..f72f8cad8 100644 --- a/src/Module/Api/Mastodon/Lists/Accounts.php +++ b/src/Module/Api/Mastodon/Lists/Accounts.php @@ -43,7 +43,7 @@ class Accounts extends BaseApi ], $request); if (empty($request['account_ids']) || empty($this->parameters['id'])) { - DI::mstdnError()->UnprocessableEntity(); + $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity()); } return Circle::removeMembers($this->parameters['id'], $request['account_ids']); @@ -58,7 +58,7 @@ class Accounts extends BaseApi ], $request); if (empty($request['account_ids']) || empty($this->parameters['id'])) { - DI::mstdnError()->UnprocessableEntity(); + $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity()); } Circle::addMembers($this->parameters['id'], $request['account_ids']); @@ -73,7 +73,7 @@ class Accounts extends BaseApi $uid = self::getCurrentUserID(); if (empty($this->parameters['id'])) { - DI::mstdnError()->UnprocessableEntity(); + $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity()); } $id = $this->parameters['id']; diff --git a/src/Module/Api/Mastodon/Markers.php b/src/Module/Api/Mastodon/Markers.php index eb19acf8e..25b56d72e 100644 --- a/src/Module/Api/Mastodon/Markers.php +++ b/src/Module/Api/Mastodon/Markers.php @@ -48,7 +48,7 @@ class Markers extends BaseApi } if (empty($timeline) || empty($last_read_id) || empty($application['id'])) { - DI::mstdnError()->UnprocessableEntity(); + $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity()); } $condition = ['application-id' => $application['id'], 'uid' => $uid, 'timeline' => $timeline]; diff --git a/src/Module/Api/Mastodon/Media.php b/src/Module/Api/Mastodon/Media.php index 91c88ee18..738feab7c 100644 --- a/src/Module/Api/Mastodon/Media.php +++ b/src/Module/Api/Mastodon/Media.php @@ -48,12 +48,12 @@ class Media extends BaseApi Logger::info('Photo post', ['request' => $request, 'files' => $_FILES]); if (empty($_FILES['file'])) { - DI::mstdnError()->UnprocessableEntity(); + $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity()); } $media = Photo::upload($uid, $_FILES['file'], '', null, null, '', '', $request['description']); if (empty($media)) { - DI::mstdnError()->UnprocessableEntity(); + $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity()); } Logger::info('Uploaded photo', ['media' => $media]); @@ -74,7 +74,7 @@ class Media extends BaseApi ], $request); if (empty($this->parameters['id'])) { - DI::mstdnError()->UnprocessableEntity(); + $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity()); } $photo = Photo::selectFirst(['resource-id'], ['id' => $this->parameters['id'], 'uid' => $uid]); @@ -104,7 +104,7 @@ class Media extends BaseApi $uid = self::getCurrentUserID(); if (empty($this->parameters['id'])) { - DI::mstdnError()->UnprocessableEntity(); + $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity()); } $id = $this->parameters['id']; diff --git a/src/Module/Api/Mastodon/Mutes.php b/src/Module/Api/Mastodon/Mutes.php index 71b1949f5..6557b770b 100644 --- a/src/Module/Api/Mastodon/Mutes.php +++ b/src/Module/Api/Mastodon/Mutes.php @@ -40,7 +40,7 @@ class Mutes extends BaseApi $uid = self::getCurrentUserID(); if (empty($this->parameters['id'])) { - DI::mstdnError()->UnprocessableEntity(); + $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity()); } $id = $this->parameters['id']; diff --git a/src/Module/Api/Mastodon/Notifications/Dismiss.php b/src/Module/Api/Mastodon/Notifications/Dismiss.php index 50d1be27b..cc8947972 100644 --- a/src/Module/Api/Mastodon/Notifications/Dismiss.php +++ b/src/Module/Api/Mastodon/Notifications/Dismiss.php @@ -38,7 +38,7 @@ class Dismiss extends BaseApi $uid = self::getCurrentUserID(); if (empty($this->parameters['id'])) { - DI::mstdnError()->UnprocessableEntity(); + $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity()); } $condition = ['id' => $this->parameters['id']]; diff --git a/src/Module/Api/Mastodon/Polls.php b/src/Module/Api/Mastodon/Polls.php index c43bdf510..a5e4fb33a 100644 --- a/src/Module/Api/Mastodon/Polls.php +++ b/src/Module/Api/Mastodon/Polls.php @@ -39,7 +39,7 @@ class Polls extends BaseApi $uid = self::getCurrentUserID(); if (empty($this->parameters['id'])) { - DI::mstdnError()->UnprocessableEntity(); + $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity()); } $this->jsonExit(DI::mstdnPoll()->createFromId($this->parameters['id'], $uid)); diff --git a/src/Module/Api/Mastodon/ScheduledStatuses.php b/src/Module/Api/Mastodon/ScheduledStatuses.php index f136c2708..cedafb8ab 100644 --- a/src/Module/Api/Mastodon/ScheduledStatuses.php +++ b/src/Module/Api/Mastodon/ScheduledStatuses.php @@ -47,7 +47,7 @@ class ScheduledStatuses extends BaseApi $uid = self::getCurrentUserID(); if (empty($this->parameters['id'])) { - DI::mstdnError()->UnprocessableEntity(); + $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity()); } if (!DBA::exists('delayed-post', ['id' => $this->parameters['id'], 'uid' => $uid])) { diff --git a/src/Module/Api/Mastodon/Search.php b/src/Module/Api/Mastodon/Search.php index ec4527f00..fb222beff 100644 --- a/src/Module/Api/Mastodon/Search.php +++ b/src/Module/Api/Mastodon/Search.php @@ -60,7 +60,7 @@ class Search extends BaseApi ], $request); if (empty($request['q'])) { - DI::mstdnError()->UnprocessableEntity(); + $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity()); } $limit = min($request['limit'], 40); diff --git a/src/Module/Api/Mastodon/Statuses.php b/src/Module/Api/Mastodon/Statuses.php index 0940befba..def4d51f6 100644 --- a/src/Module/Api/Mastodon/Statuses.php +++ b/src/Module/Api/Mastodon/Statuses.php @@ -319,7 +319,7 @@ class Statuses extends BaseApi $uid = self::getCurrentUserID(); if (empty($this->parameters['id'])) { - DI::mstdnError()->UnprocessableEntity(); + $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity()); } $item = Post::selectFirstForUser($uid, ['id'], ['uri-id' => $this->parameters['id'], 'uid' => $uid]); @@ -342,7 +342,7 @@ class Statuses extends BaseApi $uid = self::getCurrentUserID(); if (empty($this->parameters['id'])) { - DI::mstdnError()->UnprocessableEntity(); + $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity()); } $this->jsonExit(DI::mstdnStatus()->createFromUriId($this->parameters['id'], $uid, self::appSupportsQuotes(), false)); diff --git a/src/Module/Api/Mastodon/Statuses/Bookmark.php b/src/Module/Api/Mastodon/Statuses/Bookmark.php index 1ba0d6e04..cdbdcb6e6 100644 --- a/src/Module/Api/Mastodon/Statuses/Bookmark.php +++ b/src/Module/Api/Mastodon/Statuses/Bookmark.php @@ -39,7 +39,7 @@ class Bookmark extends BaseApi $uid = self::getCurrentUserID(); if (empty($this->parameters['id'])) { - DI::mstdnError()->UnprocessableEntity(); + $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity()); } $item = Post::selectOriginal(['uid', 'id', 'uri-id', 'gravity'], ['uri-id' => $this->parameters['id'], 'uid' => [$uid, 0]], ['order' => ['uid' => true]]); @@ -48,7 +48,7 @@ class Bookmark extends BaseApi } if ($item['gravity'] != Item::GRAVITY_PARENT) { - DI::mstdnError()->UnprocessableEntity(DI::l10n()->t('Only starting posts can be bookmarked')); + $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity($this->t('Only starting posts can be bookmarked'))); } if ($item['uid'] == 0) { diff --git a/src/Module/Api/Mastodon/Statuses/Card.php b/src/Module/Api/Mastodon/Statuses/Card.php index 193bb7b0c..ea5705186 100644 --- a/src/Module/Api/Mastodon/Statuses/Card.php +++ b/src/Module/Api/Mastodon/Statuses/Card.php @@ -40,7 +40,7 @@ class Card extends BaseApi $uid = self::getCurrentUserID(); if (empty($this->parameters['id'])) { - DI::mstdnError()->UnprocessableEntity(); + $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity()); } if (!$post = Post::selectOriginal(['uri-id'], ['uri-id' => $this->parameters['id'], 'uid' => [0, $uid]])) { diff --git a/src/Module/Api/Mastodon/Statuses/Context.php b/src/Module/Api/Mastodon/Statuses/Context.php index c171c0cca..dbce15058 100644 --- a/src/Module/Api/Mastodon/Statuses/Context.php +++ b/src/Module/Api/Mastodon/Statuses/Context.php @@ -41,7 +41,7 @@ class Context extends BaseApi $uid = self::getCurrentUserID(); if (empty($this->parameters['id'])) { - DI::mstdnError()->UnprocessableEntity(); + $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity()); } $request = $this->getRequest([ diff --git a/src/Module/Api/Mastodon/Statuses/Favourite.php b/src/Module/Api/Mastodon/Statuses/Favourite.php index 384abc3d8..103de8679 100644 --- a/src/Module/Api/Mastodon/Statuses/Favourite.php +++ b/src/Module/Api/Mastodon/Statuses/Favourite.php @@ -39,7 +39,7 @@ class Favourite extends BaseApi $uid = self::getCurrentUserID(); if (empty($this->parameters['id'])) { - DI::mstdnError()->UnprocessableEntity(); + $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity()); } $item = Post::selectOriginalForUser($uid, ['id', 'uri-id'], ['uri-id' => $this->parameters['id'], 'uid' => [$uid, 0]]); diff --git a/src/Module/Api/Mastodon/Statuses/FavouritedBy.php b/src/Module/Api/Mastodon/Statuses/FavouritedBy.php index bce95610a..d91eff0b8 100644 --- a/src/Module/Api/Mastodon/Statuses/FavouritedBy.php +++ b/src/Module/Api/Mastodon/Statuses/FavouritedBy.php @@ -41,7 +41,7 @@ class FavouritedBy extends BaseApi $uid = self::getCurrentUserID(); if (empty($this->parameters['id'])) { - DI::mstdnError()->UnprocessableEntity(); + $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity()); } if (!$post = Post::selectOriginal(['uri-id'], ['uri-id' => $this->parameters['id'], 'uid' => [0, $uid]])) { diff --git a/src/Module/Api/Mastodon/Statuses/Mute.php b/src/Module/Api/Mastodon/Statuses/Mute.php index 68491c8b7..0931cd733 100644 --- a/src/Module/Api/Mastodon/Statuses/Mute.php +++ b/src/Module/Api/Mastodon/Statuses/Mute.php @@ -39,7 +39,7 @@ class Mute extends BaseApi $uid = self::getCurrentUserID(); if (empty($this->parameters['id'])) { - DI::mstdnError()->UnprocessableEntity(); + $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity()); } $item = Post::selectOriginalForUser($uid, ['uri-id', 'gravity'], ['uri-id' => $this->parameters['id'], 'uid' => [$uid, 0]]); @@ -48,7 +48,7 @@ class Mute extends BaseApi } if ($item['gravity'] != Item::GRAVITY_PARENT) { - DI::mstdnError()->UnprocessableEntity(DI::l10n()->t('Only starting posts can be muted')); + $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity($this->t('Only starting posts can be muted'))); } Post\ThreadUser::setIgnored($item['uri-id'], $uid, true); diff --git a/src/Module/Api/Mastodon/Statuses/Pin.php b/src/Module/Api/Mastodon/Statuses/Pin.php index 99f097740..fbd2f00ce 100644 --- a/src/Module/Api/Mastodon/Statuses/Pin.php +++ b/src/Module/Api/Mastodon/Statuses/Pin.php @@ -38,7 +38,7 @@ class Pin extends BaseApi $uid = self::getCurrentUserID(); if (empty($this->parameters['id'])) { - DI::mstdnError()->UnprocessableEntity(); + $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity()); } $item = Post::selectOriginalForUser($uid, ['uri-id', 'gravity', 'author-id'], ['uri-id' => $this->parameters['id'], 'uid' => [$uid, 0]]); diff --git a/src/Module/Api/Mastodon/Statuses/Reblog.php b/src/Module/Api/Mastodon/Statuses/Reblog.php index 3e37a94a7..54ada1d1f 100644 --- a/src/Module/Api/Mastodon/Statuses/Reblog.php +++ b/src/Module/Api/Mastodon/Statuses/Reblog.php @@ -42,7 +42,7 @@ class Reblog extends BaseApi $uid = self::getCurrentUserID(); if (empty($this->parameters['id'])) { - DI::mstdnError()->UnprocessableEntity(); + $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity()); } $item = Post::selectOriginalForUser($uid, ['id', 'uri-id', 'network'], ['uri-id' => $this->parameters['id'], 'uid' => [$uid, 0]]); @@ -53,7 +53,10 @@ class Reblog extends BaseApi if ($item['network'] == Protocol::DIASPORA) { Diaspora::performReshare($this->parameters['id'], $uid); } elseif (!in_array($item['network'], [Protocol::DFRN, Protocol::ACTIVITYPUB, Protocol::TWITTER])) { - DI::mstdnError()->UnprocessableEntity(DI::l10n()->t("Posts from %s can't be shared", ContactSelector::networkToName($item['network']))); + $this->logErrorAndJsonExit( + 422, + $this->errorFactory->UnprocessableEntity($this->t("Posts from %s can't be shared", ContactSelector::networkToName($item['network']))) + ); } else { Item::performActivity($item['id'], 'announce', $uid); } diff --git a/src/Module/Api/Mastodon/Statuses/RebloggedBy.php b/src/Module/Api/Mastodon/Statuses/RebloggedBy.php index 9c508e42a..eab40c665 100644 --- a/src/Module/Api/Mastodon/Statuses/RebloggedBy.php +++ b/src/Module/Api/Mastodon/Statuses/RebloggedBy.php @@ -41,7 +41,7 @@ class RebloggedBy extends BaseApi $uid = self::getCurrentUserID(); if (empty($this->parameters['id'])) { - DI::mstdnError()->UnprocessableEntity(); + $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity()); } if (!$post = Post::selectOriginal(['uri-id'], ['uri-id' => $this->parameters['id'], 'uid' => [0, $uid]])) { diff --git a/src/Module/Api/Mastodon/Statuses/Source.php b/src/Module/Api/Mastodon/Statuses/Source.php index 408df3aad..1e72f33a0 100644 --- a/src/Module/Api/Mastodon/Statuses/Source.php +++ b/src/Module/Api/Mastodon/Statuses/Source.php @@ -41,7 +41,7 @@ class Source extends BaseApi $uid = self::getCurrentUserID(); if (empty($this->parameters['id'])) { - DI::mstdnError()->UnprocessableEntity(); + $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity()); } $id = $this->parameters['id']; diff --git a/src/Module/Api/Mastodon/Statuses/Unbookmark.php b/src/Module/Api/Mastodon/Statuses/Unbookmark.php index 4eccc97b2..c64a6c8a7 100644 --- a/src/Module/Api/Mastodon/Statuses/Unbookmark.php +++ b/src/Module/Api/Mastodon/Statuses/Unbookmark.php @@ -39,7 +39,7 @@ class Unbookmark extends BaseApi $uid = self::getCurrentUserID(); if (empty($this->parameters['id'])) { - DI::mstdnError()->UnprocessableEntity(); + $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity()); } $item = Post::selectOriginal(['uid', 'id', 'uri-id', 'gravity'], ['uri-id' => $this->parameters['id'], 'uid' => [$uid, 0]], ['order' => ['uid' => true]]); @@ -48,7 +48,7 @@ class Unbookmark extends BaseApi } if ($item['gravity'] != Item::GRAVITY_PARENT) { - DI::mstdnError()->UnprocessableEntity(DI::l10n()->t('Only starting posts can be unbookmarked')); + $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity($this->t('Only starting posts can be unbookmarked'))); } if ($item['uid'] == 0) { diff --git a/src/Module/Api/Mastodon/Statuses/Unfavourite.php b/src/Module/Api/Mastodon/Statuses/Unfavourite.php index ada587b2f..78e9fb350 100644 --- a/src/Module/Api/Mastodon/Statuses/Unfavourite.php +++ b/src/Module/Api/Mastodon/Statuses/Unfavourite.php @@ -39,7 +39,7 @@ class Unfavourite extends BaseApi $uid = self::getCurrentUserID(); if (empty($this->parameters['id'])) { - DI::mstdnError()->UnprocessableEntity(); + $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity()); } $item = Post::selectOriginalForUser($uid, ['id', 'uri-id'], ['uri-id' => $this->parameters['id'], 'uid' => [$uid, 0]]); diff --git a/src/Module/Api/Mastodon/Statuses/Unmute.php b/src/Module/Api/Mastodon/Statuses/Unmute.php index 511ae1540..e54380dbe 100644 --- a/src/Module/Api/Mastodon/Statuses/Unmute.php +++ b/src/Module/Api/Mastodon/Statuses/Unmute.php @@ -39,7 +39,7 @@ class Unmute extends BaseApi $uid = self::getCurrentUserID(); if (empty($this->parameters['id'])) { - DI::mstdnError()->UnprocessableEntity(); + $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity()); } $item = Post::selectOriginalForUser($uid, ['uri-id', 'gravity'], ['uri-id' => $this->parameters['id'], 'uid' => [$uid, 0]]); @@ -48,7 +48,7 @@ class Unmute extends BaseApi } if ($item['gravity'] != Item::GRAVITY_PARENT) { - DI::mstdnError()->UnprocessableEntity(DI::l10n()->t('Only starting posts can be unmuted')); + $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity($this->t('Only starting posts can be unmuted'))); } Post\ThreadUser::setIgnored($item['uri-id'], $uid, false); diff --git a/src/Module/Api/Mastodon/Statuses/Unpin.php b/src/Module/Api/Mastodon/Statuses/Unpin.php index c11f89f6e..f04ff5306 100644 --- a/src/Module/Api/Mastodon/Statuses/Unpin.php +++ b/src/Module/Api/Mastodon/Statuses/Unpin.php @@ -38,7 +38,7 @@ class Unpin extends BaseApi $uid = self::getCurrentUserID(); if (empty($this->parameters['id'])) { - DI::mstdnError()->UnprocessableEntity(); + $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity()); } $item = Post::selectOriginalForUser($uid, ['uri-id', 'gravity'], ['uri-id' => $this->parameters['id'], 'uid' => [$uid, 0]]); diff --git a/src/Module/Api/Mastodon/Statuses/Unreblog.php b/src/Module/Api/Mastodon/Statuses/Unreblog.php index c99011ae4..50931cecd 100644 --- a/src/Module/Api/Mastodon/Statuses/Unreblog.php +++ b/src/Module/Api/Mastodon/Statuses/Unreblog.php @@ -41,7 +41,7 @@ class Unreblog extends BaseApi $uid = self::getCurrentUserID(); if (empty($this->parameters['id'])) { - DI::mstdnError()->UnprocessableEntity(); + $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity()); } $item = Post::selectOriginalForUser($uid, ['id', 'uri-id', 'network'], ['uri-id' => $this->parameters['id'], 'uid' => [$uid, 0]]); @@ -59,7 +59,10 @@ class Unreblog extends BaseApi $this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound()); } } elseif (!in_array($item['network'], [Protocol::DFRN, Protocol::ACTIVITYPUB, Protocol::TWITTER])) { - DI::mstdnError()->UnprocessableEntity(DI::l10n()->t("Posts from %s can't be unshared", ContactSelector::networkToName($item['network']))); + $this->logErrorAndJsonExit( + 422, + $this->errorFactory->UnprocessableEntity($this->t("Posts from %s can't be unshared", ContactSelector::networkToName($item['network']))) + ); } else { Item::performActivity($item['id'], 'unannounce', $uid); } diff --git a/src/Module/Api/Mastodon/Tags.php b/src/Module/Api/Mastodon/Tags.php index d636dd912..d61ee88ac 100644 --- a/src/Module/Api/Mastodon/Tags.php +++ b/src/Module/Api/Mastodon/Tags.php @@ -40,7 +40,7 @@ class Tags extends BaseApi $uid = self::getCurrentUserID(); if (empty($this->parameters['hashtag'])) { - DI::mstdnError()->UnprocessableEntity(); + $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity()); } $tag = ltrim($this->parameters['hashtag'], '#'); diff --git a/src/Module/Api/Mastodon/Tags/Follow.php b/src/Module/Api/Mastodon/Tags/Follow.php index a450b2248..03844a7dd 100644 --- a/src/Module/Api/Mastodon/Tags/Follow.php +++ b/src/Module/Api/Mastodon/Tags/Follow.php @@ -37,7 +37,7 @@ class Follow extends BaseApi $uid = self::getCurrentUserID(); if (empty($this->parameters['hashtag'])) { - DI::mstdnError()->UnprocessableEntity(); + $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity()); } $fields = ['uid' => $uid, 'term' => '#' . ltrim($this->parameters['hashtag'], '#')]; diff --git a/src/Module/Api/Mastodon/Tags/Unfollow.php b/src/Module/Api/Mastodon/Tags/Unfollow.php index b4a1a7e73..07b93d95a 100644 --- a/src/Module/Api/Mastodon/Tags/Unfollow.php +++ b/src/Module/Api/Mastodon/Tags/Unfollow.php @@ -37,7 +37,7 @@ class Unfollow extends BaseApi $uid = self::getCurrentUserID(); if (empty($this->parameters['hashtag'])) { - DI::mstdnError()->UnprocessableEntity(); + $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity()); } $term = ['uid' => $uid, 'term' => '#' . ltrim($this->parameters['hashtag'], '#')]; diff --git a/src/Module/Api/Mastodon/Timelines/ListTimeline.php b/src/Module/Api/Mastodon/Timelines/ListTimeline.php index 2834b63fc..baed01e0e 100644 --- a/src/Module/Api/Mastodon/Timelines/ListTimeline.php +++ b/src/Module/Api/Mastodon/Timelines/ListTimeline.php @@ -45,7 +45,7 @@ class ListTimeline extends BaseApi $uid = self::getCurrentUserID(); if (empty($this->parameters['id'])) { - DI::mstdnError()->UnprocessableEntity(); + $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity()); } $request = $this->getRequest([ diff --git a/src/Module/Api/Mastodon/Timelines/Tag.php b/src/Module/Api/Mastodon/Timelines/Tag.php index 9bbafd587..60bdab837 100644 --- a/src/Module/Api/Mastodon/Timelines/Tag.php +++ b/src/Module/Api/Mastodon/Timelines/Tag.php @@ -45,7 +45,7 @@ class Tag extends BaseApi $uid = self::getCurrentUserID(); if (empty($this->parameters['hashtag'])) { - DI::mstdnError()->UnprocessableEntity(); + $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity()); } /** diff --git a/src/Module/OAuth/Authorize.php b/src/Module/OAuth/Authorize.php index ea91de5a0..e9ef07c62 100644 --- a/src/Module/OAuth/Authorize.php +++ b/src/Module/OAuth/Authorize.php @@ -51,17 +51,17 @@ class Authorize extends BaseApi if ($request['response_type'] != 'code') { Logger::warning('Unsupported or missing response type', ['request' => $_REQUEST]); - DI::mstdnError()->UnprocessableEntity(DI::l10n()->t('Unsupported or missing response type')); + $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity($this->t('Unsupported or missing response type'))); } if (empty($request['client_id']) || empty($request['redirect_uri'])) { Logger::warning('Incomplete request data', ['request' => $_REQUEST]); - DI::mstdnError()->UnprocessableEntity(DI::l10n()->t('Incomplete request data')); + $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity($this->t('Incomplete request data'))); } $application = OAuth::getApplication($request['client_id'], $request['client_secret'], $request['redirect_uri']); if (empty($application)) { - DI::mstdnError()->UnprocessableEntity(); + $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity()); } // @todo Compare the application scope and requested scope @@ -87,7 +87,7 @@ class Authorize extends BaseApi $token = OAuth::createTokenForUser($application, $uid, $request['scope']); if (!$token) { - DI::mstdnError()->UnprocessableEntity(); + $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity()); } if ($application['redirect_uri'] != 'urn:ietf:wg:oauth:2.0:oob') { diff --git a/src/Module/OAuth/Token.php b/src/Module/OAuth/Token.php index 61a7f2288..ab9cd3ec2 100644 --- a/src/Module/OAuth/Token.php +++ b/src/Module/OAuth/Token.php @@ -105,7 +105,7 @@ class Token extends BaseApi $me = $owner['url']; } else { Logger::warning('Unsupported or missing grant type', ['request' => $_REQUEST]); - DI::mstdnError()->UnprocessableEntity(DI::l10n()->t('Unsupported or missing grant type')); + $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity($this->t('Unsupported or missing grant type'))); } $object = new \Friendica\Object\Api\Mastodon\Token($token['access_token'], 'Bearer', $application['scopes'], $token['created_at'], $me); From 6a2ca1a6b6b9d0597f60eda9d444509734cc2c76 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Wed, 11 Oct 2023 09:24:13 -0400 Subject: [PATCH 05/10] Move jsonError out of Factory\Api\Mastodon\Error->Unauthorized --- src/Factory/Api/Mastodon/Error.php | 7 ++----- src/Module/Api/Mastodon/Apps/VerifyCredentials.php | 2 +- src/Module/OAuth/Revoke.php | 4 ++-- src/Module/OAuth/Token.php | 10 +++++----- 4 files changed, 10 insertions(+), 13 deletions(-) diff --git a/src/Factory/Api/Mastodon/Error.php b/src/Factory/Api/Mastodon/Error.php index 1dad4d9c8..661410064 100644 --- a/src/Factory/Api/Mastodon/Error.php +++ b/src/Factory/Api/Mastodon/Error.php @@ -64,13 +64,10 @@ class Error extends BaseFactory return new \Friendica\Object\Api\Mastodon\Error($error, $error_description); } - public function Unauthorized(string $error = '', string $error_description = '') + public function Unauthorized(string $error = '', string $error_description = ''): \Friendica\Object\Api\Mastodon\Error { $error = $error ?: $this->l10n->t('Unauthorized'); - $errorObj = new \Friendica\Object\Api\Mastodon\Error($error, $error_description); - - $this->logError(401, $error); - $this->jsonError(401, $errorObj->toArray()); + return new \Friendica\Object\Api\Mastodon\Error($error, $error_description); } public function Forbidden(string $error = '') diff --git a/src/Module/Api/Mastodon/Apps/VerifyCredentials.php b/src/Module/Api/Mastodon/Apps/VerifyCredentials.php index 82e0016ef..69d470306 100644 --- a/src/Module/Api/Mastodon/Apps/VerifyCredentials.php +++ b/src/Module/Api/Mastodon/Apps/VerifyCredentials.php @@ -36,7 +36,7 @@ class VerifyCredentials extends BaseApi $application = self::getCurrentApplication(); if (empty($application['id'])) { - DI::mstdnError()->Unauthorized(); + $this->logErrorAndJsonExit(401, $this->errorFactory->Unauthorized()); } $this->jsonExit(DI::mstdnApplication()->createFromApplicationId($application['id'])); diff --git a/src/Module/OAuth/Revoke.php b/src/Module/OAuth/Revoke.php index cde4c36c6..979114434 100644 --- a/src/Module/OAuth/Revoke.php +++ b/src/Module/OAuth/Revoke.php @@ -50,8 +50,8 @@ class Revoke extends BaseApi $condition = ['client_id' => $request['client_id'], 'client_secret' => $request['client_secret'], 'access_token' => $request['token']]; $token = DBA::selectFirst('application-view', ['id'], $condition); if (empty($token['id'])) { - Logger::notice('Token not found', $condition); - DI::mstdnError()->Unauthorized(); + $this->logger->notice('Token not found', $condition); + $this->logErrorAndJsonExit(401, $this->errorFactory->Unauthorized()); } DBA::delete('application-token', ['application-id' => $token['id']]); diff --git a/src/Module/OAuth/Token.php b/src/Module/OAuth/Token.php index ab9cd3ec2..0186f2851 100644 --- a/src/Module/OAuth/Token.php +++ b/src/Module/OAuth/Token.php @@ -74,13 +74,13 @@ class Token extends BaseApi } if (empty($request['client_id']) || empty($request['client_secret'])) { - Logger::warning('Incomplete request data', ['request' => $request]); - DI::mstdnError()->Unauthorized('invalid_client', DI::l10n()->t('Incomplete request data')); + $this->logger->warning('Incomplete request data', ['request' => $request]); + $this->logErrorAndJsonExit(401, $this->errorFactory->Unauthorized('invalid_client', $this->t('Incomplete request data')));; } $application = OAuth::getApplication($request['client_id'], $request['client_secret'], $request['redirect_uri']); if (empty($application)) { - DI::mstdnError()->Unauthorized('invalid_client', DI::l10n()->t('Invalid data or unknown client')); + $this->logErrorAndJsonExit(401, $this->errorFactory->Unauthorized('invalid_client', $this->t('Invalid data or unknown client'))); } if ($request['grant_type'] == 'client_credentials') { @@ -98,8 +98,8 @@ class Token extends BaseApi $token = DBA::selectFirst('application-view', ['access_token', 'created_at', 'uid'], $condition); if (!DBA::isResult($token)) { - Logger::notice('Token not found or outdated', $condition); - DI::mstdnError()->Unauthorized(); + $this->logger->notice('Token not found or outdated', $condition); + $this->logErrorAndJsonExit(401, $this->errorFactory->Unauthorized()); } $owner = User::getOwnerDataById($token['uid']); $me = $owner['url']; From 696c56b6be660f755194ee6c65706006ed8e5e3f Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Wed, 11 Oct 2023 09:31:02 -0400 Subject: [PATCH 06/10] Move jsonError out of Factory\Api\Mastodon\Error->Forbidden --- src/Factory/Api/Mastodon/Error.php | 7 ++----- src/Module/BaseApi.php | 6 +++--- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/src/Factory/Api/Mastodon/Error.php b/src/Factory/Api/Mastodon/Error.php index 661410064..7d8e02676 100644 --- a/src/Factory/Api/Mastodon/Error.php +++ b/src/Factory/Api/Mastodon/Error.php @@ -70,14 +70,11 @@ class Error extends BaseFactory return new \Friendica\Object\Api\Mastodon\Error($error, $error_description); } - public function Forbidden(string $error = '') + public function Forbidden(string $error = ''): \Friendica\Object\Api\Mastodon\Error { $error = $error ?: $this->l10n->t('Token is not authorized with a valid user or is missing a required scope'); $error_description = ''; - $errorObj = new \Friendica\Object\Api\Mastodon\Error($error, $error_description); - - $this->logError(403, $error); - $this->jsonError(403, $errorObj->toArray()); + return new \Friendica\Object\Api\Mastodon\Error($error, $error_description); } public function InternalError(string $error = '') diff --git a/src/Module/BaseApi.php b/src/Module/BaseApi.php index 95eb8f042..b2d729f28 100644 --- a/src/Module/BaseApi.php +++ b/src/Module/BaseApi.php @@ -424,17 +424,17 @@ class BaseApi extends BaseModule if (empty($token)) { $this->logger->notice('Empty application token'); - DI::mstdnError()->Forbidden(); + $this->logErrorAndJsonExit(403, $this->errorFactory->Forbidden()); } if (!isset($token[$scope])) { $this->logger->warning('The requested scope does not exist', ['scope' => $scope, 'application' => $token]); - DI::mstdnError()->Forbidden(); + $this->logErrorAndJsonExit(403, $this->errorFactory->Forbidden()); } if (empty($token[$scope])) { $this->logger->warning('The requested scope is not allowed', ['scope' => $scope, 'application' => $token]); - DI::mstdnError()->Forbidden(); + $this->logErrorAndJsonExit(403, $this->errorFactory->Forbidden()); } } From 0a91484fa037c7c2e3fe5ad2e31abadd4494a106 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Wed, 11 Oct 2023 09:32:25 -0400 Subject: [PATCH 07/10] Move jsonError out of Factory\Api\Mastodon\Error->InternalError --- src/Factory/Api/Mastodon/Error.php | 7 ++----- src/Module/Api/Mastodon/Apps.php | 2 +- src/Module/Api/Mastodon/Lists.php | 4 ++-- src/Module/Api/Mastodon/Statuses.php | 4 ++-- 4 files changed, 7 insertions(+), 10 deletions(-) diff --git a/src/Factory/Api/Mastodon/Error.php b/src/Factory/Api/Mastodon/Error.php index 7d8e02676..4f7159b7e 100644 --- a/src/Factory/Api/Mastodon/Error.php +++ b/src/Factory/Api/Mastodon/Error.php @@ -77,13 +77,10 @@ class Error extends BaseFactory return new \Friendica\Object\Api\Mastodon\Error($error, $error_description); } - public function InternalError(string $error = '') + public function InternalError(string $error = ''): \Friendica\Object\Api\Mastodon\Error { $error = $error ?: $this->l10n->t('Internal Server Error'); $error_description = ''; - $errorObj = new \Friendica\Object\Api\Mastodon\Error($error, $error_description); - - $this->logError(500, $error); - $this->jsonError(500, $errorObj->toArray()); + return new \Friendica\Object\Api\Mastodon\Error($error, $error_description); } } diff --git a/src/Module/Api/Mastodon/Apps.php b/src/Module/Api/Mastodon/Apps.php index 9d6729216..5ebe3e2ab 100644 --- a/src/Module/Api/Mastodon/Apps.php +++ b/src/Module/Api/Mastodon/Apps.php @@ -92,7 +92,7 @@ class Apps extends BaseApi } if (!DBA::insert('application', $fields)) { - DI::mstdnError()->InternalError(); + $this->logErrorAndJsonExit(500, $this->errorFactory->InternalError()); } $this->jsonExit(DI::mstdnApplication()->createFromApplicationId(DBA::lastInsertId())->toArray()); diff --git a/src/Module/Api/Mastodon/Lists.php b/src/Module/Api/Mastodon/Lists.php index beb1a3b9a..3e66b9d51 100644 --- a/src/Module/Api/Mastodon/Lists.php +++ b/src/Module/Api/Mastodon/Lists.php @@ -45,7 +45,7 @@ class Lists extends BaseApi } if (!Circle::remove($this->parameters['id'])) { - DI::mstdnError()->InternalError(); + $this->logErrorAndJsonExit(500, $this->errorFactory->InternalError()); } $this->jsonExit([]); @@ -68,7 +68,7 @@ class Lists extends BaseApi $id = Circle::getIdByName($uid, $request['title']); if (!$id) { - DI::mstdnError()->InternalError(); + $this->logErrorAndJsonExit(500, $this->errorFactory->InternalError()); } $this->jsonExit(DI::mstdnList()->createFromCircleId($id)); diff --git a/src/Module/Api/Mastodon/Statuses.php b/src/Module/Api/Mastodon/Statuses.php index def4d51f6..5b6f8550a 100644 --- a/src/Module/Api/Mastodon/Statuses.php +++ b/src/Module/Api/Mastodon/Statuses.php @@ -297,7 +297,7 @@ class Statuses extends BaseApi $item['uri'] = Item::newURI($item['guid']); $id = Post\Delayed::add($item['uri'], $item, Worker::PRIORITY_HIGH, Post\Delayed::PREPARED, DateTimeFormat::utc($request['scheduled_at'])); if (empty($id)) { - DI::mstdnError()->InternalError(); + $this->logErrorAndJsonExit(500, $this->errorFactory->InternalError()); } $this->jsonExit(DI::mstdnScheduledStatus()->createFromDelayedPostId($id, $uid)->toArray()); } @@ -310,7 +310,7 @@ class Statuses extends BaseApi } } - DI::mstdnError()->InternalError(); + $this->logErrorAndJsonExit(500, $this->errorFactory->InternalError()); } protected function delete(array $request = []) From eb583330dfe76f5076b5ec7ab6dae2604870e3b7 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Wed, 11 Oct 2023 09:33:53 -0400 Subject: [PATCH 08/10] Remove obsolete Factory\Api\Mastodon\Error->logError method and related dependencies --- src/Factory/Api/Mastodon/Error.php | 15 +-------------- static/dependencies.config.php | 5 ----- 2 files changed, 1 insertion(+), 19 deletions(-) diff --git a/src/Factory/Api/Mastodon/Error.php b/src/Factory/Api/Mastodon/Error.php index 4f7159b7e..4cf8159fd 100644 --- a/src/Factory/Api/Mastodon/Error.php +++ b/src/Factory/Api/Mastodon/Error.php @@ -21,35 +21,22 @@ namespace Friendica\Factory\Api\Mastodon; -use Friendica\App\Arguments; use Friendica\BaseFactory; use Friendica\Core\L10n; -use Friendica\Core\System; use Psr\Log\LoggerInterface; /** @todo A Factory shouldn't return something to the frontpage, it's for creating content, not showing it */ class Error extends BaseFactory { - /** @var Arguments */ - private $args; - /** @var string[] The $_SERVER array */ - private $server; /** @var L10n */ private $l10n; - public function __construct(LoggerInterface $logger, Arguments $args, L10n $l10n, array $server) + public function __construct(LoggerInterface $logger, L10n $l10n) { parent::__construct($logger); - $this->args = $args; - $this->server = $server; $this->l10n = $l10n; } - private function logError(int $errorno, string $error) - { - $this->logger->info('API Error', ['no' => $errorno, 'error' => $error, 'method' => $this->args->getMethod(), 'command' => $this->args->getQueryString(), 'user-agent' => $this->server['HTTP_USER_AGENT'] ?? '']); - } - public function RecordNotFound(): \Friendica\Object\Api\Mastodon\Error { $error = $this->l10n->t('Record not found'); diff --git a/static/dependencies.config.php b/static/dependencies.config.php index 830b7fec3..20415e3fe 100644 --- a/static/dependencies.config.php +++ b/static/dependencies.config.php @@ -302,11 +302,6 @@ return [ ['createClient', [], Dice::CHAIN_CALL], ], ], - Factory\Api\Mastodon\Error::class => [ - 'constructParams' => [ - $_SERVER - ], - ], ParsedLogIterator::class => [ 'constructParams' => [ [Dice::INSTANCE => Util\ReversedFileReader::class], From 1b9ec3a2147fc10e4037ff1b2a7aac506cdf3b13 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Wed, 11 Oct 2023 09:37:49 -0400 Subject: [PATCH 09/10] Rename BaseApi->logErrorAndJsonExit to logAndJsonError to better match the functionality - Also it's shorter and we're paying by the character --- src/Module/Api/Friendica/Statuses/Dislike.php | 4 ++-- src/Module/Api/Friendica/Statuses/DislikedBy.php | 4 ++-- src/Module/Api/Friendica/Statuses/Undislike.php | 4 ++-- src/Module/Api/Mastodon/Accounts.php | 6 +++--- src/Module/Api/Mastodon/Accounts/Block.php | 2 +- src/Module/Api/Mastodon/Accounts/Follow.php | 2 +- src/Module/Api/Mastodon/Accounts/Followers.php | 4 ++-- src/Module/Api/Mastodon/Accounts/Following.php | 4 ++-- src/Module/Api/Mastodon/Accounts/Lists.php | 4 ++-- src/Module/Api/Mastodon/Accounts/Mute.php | 2 +- src/Module/Api/Mastodon/Accounts/Note.php | 4 ++-- src/Module/Api/Mastodon/Accounts/Relationships.php | 2 +- src/Module/Api/Mastodon/Accounts/Statuses.php | 4 ++-- src/Module/Api/Mastodon/Accounts/Unblock.php | 2 +- src/Module/Api/Mastodon/Accounts/Unfollow.php | 4 ++-- src/Module/Api/Mastodon/Accounts/Unmute.php | 2 +- src/Module/Api/Mastodon/Apps.php | 4 ++-- src/Module/Api/Mastodon/Apps/VerifyCredentials.php | 2 +- src/Module/Api/Mastodon/Conversations.php | 4 ++-- src/Module/Api/Mastodon/Conversations/Read.php | 4 ++-- src/Module/Api/Mastodon/Lists.php | 14 +++++++------- src/Module/Api/Mastodon/Lists/Accounts.php | 8 ++++---- src/Module/Api/Mastodon/Markers.php | 2 +- src/Module/Api/Mastodon/Media.php | 14 +++++++------- src/Module/Api/Mastodon/Mutes.php | 4 ++-- src/Module/Api/Mastodon/Notifications.php | 2 +- src/Module/Api/Mastodon/Notifications/Dismiss.php | 2 +- src/Module/Api/Mastodon/Polls.php | 2 +- src/Module/Api/Mastodon/PushSubscription.php | 4 ++-- src/Module/Api/Mastodon/ScheduledStatuses.php | 4 ++-- src/Module/Api/Mastodon/Search.php | 2 +- src/Module/Api/Mastodon/Statuses.php | 12 ++++++------ src/Module/Api/Mastodon/Statuses/Bookmark.php | 10 +++++----- src/Module/Api/Mastodon/Statuses/Card.php | 2 +- src/Module/Api/Mastodon/Statuses/Context.php | 4 ++-- src/Module/Api/Mastodon/Statuses/Favourite.php | 4 ++-- src/Module/Api/Mastodon/Statuses/FavouritedBy.php | 4 ++-- src/Module/Api/Mastodon/Statuses/Mute.php | 6 +++--- src/Module/Api/Mastodon/Statuses/Pin.php | 4 ++-- src/Module/Api/Mastodon/Statuses/Reblog.php | 6 +++--- src/Module/Api/Mastodon/Statuses/RebloggedBy.php | 4 ++-- src/Module/Api/Mastodon/Statuses/Source.php | 2 +- src/Module/Api/Mastodon/Statuses/Unbookmark.php | 10 +++++----- src/Module/Api/Mastodon/Statuses/Unfavourite.php | 4 ++-- src/Module/Api/Mastodon/Statuses/Unmute.php | 6 +++--- src/Module/Api/Mastodon/Statuses/Unpin.php | 4 ++-- src/Module/Api/Mastodon/Statuses/Unreblog.php | 10 +++++----- src/Module/Api/Mastodon/Tags.php | 2 +- src/Module/Api/Mastodon/Tags/Follow.php | 2 +- src/Module/Api/Mastodon/Tags/Unfollow.php | 2 +- src/Module/Api/Mastodon/Timelines/Direct.php | 2 +- src/Module/Api/Mastodon/Timelines/ListTimeline.php | 2 +- src/Module/Api/Mastodon/Timelines/Tag.php | 2 +- src/Module/BaseApi.php | 8 ++++---- src/Module/OAuth/Authorize.php | 8 ++++---- src/Module/OAuth/Revoke.php | 2 +- src/Module/OAuth/Token.php | 8 ++++---- 57 files changed, 128 insertions(+), 128 deletions(-) diff --git a/src/Module/Api/Friendica/Statuses/Dislike.php b/src/Module/Api/Friendica/Statuses/Dislike.php index 99c8eb857..c436c8546 100644 --- a/src/Module/Api/Friendica/Statuses/Dislike.php +++ b/src/Module/Api/Friendica/Statuses/Dislike.php @@ -39,12 +39,12 @@ class Dislike extends BaseApi $uid = self::getCurrentUserID(); if (empty($this->parameters['id'])) { - $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity()); + $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity()); } $item = Post::selectFirstForUser($uid, ['id'], ['uri-id' => $this->parameters['id'], 'uid' => [$uid, 0]]); if (!DBA::isResult($item)) { - $this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound()); + $this->logAndJsonError(404, $this->errorFactory->RecordNotFound()); } Item::performActivity($item['id'], 'dislike', $uid); diff --git a/src/Module/Api/Friendica/Statuses/DislikedBy.php b/src/Module/Api/Friendica/Statuses/DislikedBy.php index 3c1312087..f6470330d 100644 --- a/src/Module/Api/Friendica/Statuses/DislikedBy.php +++ b/src/Module/Api/Friendica/Statuses/DislikedBy.php @@ -41,12 +41,12 @@ class DislikedBy extends BaseApi $uid = self::getCurrentUserID(); if (empty($this->parameters['id'])) { - $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity()); + $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity()); } $id = $this->parameters['id']; if (!Post::exists(['uri-id' => $id, 'uid' => [0, $uid]])) { - $this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound()); + $this->logAndJsonError(404, $this->errorFactory->RecordNotFound()); } $activities = Post::selectPosts(['author-id'], ['thr-parent-id' => $id, 'gravity' => Item::GRAVITY_ACTIVITY, 'verb' => Activity::DISLIKE, 'deleted' => false]); diff --git a/src/Module/Api/Friendica/Statuses/Undislike.php b/src/Module/Api/Friendica/Statuses/Undislike.php index 5387f1b10..ba53f902b 100644 --- a/src/Module/Api/Friendica/Statuses/Undislike.php +++ b/src/Module/Api/Friendica/Statuses/Undislike.php @@ -39,12 +39,12 @@ class Undislike extends BaseApi $uid = self::getCurrentUserID(); if (empty($this->parameters['id'])) { - $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity()); + $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity()); } $item = Post::selectFirstForUser($uid, ['id'], ['uri-id' => $this->parameters['id'], 'uid' => [$uid, 0]]); if (!DBA::isResult($item)) { - $this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound()); + $this->logAndJsonError(404, $this->errorFactory->RecordNotFound()); } Item::performActivity($item['id'], 'undislike', $uid); diff --git a/src/Module/Api/Mastodon/Accounts.php b/src/Module/Api/Mastodon/Accounts.php index 6b88b84ef..fcf443056 100644 --- a/src/Module/Api/Mastodon/Accounts.php +++ b/src/Module/Api/Mastodon/Accounts.php @@ -40,20 +40,20 @@ class Accounts extends BaseApi $uid = self::getCurrentUserID(); if (empty($this->parameters['id']) && empty($this->parameters['name'])) { - $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity()); + $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity()); } if (!empty($this->parameters['id'])) { $id = $this->parameters['id']; if (!DBA::exists('contact', ['id' => $id, 'uid' => 0])) { - $this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound()); + $this->logAndJsonError(404, $this->errorFactory->RecordNotFound()); } } else { $contact = Contact::selectFirst(['id'], ['nick' => $this->parameters['name'], 'uid' => 0]); if (!empty($contact['id'])) { $id = $contact['id']; } elseif (!($id = Contact::getIdForURL($this->parameters['name'], 0, false))) { - $this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound()); + $this->logAndJsonError(404, $this->errorFactory->RecordNotFound()); } } diff --git a/src/Module/Api/Mastodon/Accounts/Block.php b/src/Module/Api/Mastodon/Accounts/Block.php index 1582f3299..f6970336d 100644 --- a/src/Module/Api/Mastodon/Accounts/Block.php +++ b/src/Module/Api/Mastodon/Accounts/Block.php @@ -38,7 +38,7 @@ class Block extends BaseApi $uid = self::getCurrentUserID(); if (empty($this->parameters['id'])) { - $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity()); + $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity()); } Contact\User::setBlocked($this->parameters['id'], $uid, true); diff --git a/src/Module/Api/Mastodon/Accounts/Follow.php b/src/Module/Api/Mastodon/Accounts/Follow.php index 272b989ee..0f565d580 100644 --- a/src/Module/Api/Mastodon/Accounts/Follow.php +++ b/src/Module/Api/Mastodon/Accounts/Follow.php @@ -37,7 +37,7 @@ class Follow extends BaseApi $uid = self::getCurrentUserID(); if (empty($this->parameters['id'])) { - $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity()); + $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity()); } $request = $this->getRequest([ diff --git a/src/Module/Api/Mastodon/Accounts/Followers.php b/src/Module/Api/Mastodon/Accounts/Followers.php index 19f2a4388..0ad6f9667 100644 --- a/src/Module/Api/Mastodon/Accounts/Followers.php +++ b/src/Module/Api/Mastodon/Accounts/Followers.php @@ -41,12 +41,12 @@ class Followers extends BaseApi $uid = self::getCurrentUserID(); if (empty($this->parameters['id'])) { - $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity()); + $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity()); } $id = $this->parameters['id']; if (!DBA::exists('contact', ['id' => $id, 'uid' => 0])) { - $this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound()); + $this->logAndJsonError(404, $this->errorFactory->RecordNotFound()); } $request = $this->getRequest([ diff --git a/src/Module/Api/Mastodon/Accounts/Following.php b/src/Module/Api/Mastodon/Accounts/Following.php index 061e22663..bd8832860 100644 --- a/src/Module/Api/Mastodon/Accounts/Following.php +++ b/src/Module/Api/Mastodon/Accounts/Following.php @@ -41,12 +41,12 @@ class Following extends BaseApi $uid = self::getCurrentUserID(); if (empty($this->parameters['id'])) { - $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity()); + $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity()); } $id = $this->parameters['id']; if (!DBA::exists('contact', ['id' => $id, 'uid' => 0])) { - $this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound()); + $this->logAndJsonError(404, $this->errorFactory->RecordNotFound()); } $request = $this->getRequest([ diff --git a/src/Module/Api/Mastodon/Accounts/Lists.php b/src/Module/Api/Mastodon/Accounts/Lists.php index 8fdcade66..750ebd681 100644 --- a/src/Module/Api/Mastodon/Accounts/Lists.php +++ b/src/Module/Api/Mastodon/Accounts/Lists.php @@ -41,12 +41,12 @@ class Lists extends BaseApi $uid = self::getCurrentUserID(); if (empty($this->parameters['id'])) { - $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity()); + $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity()); } $id = $this->parameters['id']; if (!DBA::exists('contact', ['id' => $id, 'uid' => 0])) { - $this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound()); + $this->logAndJsonError(404, $this->errorFactory->RecordNotFound()); } $lists = []; diff --git a/src/Module/Api/Mastodon/Accounts/Mute.php b/src/Module/Api/Mastodon/Accounts/Mute.php index ea8d0ce30..4602b18ca 100644 --- a/src/Module/Api/Mastodon/Accounts/Mute.php +++ b/src/Module/Api/Mastodon/Accounts/Mute.php @@ -37,7 +37,7 @@ class Mute extends BaseApi $uid = self::getCurrentUserID(); if (empty($this->parameters['id'])) { - $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity()); + $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity()); } Contact\User::setIgnored($this->parameters['id'], $uid, true); diff --git a/src/Module/Api/Mastodon/Accounts/Note.php b/src/Module/Api/Mastodon/Accounts/Note.php index 72a7e0838..9f3600931 100644 --- a/src/Module/Api/Mastodon/Accounts/Note.php +++ b/src/Module/Api/Mastodon/Accounts/Note.php @@ -38,7 +38,7 @@ class Note extends BaseApi $uid = self::getCurrentUserID(); if (empty($this->parameters['id'])) { - $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity()); + $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity()); } $request = $this->getRequest([ @@ -47,7 +47,7 @@ class Note extends BaseApi $cdata = Contact::getPublicAndUserContactID($this->parameters['id'], $uid); if (empty($cdata['user'])) { - $this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound()); + $this->logAndJsonError(404, $this->errorFactory->RecordNotFound()); } Contact::update(['info' => $request['comment']], ['id' => $cdata['user']]); diff --git a/src/Module/Api/Mastodon/Accounts/Relationships.php b/src/Module/Api/Mastodon/Accounts/Relationships.php index f75715172..8c630d723 100644 --- a/src/Module/Api/Mastodon/Accounts/Relationships.php +++ b/src/Module/Api/Mastodon/Accounts/Relationships.php @@ -44,7 +44,7 @@ class Relationships extends BaseApi ], $request); if (empty($request['id'])) { - $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity()); + $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity()); } if (!is_array($request['id'])) { diff --git a/src/Module/Api/Mastodon/Accounts/Statuses.php b/src/Module/Api/Mastodon/Accounts/Statuses.php index fd8fbcdab..b4e09b613 100644 --- a/src/Module/Api/Mastodon/Accounts/Statuses.php +++ b/src/Module/Api/Mastodon/Accounts/Statuses.php @@ -47,12 +47,12 @@ class Statuses extends BaseApi $uid = self::getCurrentUserID(); if (empty($this->parameters['id'])) { - $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity()); + $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity()); } $id = $this->parameters['id']; if (!DBA::exists('contact', ['id' => $id, 'uid' => 0])) { - $this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound()); + $this->logAndJsonError(404, $this->errorFactory->RecordNotFound()); } $request = $this->getRequest([ diff --git a/src/Module/Api/Mastodon/Accounts/Unblock.php b/src/Module/Api/Mastodon/Accounts/Unblock.php index f2e2f2e41..0d44c52d1 100644 --- a/src/Module/Api/Mastodon/Accounts/Unblock.php +++ b/src/Module/Api/Mastodon/Accounts/Unblock.php @@ -37,7 +37,7 @@ class Unblock extends BaseApi $uid = self::getCurrentUserID(); if (empty($this->parameters['id'])) { - $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity()); + $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity()); } Contact\User::setBlocked($this->parameters['id'], $uid, false); diff --git a/src/Module/Api/Mastodon/Accounts/Unfollow.php b/src/Module/Api/Mastodon/Accounts/Unfollow.php index 6a3c68cb3..6a19267b3 100644 --- a/src/Module/Api/Mastodon/Accounts/Unfollow.php +++ b/src/Module/Api/Mastodon/Accounts/Unfollow.php @@ -37,12 +37,12 @@ class Unfollow extends BaseApi $uid = self::getCurrentUserID(); if (empty($this->parameters['id'])) { - $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity()); + $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity()); } $cdata = Contact::getPublicAndUserContactID($this->parameters['id'], $uid); if (empty($cdata['user'])) { - $this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound()); + $this->logAndJsonError(404, $this->errorFactory->RecordNotFound()); } $contact = Contact::getById($cdata['user']); diff --git a/src/Module/Api/Mastodon/Accounts/Unmute.php b/src/Module/Api/Mastodon/Accounts/Unmute.php index 651233dae..689398d10 100644 --- a/src/Module/Api/Mastodon/Accounts/Unmute.php +++ b/src/Module/Api/Mastodon/Accounts/Unmute.php @@ -37,7 +37,7 @@ class Unmute extends BaseApi $uid = self::getCurrentUserID(); if (empty($this->parameters['id'])) { - $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity()); + $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity()); } Contact\User::setIgnored($this->parameters['id'], $uid, false); diff --git a/src/Module/Api/Mastodon/Apps.php b/src/Module/Api/Mastodon/Apps.php index 5ebe3e2ab..012a2b1c2 100644 --- a/src/Module/Api/Mastodon/Apps.php +++ b/src/Module/Api/Mastodon/Apps.php @@ -70,7 +70,7 @@ class Apps extends BaseApi } if (empty($request['client_name']) || empty($request['redirect_uris'])) { - $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity($this->t('Missing parameters'))); + $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity($this->t('Missing parameters'))); } $client_id = bin2hex(random_bytes(32)); @@ -92,7 +92,7 @@ class Apps extends BaseApi } if (!DBA::insert('application', $fields)) { - $this->logErrorAndJsonExit(500, $this->errorFactory->InternalError()); + $this->logAndJsonError(500, $this->errorFactory->InternalError()); } $this->jsonExit(DI::mstdnApplication()->createFromApplicationId(DBA::lastInsertId())->toArray()); diff --git a/src/Module/Api/Mastodon/Apps/VerifyCredentials.php b/src/Module/Api/Mastodon/Apps/VerifyCredentials.php index 69d470306..42e8111e7 100644 --- a/src/Module/Api/Mastodon/Apps/VerifyCredentials.php +++ b/src/Module/Api/Mastodon/Apps/VerifyCredentials.php @@ -36,7 +36,7 @@ class VerifyCredentials extends BaseApi $application = self::getCurrentApplication(); if (empty($application['id'])) { - $this->logErrorAndJsonExit(401, $this->errorFactory->Unauthorized()); + $this->logAndJsonError(401, $this->errorFactory->Unauthorized()); } $this->jsonExit(DI::mstdnApplication()->createFromApplicationId($application['id'])); diff --git a/src/Module/Api/Mastodon/Conversations.php b/src/Module/Api/Mastodon/Conversations.php index 532db4bcd..1814922c7 100644 --- a/src/Module/Api/Mastodon/Conversations.php +++ b/src/Module/Api/Mastodon/Conversations.php @@ -38,7 +38,7 @@ class Conversations extends BaseApi $uid = self::getCurrentUserID(); if (!empty($this->parameters['id'])) { - $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity()); + $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity()); } DBA::delete('conv', ['id' => $this->parameters['id'], 'uid' => $uid]); @@ -90,7 +90,7 @@ class Conversations extends BaseApi $conversations[] = DI::mstdnConversation()->createFromConvId($conv['id']); } } catch (NotFoundException $e) { - $this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound()); + $this->logAndJsonError(404, $this->errorFactory->RecordNotFound()); } DBA::close($convs); diff --git a/src/Module/Api/Mastodon/Conversations/Read.php b/src/Module/Api/Mastodon/Conversations/Read.php index 2e876fcb5..b78fdf8ed 100644 --- a/src/Module/Api/Mastodon/Conversations/Read.php +++ b/src/Module/Api/Mastodon/Conversations/Read.php @@ -38,7 +38,7 @@ class Read extends BaseApi $uid = self::getCurrentUserID(); if (!empty($this->parameters['id'])) { - $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity()); + $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity()); } DBA::update('mail', ['seen' => true], ['convid' => $this->parameters['id'], 'uid' => $uid]); @@ -46,7 +46,7 @@ class Read extends BaseApi try { $this->jsonExit(DI::mstdnConversation()->createFromConvId($this->parameters['id'])->toArray()); } catch (NotFoundException $e) { - $this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound()); + $this->logAndJsonError(404, $this->errorFactory->RecordNotFound()); } } } diff --git a/src/Module/Api/Mastodon/Lists.php b/src/Module/Api/Mastodon/Lists.php index 3e66b9d51..b9e52f159 100644 --- a/src/Module/Api/Mastodon/Lists.php +++ b/src/Module/Api/Mastodon/Lists.php @@ -37,15 +37,15 @@ class Lists extends BaseApi $uid = self::getCurrentUserID(); if (empty($this->parameters['id'])) { - $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity()); + $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity()); } if (!Circle::exists($this->parameters['id'], $uid)) { - $this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound()); + $this->logAndJsonError(404, $this->errorFactory->RecordNotFound()); } if (!Circle::remove($this->parameters['id'])) { - $this->logErrorAndJsonExit(500, $this->errorFactory->InternalError()); + $this->logAndJsonError(500, $this->errorFactory->InternalError()); } $this->jsonExit([]); @@ -61,14 +61,14 @@ class Lists extends BaseApi ], $request); if (empty($request['title'])) { - $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity()); + $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity()); } Circle::create($uid, $request['title']); $id = Circle::getIdByName($uid, $request['title']); if (!$id) { - $this->logErrorAndJsonExit(500, $this->errorFactory->InternalError()); + $this->logAndJsonError(500, $this->errorFactory->InternalError()); } $this->jsonExit(DI::mstdnList()->createFromCircleId($id)); @@ -82,7 +82,7 @@ class Lists extends BaseApi ], $request); if (empty($request['title']) || empty($this->parameters['id'])) { - $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity()); + $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity()); } Circle::update($this->parameters['id'], $request['title']); @@ -106,7 +106,7 @@ class Lists extends BaseApi $id = $this->parameters['id']; if (!Circle::exists($id, $uid)) { - $this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound()); + $this->logAndJsonError(404, $this->errorFactory->RecordNotFound()); } $lists = DI::mstdnList()->createFromCircleId($id); } diff --git a/src/Module/Api/Mastodon/Lists/Accounts.php b/src/Module/Api/Mastodon/Lists/Accounts.php index f72f8cad8..4db6846a2 100644 --- a/src/Module/Api/Mastodon/Lists/Accounts.php +++ b/src/Module/Api/Mastodon/Lists/Accounts.php @@ -43,7 +43,7 @@ class Accounts extends BaseApi ], $request); if (empty($request['account_ids']) || empty($this->parameters['id'])) { - $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity()); + $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity()); } return Circle::removeMembers($this->parameters['id'], $request['account_ids']); @@ -58,7 +58,7 @@ class Accounts extends BaseApi ], $request); if (empty($request['account_ids']) || empty($this->parameters['id'])) { - $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity()); + $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity()); } Circle::addMembers($this->parameters['id'], $request['account_ids']); @@ -73,12 +73,12 @@ class Accounts extends BaseApi $uid = self::getCurrentUserID(); if (empty($this->parameters['id'])) { - $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity()); + $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity()); } $id = $this->parameters['id']; if (!DBA::exists('group', ['id' => $id, 'uid' => $uid])) { - $this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound()); + $this->logAndJsonError(404, $this->errorFactory->RecordNotFound()); } $request = $this->getRequest([ diff --git a/src/Module/Api/Mastodon/Markers.php b/src/Module/Api/Mastodon/Markers.php index 25b56d72e..4bd714c11 100644 --- a/src/Module/Api/Mastodon/Markers.php +++ b/src/Module/Api/Mastodon/Markers.php @@ -48,7 +48,7 @@ class Markers extends BaseApi } if (empty($timeline) || empty($last_read_id) || empty($application['id'])) { - $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity()); + $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity()); } $condition = ['application-id' => $application['id'], 'uid' => $uid, 'timeline' => $timeline]; diff --git a/src/Module/Api/Mastodon/Media.php b/src/Module/Api/Mastodon/Media.php index 738feab7c..1da6b3006 100644 --- a/src/Module/Api/Mastodon/Media.php +++ b/src/Module/Api/Mastodon/Media.php @@ -48,12 +48,12 @@ class Media extends BaseApi Logger::info('Photo post', ['request' => $request, 'files' => $_FILES]); if (empty($_FILES['file'])) { - $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity()); + $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity()); } $media = Photo::upload($uid, $_FILES['file'], '', null, null, '', '', $request['description']); if (empty($media)) { - $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity()); + $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity()); } Logger::info('Uploaded photo', ['media' => $media]); @@ -74,17 +74,17 @@ class Media extends BaseApi ], $request); if (empty($this->parameters['id'])) { - $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity()); + $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity()); } $photo = Photo::selectFirst(['resource-id'], ['id' => $this->parameters['id'], 'uid' => $uid]); if (empty($photo['resource-id'])) { $media = Post\Media::getById($this->parameters['id']); if (empty($media['uri-id'])) { - $this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound()); + $this->logAndJsonError(404, $this->errorFactory->RecordNotFound()); } if (!Post::exists(['uri-id' => $media['uri-id'], 'uid' => $uid, 'origin' => true])) { - $this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound()); + $this->logAndJsonError(404, $this->errorFactory->RecordNotFound()); } Post\Media::updateById(['description' => $request['description']], $this->parameters['id']); $this->jsonExit(DI::mstdnAttachment()->createFromId($this->parameters['id'])); @@ -104,12 +104,12 @@ class Media extends BaseApi $uid = self::getCurrentUserID(); if (empty($this->parameters['id'])) { - $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity()); + $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity()); } $id = $this->parameters['id']; if (!Photo::exists(['id' => $id, 'uid' => $uid])) { - $this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound()); + $this->logAndJsonError(404, $this->errorFactory->RecordNotFound()); } $this->jsonExit(DI::mstdnAttachment()->createFromPhoto($id)); diff --git a/src/Module/Api/Mastodon/Mutes.php b/src/Module/Api/Mastodon/Mutes.php index 6557b770b..b87da7f7b 100644 --- a/src/Module/Api/Mastodon/Mutes.php +++ b/src/Module/Api/Mastodon/Mutes.php @@ -40,12 +40,12 @@ class Mutes extends BaseApi $uid = self::getCurrentUserID(); if (empty($this->parameters['id'])) { - $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity()); + $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity()); } $id = $this->parameters['id']; if (!DBA::exists('contact', ['id' => $id, 'uid' => 0])) { - $this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound()); + $this->logAndJsonError(404, $this->errorFactory->RecordNotFound()); } $request = $this->getRequest([ diff --git a/src/Module/Api/Mastodon/Notifications.php b/src/Module/Api/Mastodon/Notifications.php index 6045d2465..b359113dc 100644 --- a/src/Module/Api/Mastodon/Notifications.php +++ b/src/Module/Api/Mastodon/Notifications.php @@ -50,7 +50,7 @@ class Notifications extends BaseApi $notification = DI::notification()->selectOneForUser($uid, ['id' => $id]); $this->jsonExit(DI::mstdnNotification()->createFromNotification($notification, self::appSupportsQuotes())); } catch (\Exception $e) { - $this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound()); + $this->logAndJsonError(404, $this->errorFactory->RecordNotFound()); } } diff --git a/src/Module/Api/Mastodon/Notifications/Dismiss.php b/src/Module/Api/Mastodon/Notifications/Dismiss.php index cc8947972..9771f1df6 100644 --- a/src/Module/Api/Mastodon/Notifications/Dismiss.php +++ b/src/Module/Api/Mastodon/Notifications/Dismiss.php @@ -38,7 +38,7 @@ class Dismiss extends BaseApi $uid = self::getCurrentUserID(); if (empty($this->parameters['id'])) { - $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity()); + $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity()); } $condition = ['id' => $this->parameters['id']]; diff --git a/src/Module/Api/Mastodon/Polls.php b/src/Module/Api/Mastodon/Polls.php index a5e4fb33a..51d46c45b 100644 --- a/src/Module/Api/Mastodon/Polls.php +++ b/src/Module/Api/Mastodon/Polls.php @@ -39,7 +39,7 @@ class Polls extends BaseApi $uid = self::getCurrentUserID(); if (empty($this->parameters['id'])) { - $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity()); + $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity()); } $this->jsonExit(DI::mstdnPoll()->createFromId($this->parameters['id'], $uid)); diff --git a/src/Module/Api/Mastodon/PushSubscription.php b/src/Module/Api/Mastodon/PushSubscription.php index b91f8e7ba..5624a1de4 100644 --- a/src/Module/Api/Mastodon/PushSubscription.php +++ b/src/Module/Api/Mastodon/PushSubscription.php @@ -94,7 +94,7 @@ class PushSubscription extends BaseApi $subscription = Subscription::select($application['id'], $uid, ['id']); if (empty($subscription)) { $this->logger->info('Subscription not found', ['application-id' => $application['id'], 'uid' => $uid]); - $this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound()); + $this->logAndJsonError(404, $this->errorFactory->RecordNotFound()); } $fields = [ @@ -145,7 +145,7 @@ class PushSubscription extends BaseApi if (!Subscription::exists($application['id'], $uid)) { $this->logger->info('Subscription not found', ['application-id' => $application['id'], 'uid' => $uid]); - $this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound()); + $this->logAndJsonError(404, $this->errorFactory->RecordNotFound()); } $this->logger->info('Fetch subscription', ['application-id' => $application['id'], 'uid' => $uid]); diff --git a/src/Module/Api/Mastodon/ScheduledStatuses.php b/src/Module/Api/Mastodon/ScheduledStatuses.php index cedafb8ab..18b5c31c4 100644 --- a/src/Module/Api/Mastodon/ScheduledStatuses.php +++ b/src/Module/Api/Mastodon/ScheduledStatuses.php @@ -47,11 +47,11 @@ class ScheduledStatuses extends BaseApi $uid = self::getCurrentUserID(); if (empty($this->parameters['id'])) { - $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity()); + $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity()); } if (!DBA::exists('delayed-post', ['id' => $this->parameters['id'], 'uid' => $uid])) { - $this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound()); + $this->logAndJsonError(404, $this->errorFactory->RecordNotFound()); } Post\Delayed::deleteById($this->parameters['id']); diff --git a/src/Module/Api/Mastodon/Search.php b/src/Module/Api/Mastodon/Search.php index fb222beff..75dc05e24 100644 --- a/src/Module/Api/Mastodon/Search.php +++ b/src/Module/Api/Mastodon/Search.php @@ -60,7 +60,7 @@ class Search extends BaseApi ], $request); if (empty($request['q'])) { - $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity()); + $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity()); } $limit = min($request['limit'], 40); diff --git a/src/Module/Api/Mastodon/Statuses.php b/src/Module/Api/Mastodon/Statuses.php index 5b6f8550a..dfd81c9d4 100644 --- a/src/Module/Api/Mastodon/Statuses.php +++ b/src/Module/Api/Mastodon/Statuses.php @@ -297,7 +297,7 @@ class Statuses extends BaseApi $item['uri'] = Item::newURI($item['guid']); $id = Post\Delayed::add($item['uri'], $item, Worker::PRIORITY_HIGH, Post\Delayed::PREPARED, DateTimeFormat::utc($request['scheduled_at'])); if (empty($id)) { - $this->logErrorAndJsonExit(500, $this->errorFactory->InternalError()); + $this->logAndJsonError(500, $this->errorFactory->InternalError()); } $this->jsonExit(DI::mstdnScheduledStatus()->createFromDelayedPostId($id, $uid)->toArray()); } @@ -310,7 +310,7 @@ class Statuses extends BaseApi } } - $this->logErrorAndJsonExit(500, $this->errorFactory->InternalError()); + $this->logAndJsonError(500, $this->errorFactory->InternalError()); } protected function delete(array $request = []) @@ -319,16 +319,16 @@ class Statuses extends BaseApi $uid = self::getCurrentUserID(); if (empty($this->parameters['id'])) { - $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity()); + $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity()); } $item = Post::selectFirstForUser($uid, ['id'], ['uri-id' => $this->parameters['id'], 'uid' => $uid]); if (empty($item['id'])) { - $this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound()); + $this->logAndJsonError(404, $this->errorFactory->RecordNotFound()); } if (!Item::markForDeletionById($item['id'])) { - $this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound()); + $this->logAndJsonError(404, $this->errorFactory->RecordNotFound()); } $this->jsonExit([]); @@ -342,7 +342,7 @@ class Statuses extends BaseApi $uid = self::getCurrentUserID(); if (empty($this->parameters['id'])) { - $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity()); + $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity()); } $this->jsonExit(DI::mstdnStatus()->createFromUriId($this->parameters['id'], $uid, self::appSupportsQuotes(), false)); diff --git a/src/Module/Api/Mastodon/Statuses/Bookmark.php b/src/Module/Api/Mastodon/Statuses/Bookmark.php index cdbdcb6e6..35ebf28d7 100644 --- a/src/Module/Api/Mastodon/Statuses/Bookmark.php +++ b/src/Module/Api/Mastodon/Statuses/Bookmark.php @@ -39,16 +39,16 @@ class Bookmark extends BaseApi $uid = self::getCurrentUserID(); if (empty($this->parameters['id'])) { - $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity()); + $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity()); } $item = Post::selectOriginal(['uid', 'id', 'uri-id', 'gravity'], ['uri-id' => $this->parameters['id'], 'uid' => [$uid, 0]], ['order' => ['uid' => true]]); if (!DBA::isResult($item)) { - $this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound()); + $this->logAndJsonError(404, $this->errorFactory->RecordNotFound()); } if ($item['gravity'] != Item::GRAVITY_PARENT) { - $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity($this->t('Only starting posts can be bookmarked'))); + $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity($this->t('Only starting posts can be bookmarked'))); } if ($item['uid'] == 0) { @@ -56,10 +56,10 @@ class Bookmark extends BaseApi if (!empty($stored)) { $item = Post::selectFirst(['id', 'gravity'], ['id' => $stored]); if (!DBA::isResult($item)) { - $this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound()); + $this->logAndJsonError(404, $this->errorFactory->RecordNotFound()); } } else { - $this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound()); + $this->logAndJsonError(404, $this->errorFactory->RecordNotFound()); } } diff --git a/src/Module/Api/Mastodon/Statuses/Card.php b/src/Module/Api/Mastodon/Statuses/Card.php index ea5705186..ef38f66a8 100644 --- a/src/Module/Api/Mastodon/Statuses/Card.php +++ b/src/Module/Api/Mastodon/Statuses/Card.php @@ -40,7 +40,7 @@ class Card extends BaseApi $uid = self::getCurrentUserID(); if (empty($this->parameters['id'])) { - $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity()); + $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity()); } if (!$post = Post::selectOriginal(['uri-id'], ['uri-id' => $this->parameters['id'], 'uid' => [0, $uid]])) { diff --git a/src/Module/Api/Mastodon/Statuses/Context.php b/src/Module/Api/Mastodon/Statuses/Context.php index dbce15058..6e35d717b 100644 --- a/src/Module/Api/Mastodon/Statuses/Context.php +++ b/src/Module/Api/Mastodon/Statuses/Context.php @@ -41,7 +41,7 @@ class Context extends BaseApi $uid = self::getCurrentUserID(); if (empty($this->parameters['id'])) { - $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity()); + $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity()); } $request = $this->getRequest([ @@ -116,7 +116,7 @@ class Context extends BaseApi } DBA::close($posts); } else { - $this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound()); + $this->logAndJsonError(404, $this->errorFactory->RecordNotFound()); } } diff --git a/src/Module/Api/Mastodon/Statuses/Favourite.php b/src/Module/Api/Mastodon/Statuses/Favourite.php index 103de8679..04e4c6256 100644 --- a/src/Module/Api/Mastodon/Statuses/Favourite.php +++ b/src/Module/Api/Mastodon/Statuses/Favourite.php @@ -39,12 +39,12 @@ class Favourite extends BaseApi $uid = self::getCurrentUserID(); if (empty($this->parameters['id'])) { - $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity()); + $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity()); } $item = Post::selectOriginalForUser($uid, ['id', 'uri-id'], ['uri-id' => $this->parameters['id'], 'uid' => [$uid, 0]]); if (!DBA::isResult($item)) { - $this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound()); + $this->logAndJsonError(404, $this->errorFactory->RecordNotFound()); } Item::performActivity($item['id'], 'like', $uid); diff --git a/src/Module/Api/Mastodon/Statuses/FavouritedBy.php b/src/Module/Api/Mastodon/Statuses/FavouritedBy.php index d91eff0b8..96c86dfb1 100644 --- a/src/Module/Api/Mastodon/Statuses/FavouritedBy.php +++ b/src/Module/Api/Mastodon/Statuses/FavouritedBy.php @@ -41,11 +41,11 @@ class FavouritedBy extends BaseApi $uid = self::getCurrentUserID(); if (empty($this->parameters['id'])) { - $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity()); + $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity()); } if (!$post = Post::selectOriginal(['uri-id'], ['uri-id' => $this->parameters['id'], 'uid' => [0, $uid]])) { - $this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound()); + $this->logAndJsonError(404, $this->errorFactory->RecordNotFound()); } $activities = Post::selectPosts(['author-id'], ['thr-parent-id' => $post['uri-id'], 'gravity' => Item::GRAVITY_ACTIVITY, 'verb' => Activity::LIKE, 'deleted' => false]); diff --git a/src/Module/Api/Mastodon/Statuses/Mute.php b/src/Module/Api/Mastodon/Statuses/Mute.php index 0931cd733..fc6b642b4 100644 --- a/src/Module/Api/Mastodon/Statuses/Mute.php +++ b/src/Module/Api/Mastodon/Statuses/Mute.php @@ -39,16 +39,16 @@ class Mute extends BaseApi $uid = self::getCurrentUserID(); if (empty($this->parameters['id'])) { - $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity()); + $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity()); } $item = Post::selectOriginalForUser($uid, ['uri-id', 'gravity'], ['uri-id' => $this->parameters['id'], 'uid' => [$uid, 0]]); if (!DBA::isResult($item)) { - $this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound()); + $this->logAndJsonError(404, $this->errorFactory->RecordNotFound()); } if ($item['gravity'] != Item::GRAVITY_PARENT) { - $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity($this->t('Only starting posts can be muted'))); + $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity($this->t('Only starting posts can be muted'))); } Post\ThreadUser::setIgnored($item['uri-id'], $uid, true); diff --git a/src/Module/Api/Mastodon/Statuses/Pin.php b/src/Module/Api/Mastodon/Statuses/Pin.php index fbd2f00ce..b5c8f5c6e 100644 --- a/src/Module/Api/Mastodon/Statuses/Pin.php +++ b/src/Module/Api/Mastodon/Statuses/Pin.php @@ -38,12 +38,12 @@ class Pin extends BaseApi $uid = self::getCurrentUserID(); if (empty($this->parameters['id'])) { - $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity()); + $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity()); } $item = Post::selectOriginalForUser($uid, ['uri-id', 'gravity', 'author-id'], ['uri-id' => $this->parameters['id'], 'uid' => [$uid, 0]]); if (!DBA::isResult($item)) { - $this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound()); + $this->logAndJsonError(404, $this->errorFactory->RecordNotFound()); } Post\Collection::add($item['uri-id'], Post\Collection::FEATURED, $item['author-id'], $uid); diff --git a/src/Module/Api/Mastodon/Statuses/Reblog.php b/src/Module/Api/Mastodon/Statuses/Reblog.php index 54ada1d1f..cf35286b2 100644 --- a/src/Module/Api/Mastodon/Statuses/Reblog.php +++ b/src/Module/Api/Mastodon/Statuses/Reblog.php @@ -42,18 +42,18 @@ class Reblog extends BaseApi $uid = self::getCurrentUserID(); if (empty($this->parameters['id'])) { - $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity()); + $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity()); } $item = Post::selectOriginalForUser($uid, ['id', 'uri-id', 'network'], ['uri-id' => $this->parameters['id'], 'uid' => [$uid, 0]]); if (!DBA::isResult($item)) { - $this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound()); + $this->logAndJsonError(404, $this->errorFactory->RecordNotFound()); } if ($item['network'] == Protocol::DIASPORA) { Diaspora::performReshare($this->parameters['id'], $uid); } elseif (!in_array($item['network'], [Protocol::DFRN, Protocol::ACTIVITYPUB, Protocol::TWITTER])) { - $this->logErrorAndJsonExit( + $this->logAndJsonError( 422, $this->errorFactory->UnprocessableEntity($this->t("Posts from %s can't be shared", ContactSelector::networkToName($item['network']))) ); diff --git a/src/Module/Api/Mastodon/Statuses/RebloggedBy.php b/src/Module/Api/Mastodon/Statuses/RebloggedBy.php index eab40c665..0c8376fd0 100644 --- a/src/Module/Api/Mastodon/Statuses/RebloggedBy.php +++ b/src/Module/Api/Mastodon/Statuses/RebloggedBy.php @@ -41,11 +41,11 @@ class RebloggedBy extends BaseApi $uid = self::getCurrentUserID(); if (empty($this->parameters['id'])) { - $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity()); + $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity()); } if (!$post = Post::selectOriginal(['uri-id'], ['uri-id' => $this->parameters['id'], 'uid' => [0, $uid]])) { - $this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound()); + $this->logAndJsonError(404, $this->errorFactory->RecordNotFound()); } $activities = Post::selectPosts(['author-id'], ['thr-parent-id' => $post['uri-id'], 'gravity' => Item::GRAVITY_ACTIVITY, 'verb' => Activity::ANNOUNCE]); diff --git a/src/Module/Api/Mastodon/Statuses/Source.php b/src/Module/Api/Mastodon/Statuses/Source.php index 1e72f33a0..8810058d6 100644 --- a/src/Module/Api/Mastodon/Statuses/Source.php +++ b/src/Module/Api/Mastodon/Statuses/Source.php @@ -41,7 +41,7 @@ class Source extends BaseApi $uid = self::getCurrentUserID(); if (empty($this->parameters['id'])) { - $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity()); + $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity()); } $id = $this->parameters['id']; diff --git a/src/Module/Api/Mastodon/Statuses/Unbookmark.php b/src/Module/Api/Mastodon/Statuses/Unbookmark.php index c64a6c8a7..594cde422 100644 --- a/src/Module/Api/Mastodon/Statuses/Unbookmark.php +++ b/src/Module/Api/Mastodon/Statuses/Unbookmark.php @@ -39,16 +39,16 @@ class Unbookmark extends BaseApi $uid = self::getCurrentUserID(); if (empty($this->parameters['id'])) { - $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity()); + $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity()); } $item = Post::selectOriginal(['uid', 'id', 'uri-id', 'gravity'], ['uri-id' => $this->parameters['id'], 'uid' => [$uid, 0]], ['order' => ['uid' => true]]); if (!DBA::isResult($item)) { - $this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound()); + $this->logAndJsonError(404, $this->errorFactory->RecordNotFound()); } if ($item['gravity'] != Item::GRAVITY_PARENT) { - $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity($this->t('Only starting posts can be unbookmarked'))); + $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity($this->t('Only starting posts can be unbookmarked'))); } if ($item['uid'] == 0) { @@ -56,10 +56,10 @@ class Unbookmark extends BaseApi if (!empty($stored)) { $item = Post::selectFirst(['id', 'gravity'], ['id' => $stored]); if (!DBA::isResult($item)) { - $this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound()); + $this->logAndJsonError(404, $this->errorFactory->RecordNotFound()); } } else { - $this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound()); + $this->logAndJsonError(404, $this->errorFactory->RecordNotFound()); } } diff --git a/src/Module/Api/Mastodon/Statuses/Unfavourite.php b/src/Module/Api/Mastodon/Statuses/Unfavourite.php index 78e9fb350..631e18dda 100644 --- a/src/Module/Api/Mastodon/Statuses/Unfavourite.php +++ b/src/Module/Api/Mastodon/Statuses/Unfavourite.php @@ -39,12 +39,12 @@ class Unfavourite extends BaseApi $uid = self::getCurrentUserID(); if (empty($this->parameters['id'])) { - $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity()); + $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity()); } $item = Post::selectOriginalForUser($uid, ['id', 'uri-id'], ['uri-id' => $this->parameters['id'], 'uid' => [$uid, 0]]); if (!DBA::isResult($item)) { - $this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound()); + $this->logAndJsonError(404, $this->errorFactory->RecordNotFound()); } Item::performActivity($item['id'], 'unlike', $uid); diff --git a/src/Module/Api/Mastodon/Statuses/Unmute.php b/src/Module/Api/Mastodon/Statuses/Unmute.php index e54380dbe..9fb05e8f6 100644 --- a/src/Module/Api/Mastodon/Statuses/Unmute.php +++ b/src/Module/Api/Mastodon/Statuses/Unmute.php @@ -39,16 +39,16 @@ class Unmute extends BaseApi $uid = self::getCurrentUserID(); if (empty($this->parameters['id'])) { - $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity()); + $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity()); } $item = Post::selectOriginalForUser($uid, ['uri-id', 'gravity'], ['uri-id' => $this->parameters['id'], 'uid' => [$uid, 0]]); if (!DBA::isResult($item)) { - $this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound()); + $this->logAndJsonError(404, $this->errorFactory->RecordNotFound()); } if ($item['gravity'] != Item::GRAVITY_PARENT) { - $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity($this->t('Only starting posts can be unmuted'))); + $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity($this->t('Only starting posts can be unmuted'))); } Post\ThreadUser::setIgnored($item['uri-id'], $uid, false); diff --git a/src/Module/Api/Mastodon/Statuses/Unpin.php b/src/Module/Api/Mastodon/Statuses/Unpin.php index f04ff5306..626e18d75 100644 --- a/src/Module/Api/Mastodon/Statuses/Unpin.php +++ b/src/Module/Api/Mastodon/Statuses/Unpin.php @@ -38,12 +38,12 @@ class Unpin extends BaseApi $uid = self::getCurrentUserID(); if (empty($this->parameters['id'])) { - $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity()); + $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity()); } $item = Post::selectOriginalForUser($uid, ['uri-id', 'gravity'], ['uri-id' => $this->parameters['id'], 'uid' => [$uid, 0]]); if (!DBA::isResult($item)) { - $this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound()); + $this->logAndJsonError(404, $this->errorFactory->RecordNotFound()); } Post\Collection::remove($item['uri-id'], Post\Collection::FEATURED, $uid); diff --git a/src/Module/Api/Mastodon/Statuses/Unreblog.php b/src/Module/Api/Mastodon/Statuses/Unreblog.php index 50931cecd..2036bb1fb 100644 --- a/src/Module/Api/Mastodon/Statuses/Unreblog.php +++ b/src/Module/Api/Mastodon/Statuses/Unreblog.php @@ -41,25 +41,25 @@ class Unreblog extends BaseApi $uid = self::getCurrentUserID(); if (empty($this->parameters['id'])) { - $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity()); + $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity()); } $item = Post::selectOriginalForUser($uid, ['id', 'uri-id', 'network'], ['uri-id' => $this->parameters['id'], 'uid' => [$uid, 0]]); if (!DBA::isResult($item)) { - $this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound()); + $this->logAndJsonError(404, $this->errorFactory->RecordNotFound()); } if ($item['network'] == Protocol::DIASPORA) { $item = Post::selectFirstForUser($uid, ['id'], ['quote-uri-id' => $this->parameters['id'], 'body' => '', 'origin' => true, 'uid' => $uid]); if (empty($item['id'])) { - $this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound()); + $this->logAndJsonError(404, $this->errorFactory->RecordNotFound()); } if (!Item::markForDeletionById($item['id'])) { - $this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound()); + $this->logAndJsonError(404, $this->errorFactory->RecordNotFound()); } } elseif (!in_array($item['network'], [Protocol::DFRN, Protocol::ACTIVITYPUB, Protocol::TWITTER])) { - $this->logErrorAndJsonExit( + $this->logAndJsonError( 422, $this->errorFactory->UnprocessableEntity($this->t("Posts from %s can't be unshared", ContactSelector::networkToName($item['network']))) ); diff --git a/src/Module/Api/Mastodon/Tags.php b/src/Module/Api/Mastodon/Tags.php index d61ee88ac..00cbac0d9 100644 --- a/src/Module/Api/Mastodon/Tags.php +++ b/src/Module/Api/Mastodon/Tags.php @@ -40,7 +40,7 @@ class Tags extends BaseApi $uid = self::getCurrentUserID(); if (empty($this->parameters['hashtag'])) { - $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity()); + $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity()); } $tag = ltrim($this->parameters['hashtag'], '#'); diff --git a/src/Module/Api/Mastodon/Tags/Follow.php b/src/Module/Api/Mastodon/Tags/Follow.php index 03844a7dd..0fe6307eb 100644 --- a/src/Module/Api/Mastodon/Tags/Follow.php +++ b/src/Module/Api/Mastodon/Tags/Follow.php @@ -37,7 +37,7 @@ class Follow extends BaseApi $uid = self::getCurrentUserID(); if (empty($this->parameters['hashtag'])) { - $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity()); + $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity()); } $fields = ['uid' => $uid, 'term' => '#' . ltrim($this->parameters['hashtag'], '#')]; diff --git a/src/Module/Api/Mastodon/Tags/Unfollow.php b/src/Module/Api/Mastodon/Tags/Unfollow.php index 07b93d95a..31e2ade4e 100644 --- a/src/Module/Api/Mastodon/Tags/Unfollow.php +++ b/src/Module/Api/Mastodon/Tags/Unfollow.php @@ -37,7 +37,7 @@ class Unfollow extends BaseApi $uid = self::getCurrentUserID(); if (empty($this->parameters['hashtag'])) { - $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity()); + $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity()); } $term = ['uid' => $uid, 'term' => '#' . ltrim($this->parameters['hashtag'], '#')]; diff --git a/src/Module/Api/Mastodon/Timelines/Direct.php b/src/Module/Api/Mastodon/Timelines/Direct.php index 730b63910..356a4fa94 100644 --- a/src/Module/Api/Mastodon/Timelines/Direct.php +++ b/src/Module/Api/Mastodon/Timelines/Direct.php @@ -83,7 +83,7 @@ class Direct extends BaseApi $statuses[] = DI::mstdnStatus()->createFromMailId($mail['id']); } } catch (NotFoundException $e) { - $this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound()); + $this->logAndJsonError(404, $this->errorFactory->RecordNotFound()); } if (!empty($request['min_id'])) { diff --git a/src/Module/Api/Mastodon/Timelines/ListTimeline.php b/src/Module/Api/Mastodon/Timelines/ListTimeline.php index baed01e0e..4331fc321 100644 --- a/src/Module/Api/Mastodon/Timelines/ListTimeline.php +++ b/src/Module/Api/Mastodon/Timelines/ListTimeline.php @@ -45,7 +45,7 @@ class ListTimeline extends BaseApi $uid = self::getCurrentUserID(); if (empty($this->parameters['id'])) { - $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity()); + $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity()); } $request = $this->getRequest([ diff --git a/src/Module/Api/Mastodon/Timelines/Tag.php b/src/Module/Api/Mastodon/Timelines/Tag.php index 60bdab837..e08453327 100644 --- a/src/Module/Api/Mastodon/Timelines/Tag.php +++ b/src/Module/Api/Mastodon/Timelines/Tag.php @@ -45,7 +45,7 @@ class Tag extends BaseApi $uid = self::getCurrentUserID(); if (empty($this->parameters['hashtag'])) { - $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity()); + $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity()); } /** diff --git a/src/Module/BaseApi.php b/src/Module/BaseApi.php index b2d729f28..7d21d7a8d 100644 --- a/src/Module/BaseApi.php +++ b/src/Module/BaseApi.php @@ -424,17 +424,17 @@ class BaseApi extends BaseModule if (empty($token)) { $this->logger->notice('Empty application token'); - $this->logErrorAndJsonExit(403, $this->errorFactory->Forbidden()); + $this->logAndJsonError(403, $this->errorFactory->Forbidden()); } if (!isset($token[$scope])) { $this->logger->warning('The requested scope does not exist', ['scope' => $scope, 'application' => $token]); - $this->logErrorAndJsonExit(403, $this->errorFactory->Forbidden()); + $this->logAndJsonError(403, $this->errorFactory->Forbidden()); } if (empty($token[$scope])) { $this->logger->warning('The requested scope is not allowed', ['scope' => $scope, 'application' => $token]); - $this->logErrorAndJsonExit(403, $this->errorFactory->Forbidden()); + $this->logAndJsonError(403, $this->errorFactory->Forbidden()); } } @@ -526,7 +526,7 @@ class BaseApi extends BaseModule * @return void * @throws HTTPException\InternalServerErrorException */ - protected function logErrorAndJsonExit(int $errorno, Error $error) + protected function logAndJsonError(int $errorno, Error $error) { $this->logger->info('API Error', ['no' => $errorno, 'error' => $error->toArray(), 'method' => $this->args->getMethod(), 'command' => $this->args->getQueryString(), 'user-agent' => $this->server['HTTP_USER_AGENT'] ?? '']); $this->jsonError(403, $error->toArray()); diff --git a/src/Module/OAuth/Authorize.php b/src/Module/OAuth/Authorize.php index e9ef07c62..31db02b01 100644 --- a/src/Module/OAuth/Authorize.php +++ b/src/Module/OAuth/Authorize.php @@ -51,17 +51,17 @@ class Authorize extends BaseApi if ($request['response_type'] != 'code') { Logger::warning('Unsupported or missing response type', ['request' => $_REQUEST]); - $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity($this->t('Unsupported or missing response type'))); + $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity($this->t('Unsupported or missing response type'))); } if (empty($request['client_id']) || empty($request['redirect_uri'])) { Logger::warning('Incomplete request data', ['request' => $_REQUEST]); - $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity($this->t('Incomplete request data'))); + $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity($this->t('Incomplete request data'))); } $application = OAuth::getApplication($request['client_id'], $request['client_secret'], $request['redirect_uri']); if (empty($application)) { - $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity()); + $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity()); } // @todo Compare the application scope and requested scope @@ -87,7 +87,7 @@ class Authorize extends BaseApi $token = OAuth::createTokenForUser($application, $uid, $request['scope']); if (!$token) { - $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity()); + $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity()); } if ($application['redirect_uri'] != 'urn:ietf:wg:oauth:2.0:oob') { diff --git a/src/Module/OAuth/Revoke.php b/src/Module/OAuth/Revoke.php index 979114434..a20482b22 100644 --- a/src/Module/OAuth/Revoke.php +++ b/src/Module/OAuth/Revoke.php @@ -51,7 +51,7 @@ class Revoke extends BaseApi $token = DBA::selectFirst('application-view', ['id'], $condition); if (empty($token['id'])) { $this->logger->notice('Token not found', $condition); - $this->logErrorAndJsonExit(401, $this->errorFactory->Unauthorized()); + $this->logAndJsonError(401, $this->errorFactory->Unauthorized()); } DBA::delete('application-token', ['application-id' => $token['id']]); diff --git a/src/Module/OAuth/Token.php b/src/Module/OAuth/Token.php index 0186f2851..7e22a88da 100644 --- a/src/Module/OAuth/Token.php +++ b/src/Module/OAuth/Token.php @@ -75,12 +75,12 @@ class Token extends BaseApi if (empty($request['client_id']) || empty($request['client_secret'])) { $this->logger->warning('Incomplete request data', ['request' => $request]); - $this->logErrorAndJsonExit(401, $this->errorFactory->Unauthorized('invalid_client', $this->t('Incomplete request data')));; + $this->logAndJsonError(401, $this->errorFactory->Unauthorized('invalid_client', $this->t('Incomplete request data')));; } $application = OAuth::getApplication($request['client_id'], $request['client_secret'], $request['redirect_uri']); if (empty($application)) { - $this->logErrorAndJsonExit(401, $this->errorFactory->Unauthorized('invalid_client', $this->t('Invalid data or unknown client'))); + $this->logAndJsonError(401, $this->errorFactory->Unauthorized('invalid_client', $this->t('Invalid data or unknown client'))); } if ($request['grant_type'] == 'client_credentials') { @@ -99,13 +99,13 @@ class Token extends BaseApi $token = DBA::selectFirst('application-view', ['access_token', 'created_at', 'uid'], $condition); if (!DBA::isResult($token)) { $this->logger->notice('Token not found or outdated', $condition); - $this->logErrorAndJsonExit(401, $this->errorFactory->Unauthorized()); + $this->logAndJsonError(401, $this->errorFactory->Unauthorized()); } $owner = User::getOwnerDataById($token['uid']); $me = $owner['url']; } else { Logger::warning('Unsupported or missing grant type', ['request' => $_REQUEST]); - $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity($this->t('Unsupported or missing grant type'))); + $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity($this->t('Unsupported or missing grant type'))); } $object = new \Friendica\Object\Api\Mastodon\Token($token['access_token'], 'Bearer', $application['scopes'], $token['created_at'], $me); From 5d428ac8af702a374f8b9677e1e6502bbc9b256a Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Wed, 11 Oct 2023 10:01:32 -0400 Subject: [PATCH 10/10] Add newly required constructor parameter to BaseApi-related tests --- .../Module/Api/Friendica/DirectMessages/SearchTest.php | 6 +++--- tests/src/Module/Api/Friendica/NotificationTest.php | 4 ++-- tests/src/Module/Api/Friendica/Photo/DeleteTest.php | 8 ++++---- .../src/Module/Api/Friendica/Photoalbum/DeleteTest.php | 6 +++--- .../src/Module/Api/Friendica/Photoalbum/UpdateTest.php | 8 ++++---- .../src/Module/Api/GnuSocial/GnuSocial/ConfigTest.php | 2 +- .../src/Module/Api/GnuSocial/GnuSocial/VersionTest.php | 2 +- tests/src/Module/Api/GnuSocial/Help/TestTest.php | 6 +++--- .../Api/Mastodon/Accounts/VerifyCredentialsTest.php | 2 +- .../Module/Api/Twitter/Account/RateLimitStatusTest.php | 4 ++-- .../Module/Api/Twitter/Account/UpdateProfileTest.php | 2 +- tests/src/Module/Api/Twitter/Blocks/ListsTest.php | 2 +- .../src/Module/Api/Twitter/DirectMessages/AllTest.php | 2 +- .../Api/Twitter/DirectMessages/ConversationTest.php | 2 +- .../Module/Api/Twitter/DirectMessages/DestroyTest.php | 10 +++++----- .../Module/Api/Twitter/DirectMessages/InboxTest.php | 2 +- .../Module/Api/Twitter/DirectMessages/NewDMTest.php | 10 +++++----- .../src/Module/Api/Twitter/DirectMessages/SentTest.php | 4 ++-- tests/src/Module/Api/Twitter/Favorites/CreateTest.php | 6 +++--- tests/src/Module/Api/Twitter/Favorites/DestroyTest.php | 4 ++-- tests/src/Module/Api/Twitter/FavoritesTest.php | 4 ++-- tests/src/Module/Api/Twitter/Followers/ListsTest.php | 2 +- tests/src/Module/Api/Twitter/Friends/ListsTest.php | 2 +- .../Module/Api/Twitter/Friendships/IncomingTest.php | 2 +- tests/src/Module/Api/Twitter/Lists/StatusesTest.php | 6 +++--- tests/src/Module/Api/Twitter/Media/UploadTest.php | 8 ++++---- tests/src/Module/Api/Twitter/SavedSearchesTest.php | 2 +- tests/src/Module/Api/Twitter/Statuses/DestroyTest.php | 4 ++-- tests/src/Module/Api/Twitter/Statuses/MentionsTest.php | 6 +++--- .../Api/Twitter/Statuses/NetworkPublicTimelineTest.php | 6 +++--- tests/src/Module/Api/Twitter/Statuses/RetweetTest.php | 6 +++--- tests/src/Module/Api/Twitter/Statuses/ShowTest.php | 6 +++--- tests/src/Module/Api/Twitter/Statuses/UpdateTest.php | 4 ++-- .../Module/Api/Twitter/Statuses/UserTimelineTest.php | 6 +++--- tests/src/Module/Api/Twitter/Users/LookupTest.php | 4 ++-- tests/src/Module/Api/Twitter/Users/SearchTest.php | 6 +++--- tests/src/Module/Api/Twitter/Users/ShowTest.php | 4 ++-- 37 files changed, 85 insertions(+), 85 deletions(-) diff --git a/tests/src/Module/Api/Friendica/DirectMessages/SearchTest.php b/tests/src/Module/Api/Friendica/DirectMessages/SearchTest.php index c99798441..e17afb9be 100644 --- a/tests/src/Module/Api/Friendica/DirectMessages/SearchTest.php +++ b/tests/src/Module/Api/Friendica/DirectMessages/SearchTest.php @@ -34,7 +34,7 @@ class SearchTest extends ApiTest { $directMessage = new DirectMessage(new NullLogger(), DI::dba(), DI::twitterUser()); - $response = (new Search($directMessage, DI::dba(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [])) + $response = (new Search($directMessage, DI::dba(), DI::mstdnError(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [])) ->run($this->httpExceptionMock); $json = $this->toJson($response); @@ -52,7 +52,7 @@ class SearchTest extends ApiTest $directMessage = new DirectMessage(new NullLogger(), DI::dba(), DI::twitterUser()); - $response = (new Search($directMessage, DI::dba(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [])) + $response = (new Search($directMessage, DI::dba(), DI::mstdnError(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [])) ->run($this->httpExceptionMock, [ 'searchstring' => 'item_body' ]); @@ -73,7 +73,7 @@ class SearchTest extends ApiTest { $directMessage = new DirectMessage(new NullLogger(), DI::dba(), DI::twitterUser()); - $response = (new Search($directMessage, DI::dba(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [])) + $response = (new Search($directMessage, DI::dba(), DI::mstdnError(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [])) ->run($this->httpExceptionMock, [ 'searchstring' => 'test' ]); diff --git a/tests/src/Module/Api/Friendica/NotificationTest.php b/tests/src/Module/Api/Friendica/NotificationTest.php index aaf702202..06191e3d3 100644 --- a/tests/src/Module/Api/Friendica/NotificationTest.php +++ b/tests/src/Module/Api/Friendica/NotificationTest.php @@ -66,7 +66,7 @@ class NotificationTest extends ApiTest XML; - $response = (new Notification(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [], ['extension' => 'xml'])) + $response = (new Notification(DI::mstdnError(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [], ['extension' => 'xml'])) ->run($this->httpExceptionMock); self::assertXmlStringEqualsXmlString($assertXml, (string)$response->getBody()); @@ -78,7 +78,7 @@ XML; public function testWithJsonResult() { - $response = (new Notification(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [], ['extension' => 'json'])) + $response = (new Notification(DI::mstdnError(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [], ['extension' => 'json'])) ->run($this->httpExceptionMock); $json = $this->toJson($response); diff --git a/tests/src/Module/Api/Friendica/Photo/DeleteTest.php b/tests/src/Module/Api/Friendica/Photo/DeleteTest.php index 637ff9581..7e3009559 100644 --- a/tests/src/Module/Api/Friendica/Photo/DeleteTest.php +++ b/tests/src/Module/Api/Friendica/Photo/DeleteTest.php @@ -39,7 +39,7 @@ class DeleteTest extends ApiTest public function testEmpty() { $this->expectException(BadRequestException::class); - (new Delete(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), []))->run($this->httpExceptionMock); + (new Delete(DI::mstdnError(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), []))->run($this->httpExceptionMock); } public function testWithoutAuthenticatedUser() @@ -50,14 +50,14 @@ class DeleteTest extends ApiTest public function testWrong() { $this->expectException(BadRequestException::class); - (new Delete(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), []))->run($this->httpExceptionMock, ['photo_id' => 1]); + (new Delete(DI::mstdnError(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), []))->run($this->httpExceptionMock, ['photo_id' => 1]); } public function testValidWithPost() { $this->loadFixture(__DIR__ . '/../../../../../datasets/photo/photo.fixture.php', DI::dba()); - $response = (new Delete(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [])) + $response = (new Delete(DI::mstdnError(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [])) ->run($this->httpExceptionMock, [ 'photo_id' => '709057080661a283a6aa598501504178' ]); @@ -72,7 +72,7 @@ class DeleteTest extends ApiTest { $this->loadFixture(__DIR__ . '/../../../../../datasets/photo/photo.fixture.php', DI::dba()); - $response = (new Delete(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [])) + $response = (new Delete(DI::mstdnError(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [])) ->run($this->httpExceptionMock, [ 'photo_id' => '709057080661a283a6aa598501504178' ]); diff --git a/tests/src/Module/Api/Friendica/Photoalbum/DeleteTest.php b/tests/src/Module/Api/Friendica/Photoalbum/DeleteTest.php index 1cc255c36..7d483f1fd 100644 --- a/tests/src/Module/Api/Friendica/Photoalbum/DeleteTest.php +++ b/tests/src/Module/Api/Friendica/Photoalbum/DeleteTest.php @@ -39,7 +39,7 @@ class DeleteTest extends ApiTest public function testEmpty() { $this->expectException(BadRequestException::class); - (new Delete(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [])) + (new Delete(DI::mstdnError(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [])) ->run($this->httpExceptionMock); } @@ -47,7 +47,7 @@ class DeleteTest extends ApiTest public function testWrong() { $this->expectException(BadRequestException::class); - (new Delete(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [])) + (new Delete(DI::mstdnError(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [])) ->run($this->httpExceptionMock, [ 'album' => 'album_name' ]); @@ -57,7 +57,7 @@ class DeleteTest extends ApiTest { $this->loadFixture(__DIR__ . '/../../../../../datasets/photo/photo.fixture.php', DI::dba()); - $response = (new Delete(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [])) + $response = (new Delete(DI::mstdnError(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [])) ->run($this->httpExceptionMock, [ 'album' => 'test_album'] ); diff --git a/tests/src/Module/Api/Friendica/Photoalbum/UpdateTest.php b/tests/src/Module/Api/Friendica/Photoalbum/UpdateTest.php index 3812c7ffb..4d8c7ff7f 100644 --- a/tests/src/Module/Api/Friendica/Photoalbum/UpdateTest.php +++ b/tests/src/Module/Api/Friendica/Photoalbum/UpdateTest.php @@ -39,14 +39,14 @@ class UpdateTest extends ApiTest public function testEmpty() { $this->expectException(BadRequestException::class); - (new Update(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [])) + (new Update(DI::mstdnError(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [])) ->run($this->httpExceptionMock); } public function testTooFewArgs() { $this->expectException(BadRequestException::class); - (new Update(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [])) + (new Update(DI::mstdnError(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [])) ->run($this->httpExceptionMock, [ 'album' => 'album_name' ]); @@ -55,7 +55,7 @@ class UpdateTest extends ApiTest public function testWrongUpdate() { $this->expectException(BadRequestException::class); - (new Update(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [])) + (new Update(DI::mstdnError(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [])) ->run($this->httpExceptionMock, [ 'album' => 'album_name', 'album_new' => 'album_name' @@ -71,7 +71,7 @@ class UpdateTest extends ApiTest { $this->loadFixture(__DIR__ . '/../../../../../datasets/photo/photo.fixture.php', DI::dba()); - $response = (new Update(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [])) + $response = (new Update(DI::mstdnError(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [])) ->run($this->httpExceptionMock, [ 'album' => 'test_album', 'album_new' => 'test_album_2' diff --git a/tests/src/Module/Api/GnuSocial/GnuSocial/ConfigTest.php b/tests/src/Module/Api/GnuSocial/GnuSocial/ConfigTest.php index b6166fc40..db1607006 100644 --- a/tests/src/Module/Api/GnuSocial/GnuSocial/ConfigTest.php +++ b/tests/src/Module/Api/GnuSocial/GnuSocial/ConfigTest.php @@ -32,7 +32,7 @@ class ConfigTest extends ApiTest */ public function testApiStatusnetConfig() { - $response = (new Config(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [])) + $response = (new Config(DI::mstdnError(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [])) ->run($this->httpExceptionMock); $json = $this->toJson($response); diff --git a/tests/src/Module/Api/GnuSocial/GnuSocial/VersionTest.php b/tests/src/Module/Api/GnuSocial/GnuSocial/VersionTest.php index 2b636565a..11fa444ef 100644 --- a/tests/src/Module/Api/GnuSocial/GnuSocial/VersionTest.php +++ b/tests/src/Module/Api/GnuSocial/GnuSocial/VersionTest.php @@ -30,7 +30,7 @@ class VersionTest extends ApiTest { public function test() { - $response = (new Version(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [], ['extension' => 'json'])) + $response = (new Version(DI::mstdnError(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [], ['extension' => 'json'])) ->run($this->httpExceptionMock); self::assertEquals([ diff --git a/tests/src/Module/Api/GnuSocial/Help/TestTest.php b/tests/src/Module/Api/GnuSocial/Help/TestTest.php index 1b7934a19..452211bb0 100644 --- a/tests/src/Module/Api/GnuSocial/Help/TestTest.php +++ b/tests/src/Module/Api/GnuSocial/Help/TestTest.php @@ -30,7 +30,7 @@ class TestTest extends ApiTest { public function testJson() { - $response = (new Test(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [], ['extension' => 'json'])) + $response = (new Test(DI::mstdnError(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [], ['extension' => 'json'])) ->run($this->httpExceptionMock); $json = $this->toJson($response); @@ -44,13 +44,13 @@ class TestTest extends ApiTest public function testXml() { - $response = (new Test(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [], ['extension' => 'xml'])) + $response = (new Test(DI::mstdnError(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [], ['extension' => 'xml'])) ->run($this->httpExceptionMock); self::assertEquals([ 'Content-type' => ['text/xml'], ICanCreateResponses::X_HEADER => ['xml'] ], $response->getHeaders()); - self::assertxml($response->getBody(), 'ok'); + self::assertXml($response->getBody(), 'ok'); } } diff --git a/tests/src/Module/Api/Mastodon/Accounts/VerifyCredentialsTest.php b/tests/src/Module/Api/Mastodon/Accounts/VerifyCredentialsTest.php index 6afa44b83..06a3b8614 100644 --- a/tests/src/Module/Api/Mastodon/Accounts/VerifyCredentialsTest.php +++ b/tests/src/Module/Api/Mastodon/Accounts/VerifyCredentialsTest.php @@ -35,7 +35,7 @@ class VerifyCredentialsTest extends ApiTest */ public function testApiAccountVerifyCredentials() { - $response = (new VerifyCredentials(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [])) + $response = (new VerifyCredentials(DI::mstdnError(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [])) ->run($this->httpExceptionMock); $json = $this->toJson($response); diff --git a/tests/src/Module/Api/Twitter/Account/RateLimitStatusTest.php b/tests/src/Module/Api/Twitter/Account/RateLimitStatusTest.php index 960599e07..2a4cc0e40 100644 --- a/tests/src/Module/Api/Twitter/Account/RateLimitStatusTest.php +++ b/tests/src/Module/Api/Twitter/Account/RateLimitStatusTest.php @@ -31,7 +31,7 @@ class RateLimitStatusTest extends ApiTest { public function testWithJson() { - $response = (new RateLimitStatus(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [], ['extension' => 'json'])) + $response = (new RateLimitStatus(DI::mstdnError(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [], ['extension' => 'json'])) ->run($this->httpExceptionMock); $result = $this->toJson($response); @@ -47,7 +47,7 @@ class RateLimitStatusTest extends ApiTest public function testWithXml() { - $response = (new RateLimitStatus(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [], ['extension' => 'xml'])) + $response = (new RateLimitStatus(DI::mstdnError(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [], ['extension' => 'xml'])) ->run($this->httpExceptionMock); self::assertEquals([ diff --git a/tests/src/Module/Api/Twitter/Account/UpdateProfileTest.php b/tests/src/Module/Api/Twitter/Account/UpdateProfileTest.php index 2e452e3d5..71817022d 100644 --- a/tests/src/Module/Api/Twitter/Account/UpdateProfileTest.php +++ b/tests/src/Module/Api/Twitter/Account/UpdateProfileTest.php @@ -35,7 +35,7 @@ class UpdateProfileTest extends ApiTest { $this->useHttpMethod(Router::POST); - $response = (new UpdateProfile(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [], ['extension' => 'json'])) + $response = (new UpdateProfile(DI::mstdnError(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [], ['extension' => 'json'])) ->run($this->httpExceptionMock, [ 'name' => 'new_name', 'description' => 'new_description' diff --git a/tests/src/Module/Api/Twitter/Blocks/ListsTest.php b/tests/src/Module/Api/Twitter/Blocks/ListsTest.php index 8a61ad88f..2476315a0 100644 --- a/tests/src/Module/Api/Twitter/Blocks/ListsTest.php +++ b/tests/src/Module/Api/Twitter/Blocks/ListsTest.php @@ -33,7 +33,7 @@ class ListsTest extends ApiTest */ public function testApiStatusesFWithBlocks() { - $response = (new Lists(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [])) + $response = (new Lists(DI::mstdnError(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [])) ->run($this->httpExceptionMock); $json = $this->toJson($response); diff --git a/tests/src/Module/Api/Twitter/DirectMessages/AllTest.php b/tests/src/Module/Api/Twitter/DirectMessages/AllTest.php index 6ed3e15dc..c04097cd8 100644 --- a/tests/src/Module/Api/Twitter/DirectMessages/AllTest.php +++ b/tests/src/Module/Api/Twitter/DirectMessages/AllTest.php @@ -39,7 +39,7 @@ class AllTest extends ApiTest $directMessage = new DirectMessage(DI::logger(), DI::dba(), DI::twitterUser()); - $response = (new All($directMessage, DI::dba(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [], ['extension' => 'json'])) + $response = (new All($directMessage, DI::dba(), DI::mstdnError(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [], ['extension' => 'json'])) ->run($this->httpExceptionMock); $json = $this->toJson($response); diff --git a/tests/src/Module/Api/Twitter/DirectMessages/ConversationTest.php b/tests/src/Module/Api/Twitter/DirectMessages/ConversationTest.php index f194d2a36..0dc9ba8e8 100644 --- a/tests/src/Module/Api/Twitter/DirectMessages/ConversationTest.php +++ b/tests/src/Module/Api/Twitter/DirectMessages/ConversationTest.php @@ -38,7 +38,7 @@ class ConversationTest extends ApiTest { $directMessage = new DirectMessage(DI::logger(), DI::dba(), DI::twitterUser()); - $response = (new Conversation($directMessage, DI::dba(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [], ['extension' => 'json'])) + $response = (new Conversation($directMessage, DI::dba(), DI::mstdnError(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [], ['extension' => 'json'])) ->run($this->httpExceptionMock, [ 'friendica_verbose' => true, ]); diff --git a/tests/src/Module/Api/Twitter/DirectMessages/DestroyTest.php b/tests/src/Module/Api/Twitter/DirectMessages/DestroyTest.php index 509a65a7e..d699fb713 100644 --- a/tests/src/Module/Api/Twitter/DirectMessages/DestroyTest.php +++ b/tests/src/Module/Api/Twitter/DirectMessages/DestroyTest.php @@ -37,7 +37,7 @@ class DestroyTest extends ApiTest public function testApiDirectMessagesDestroy() { $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class); - (new Destroy(DI::dba(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [], ['extension' => 'json'])) + (new Destroy(DI::dba(), DI::mstdnError(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [], ['extension' => 'json'])) ->run($this->httpExceptionMock); } @@ -48,7 +48,7 @@ class DestroyTest extends ApiTest */ public function testApiDirectMessagesDestroyWithVerbose() { - $response = (new Destroy(DI::dba(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [], ['extension' => 'json'])) + $response = (new Destroy(DI::dba(), DI::mstdnError(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [], ['extension' => 'json'])) ->run($this->httpExceptionMock, [ 'friendica_verbose' => true, ]); @@ -84,7 +84,7 @@ class DestroyTest extends ApiTest public function testApiDirectMessagesDestroyWithId() { $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class); - (new Destroy(DI::dba(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [], ['extension' => 'json'])) + (new Destroy(DI::dba(), DI::mstdnError(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [], ['extension' => 'json'])) ->run($this->httpExceptionMock, [ 'id' => 1 ]); @@ -97,7 +97,7 @@ class DestroyTest extends ApiTest */ public function testApiDirectMessagesDestroyWithIdAndVerbose() { - $response = (new Destroy(DI::dba(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [], ['extension' => 'json'])) + $response = (new Destroy(DI::dba(), DI::mstdnError(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [], ['extension' => 'json'])) ->run($this->httpExceptionMock, [ 'id' => 1, 'friendica_parenturi' => 'parent_uri', @@ -121,7 +121,7 @@ class DestroyTest extends ApiTest $ids = DBA::selectToArray('mail', ['id']); $id = $ids[0]['id']; - $response = (new Destroy(DI::dba(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [], ['extension' => 'json'])) + $response = (new Destroy(DI::dba(), DI::mstdnError(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [], ['extension' => 'json'])) ->run($this->httpExceptionMock, [ 'id' => $id, 'friendica_verbose' => true, diff --git a/tests/src/Module/Api/Twitter/DirectMessages/InboxTest.php b/tests/src/Module/Api/Twitter/DirectMessages/InboxTest.php index c73592261..6aa9db5a4 100644 --- a/tests/src/Module/Api/Twitter/DirectMessages/InboxTest.php +++ b/tests/src/Module/Api/Twitter/DirectMessages/InboxTest.php @@ -40,7 +40,7 @@ class InboxTest extends ApiTest $directMessage = new DirectMessage(DI::logger(), DI::dba(), DI::twitterUser()); - $response = (new Inbox($directMessage, DI::dba(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [], ['extension' => 'json'])) + $response = (new Inbox($directMessage, DI::dba(), DI::mstdnError(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [], ['extension' => 'json'])) ->run($this->httpExceptionMock); $json = $this->toJson($response); diff --git a/tests/src/Module/Api/Twitter/DirectMessages/NewDMTest.php b/tests/src/Module/Api/Twitter/DirectMessages/NewDMTest.php index d5df5e4ad..e0c9b070d 100644 --- a/tests/src/Module/Api/Twitter/DirectMessages/NewDMTest.php +++ b/tests/src/Module/Api/Twitter/DirectMessages/NewDMTest.php @@ -38,7 +38,7 @@ class NewDMTest extends ApiTest { $directMessage = new DirectMessage(DI::logger(), DI::dba(), DI::twitterUser()); - $response = (new NewDM($directMessage, DI::dba(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [], ['extension' => 'json'])) + $response = (new NewDM($directMessage, DI::dba(), DI::mstdnError(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [], ['extension' => 'json'])) ->run($this->httpExceptionMock); self::assertEmpty((string)$response->getBody()); @@ -70,7 +70,7 @@ class NewDMTest extends ApiTest { $directMessage = new DirectMessage(DI::logger(), DI::dba(), DI::twitterUser()); - $response = (new NewDM($directMessage, DI::dba(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [], ['extension' => 'json'])) + $response = (new NewDM($directMessage, DI::dba(), DI::mstdnError(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [], ['extension' => 'json'])) ->run($this->httpExceptionMock, [ 'text' => 'message_text', 'user_id' => 43 @@ -92,7 +92,7 @@ class NewDMTest extends ApiTest $directMessage = new DirectMessage(DI::logger(), DI::dba(), DI::twitterUser()); - $response = (new NewDM($directMessage, DI::dba(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [], ['extension' => 'json'])) + $response = (new NewDM($directMessage, DI::dba(), DI::mstdnError(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [], ['extension' => 'json'])) ->run($this->httpExceptionMock, [ 'text' => 'message_text', 'user_id' => 44 @@ -116,7 +116,7 @@ class NewDMTest extends ApiTest $directMessage = new DirectMessage(DI::logger(), DI::dba(), DI::twitterUser()); - $response = (new NewDM($directMessage, DI::dba(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [], ['extension' => 'json'])) + $response = (new NewDM($directMessage, DI::dba(), DI::mstdnError(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [], ['extension' => 'json'])) ->run($this->httpExceptionMock, [ 'text' => 'message_text', 'user_id' => 44, @@ -142,7 +142,7 @@ class NewDMTest extends ApiTest $directMessage = new DirectMessage(DI::logger(), DI::dba(), DI::twitterUser()); - $response = (new NewDM($directMessage, DI::dba(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [], ['extension' => 'rss'])) + $response = (new NewDM($directMessage, DI::dba(), DI::mstdnError(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [], ['extension' => 'rss'])) ->run($this->httpExceptionMock, [ 'text' => 'message_text', 'user_id' => 44, diff --git a/tests/src/Module/Api/Twitter/DirectMessages/SentTest.php b/tests/src/Module/Api/Twitter/DirectMessages/SentTest.php index 7886c8cff..a2355bca9 100644 --- a/tests/src/Module/Api/Twitter/DirectMessages/SentTest.php +++ b/tests/src/Module/Api/Twitter/DirectMessages/SentTest.php @@ -38,7 +38,7 @@ class SentTest extends ApiTest { $directMessage = new DirectMessage(DI::logger(), DI::dba(), DI::twitterUser()); - $response = (new Sent($directMessage, DI::dba(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [], ['extension' => 'json'])) + $response = (new Sent($directMessage, DI::dba(), DI::mstdnError(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [], ['extension' => 'json'])) ->run($this->httpExceptionMock, [ 'friendica_verbose' => true, ]); @@ -58,7 +58,7 @@ class SentTest extends ApiTest { $directMessage = new DirectMessage(DI::logger(), DI::dba(), DI::twitterUser()); - $response = (new Sent($directMessage, DI::dba(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [], ['extension' => 'rss'])) + $response = (new Sent($directMessage, DI::dba(), DI::mstdnError(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [], ['extension' => 'rss'])) ->run($this->httpExceptionMock); self::assertXml((string)$response->getBody(), 'direct-messages'); diff --git a/tests/src/Module/Api/Twitter/Favorites/CreateTest.php b/tests/src/Module/Api/Twitter/Favorites/CreateTest.php index 9ddffeef6..74f64e65e 100644 --- a/tests/src/Module/Api/Twitter/Favorites/CreateTest.php +++ b/tests/src/Module/Api/Twitter/Favorites/CreateTest.php @@ -46,7 +46,7 @@ class CreateTest extends ApiTest { $this->expectException(BadRequestException::class); - (new Create(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [])) + (new Create(DI::mstdnError(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [])) ->run($this->httpExceptionMock); } @@ -57,7 +57,7 @@ class CreateTest extends ApiTest */ public function testApiFavoritesCreateDestroyWithCreateAction() { - $response = (new Create(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [])) + $response = (new Create(DI::mstdnError(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [])) ->run($this->httpExceptionMock, [ 'id' => 3 ]); @@ -74,7 +74,7 @@ class CreateTest extends ApiTest */ public function testApiFavoritesCreateDestroyWithCreateActionAndRss() { - $response = (new Create(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [], ['extension' => ICanCreateResponses::TYPE_RSS])) + $response = (new Create(DI::mstdnError(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [], ['extension' => ICanCreateResponses::TYPE_RSS])) ->run($this->httpExceptionMock, [ 'id' => 3 ]); diff --git a/tests/src/Module/Api/Twitter/Favorites/DestroyTest.php b/tests/src/Module/Api/Twitter/Favorites/DestroyTest.php index 8dd4435bc..94c363abc 100644 --- a/tests/src/Module/Api/Twitter/Favorites/DestroyTest.php +++ b/tests/src/Module/Api/Twitter/Favorites/DestroyTest.php @@ -45,7 +45,7 @@ class DestroyTest extends ApiTest { $this->expectException(BadRequestException::class); - (new Destroy(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [])) + (new Destroy(DI::mstdnError(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [])) ->run($this->httpExceptionMock); } @@ -56,7 +56,7 @@ class DestroyTest extends ApiTest */ public function testApiFavoritesCreateDestroyWithDestroyAction() { - $response = (new Destroy(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [])) + $response = (new Destroy(DI::mstdnError(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [])) ->run($this->httpExceptionMock, [ 'id' => 3 ]); diff --git a/tests/src/Module/Api/Twitter/FavoritesTest.php b/tests/src/Module/Api/Twitter/FavoritesTest.php index c25cb8609..34c344f5f 100644 --- a/tests/src/Module/Api/Twitter/FavoritesTest.php +++ b/tests/src/Module/Api/Twitter/FavoritesTest.php @@ -36,7 +36,7 @@ class FavoritesTest extends ApiTest */ public function testApiFavorites() { - $response = (new Favorites(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [])) + $response = (new Favorites(DI::mstdnError(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [])) ->run($this->httpExceptionMock, [ 'page' => -1, 'max_id' => 10, @@ -56,7 +56,7 @@ class FavoritesTest extends ApiTest */ public function testApiFavoritesWithRss() { - $response = (new Favorites(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [], [ + $response = (new Favorites(DI::mstdnError(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [], [ 'extension' => ICanCreateResponses::TYPE_RSS ]))->run($this->httpExceptionMock); diff --git a/tests/src/Module/Api/Twitter/Followers/ListsTest.php b/tests/src/Module/Api/Twitter/Followers/ListsTest.php index fdbfb55f2..e44c27005 100644 --- a/tests/src/Module/Api/Twitter/Followers/ListsTest.php +++ b/tests/src/Module/Api/Twitter/Followers/ListsTest.php @@ -33,7 +33,7 @@ class ListsTest extends ApiTest */ public function testApiStatusesFWithFollowers() { - $response = (new Lists(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [])) + $response = (new Lists(DI::mstdnError(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [])) ->run($this->httpExceptionMock); $json = $this->toJson($response); diff --git a/tests/src/Module/Api/Twitter/Friends/ListsTest.php b/tests/src/Module/Api/Twitter/Friends/ListsTest.php index 70b28557d..0b2f4cd4e 100644 --- a/tests/src/Module/Api/Twitter/Friends/ListsTest.php +++ b/tests/src/Module/Api/Twitter/Friends/ListsTest.php @@ -35,7 +35,7 @@ class ListsTest extends ApiTest */ public function testApiStatusesFWithFriends() { - $response = (new Lists(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [])) + $response = (new Lists(DI::mstdnError(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [])) ->run($this->httpExceptionMock); $json = $this->toJson($response); diff --git a/tests/src/Module/Api/Twitter/Friendships/IncomingTest.php b/tests/src/Module/Api/Twitter/Friendships/IncomingTest.php index 076edd4f6..0b8d06980 100644 --- a/tests/src/Module/Api/Twitter/Friendships/IncomingTest.php +++ b/tests/src/Module/Api/Twitter/Friendships/IncomingTest.php @@ -35,7 +35,7 @@ class IncomingTest extends ApiTest */ public function testApiFriendshipsIncoming() { - $response = (new Incoming(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [])) + $response = (new Incoming(DI::mstdnError(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [])) ->run($this->httpExceptionMock); $json = $this->toJson($response); diff --git a/tests/src/Module/Api/Twitter/Lists/StatusesTest.php b/tests/src/Module/Api/Twitter/Lists/StatusesTest.php index b393c3b7b..8b6b9ed75 100644 --- a/tests/src/Module/Api/Twitter/Lists/StatusesTest.php +++ b/tests/src/Module/Api/Twitter/Lists/StatusesTest.php @@ -38,7 +38,7 @@ class StatusesTest extends ApiTest { $this->expectException(BadRequestException::class); - (new Statuses(DI::dba(), DI::twitterStatus(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [])) + (new Statuses(DI::dba(), DI::twitterStatus(), DI::mstdnError(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [])) ->run($this->httpExceptionMock); } @@ -47,7 +47,7 @@ class StatusesTest extends ApiTest */ public function testApiListsStatusesWithListId() { - $response = (new Statuses(DI::dba(), DI::twitterStatus(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [])) + $response = (new Statuses(DI::dba(), DI::twitterStatus(), DI::mstdnError(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [])) ->run($this->httpExceptionMock, [ 'list_id' => 1, 'page' => -1, @@ -67,7 +67,7 @@ class StatusesTest extends ApiTest */ public function testApiListsStatusesWithListIdAndRss() { - $response = (new Statuses(DI::dba(), DI::twitterStatus(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [], ['extension' => 'rss'])) + $response = (new Statuses(DI::dba(), DI::twitterStatus(), DI::mstdnError(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [], ['extension' => 'rss'])) ->run($this->httpExceptionMock, [ 'list_id' => 1 ]); diff --git a/tests/src/Module/Api/Twitter/Media/UploadTest.php b/tests/src/Module/Api/Twitter/Media/UploadTest.php index c830260d1..7ab2bcc20 100644 --- a/tests/src/Module/Api/Twitter/Media/UploadTest.php +++ b/tests/src/Module/Api/Twitter/Media/UploadTest.php @@ -46,7 +46,7 @@ class UploadTest extends ApiTest { $this->expectException(BadRequestException::class); - (new Upload(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [])) + (new Upload(DI::mstdnError(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [])) ->run($this->httpExceptionMock); } @@ -60,7 +60,7 @@ class UploadTest extends ApiTest $this->expectException(UnauthorizedException::class); AuthTestConfig::$authenticated = false; - (new Upload(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [])) + (new Upload(DI::mstdnError(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [])) ->run($this->httpExceptionMock); } @@ -79,7 +79,7 @@ class UploadTest extends ApiTest ] ]; - (new Upload(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [])) + (new Upload(DI::mstdnError(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [])) ->run($this->httpExceptionMock); } @@ -102,7 +102,7 @@ class UploadTest extends ApiTest ] ]; - $response = (new Upload(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [])) + $response = (new Upload(DI::mstdnError(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [])) ->run($this->httpExceptionMock); $media = $this->toJson($response); diff --git a/tests/src/Module/Api/Twitter/SavedSearchesTest.php b/tests/src/Module/Api/Twitter/SavedSearchesTest.php index 2e9ba9990..c92d949ea 100644 --- a/tests/src/Module/Api/Twitter/SavedSearchesTest.php +++ b/tests/src/Module/Api/Twitter/SavedSearchesTest.php @@ -30,7 +30,7 @@ class SavedSearchesTest extends ApiTest { public function test() { - $response = (new SavedSearches(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [], ['extension' => 'json'])) + $response = (new SavedSearches(DI::mstdnError(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [], ['extension' => 'json'])) ->run($this->httpExceptionMock); $result = $this->toJson($response); diff --git a/tests/src/Module/Api/Twitter/Statuses/DestroyTest.php b/tests/src/Module/Api/Twitter/Statuses/DestroyTest.php index b93cb327c..a08e2e5d8 100644 --- a/tests/src/Module/Api/Twitter/Statuses/DestroyTest.php +++ b/tests/src/Module/Api/Twitter/Statuses/DestroyTest.php @@ -45,7 +45,7 @@ class DestroyTest extends ApiTest { $this->expectException(BadRequestException::class); - (new Destroy(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [])) + (new Destroy(DI::mstdnError(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [])) ->run($this->httpExceptionMock); } @@ -71,7 +71,7 @@ class DestroyTest extends ApiTest */ public function testApiStatusesDestroyWithId() { - $response = (new Destroy(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [])) + $response = (new Destroy(DI::mstdnError(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [])) ->run($this->httpExceptionMock, [ 'id' => 1 ]); diff --git a/tests/src/Module/Api/Twitter/Statuses/MentionsTest.php b/tests/src/Module/Api/Twitter/Statuses/MentionsTest.php index 2e2f3cc0e..41a1fcd4c 100644 --- a/tests/src/Module/Api/Twitter/Statuses/MentionsTest.php +++ b/tests/src/Module/Api/Twitter/Statuses/MentionsTest.php @@ -36,7 +36,7 @@ class MentionsTest extends ApiTest */ public function testApiStatusesMentions() { - $response = (new Mentions(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [])) + $response = (new Mentions(DI::mstdnError(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [])) ->run($this->httpExceptionMock, [ 'max_id' => 10 ]); @@ -54,7 +54,7 @@ class MentionsTest extends ApiTest */ public function testApiStatusesMentionsWithNegativePage() { - $response = (new Mentions(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [])) + $response = (new Mentions(DI::mstdnError(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [])) ->run($this->httpExceptionMock, [ 'page' => -2 ]); @@ -86,7 +86,7 @@ class MentionsTest extends ApiTest */ public function testApiStatusesMentionsWithRss() { - $response = (new Mentions(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [], ['extension' => ICanCreateResponses::TYPE_RSS])) + $response = (new Mentions(DI::mstdnError(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [], ['extension' => ICanCreateResponses::TYPE_RSS])) ->run($this->httpExceptionMock, [ 'page' => -2 ]); diff --git a/tests/src/Module/Api/Twitter/Statuses/NetworkPublicTimelineTest.php b/tests/src/Module/Api/Twitter/Statuses/NetworkPublicTimelineTest.php index 8ae894552..7903ac481 100644 --- a/tests/src/Module/Api/Twitter/Statuses/NetworkPublicTimelineTest.php +++ b/tests/src/Module/Api/Twitter/Statuses/NetworkPublicTimelineTest.php @@ -36,7 +36,7 @@ class NetworkPublicTimelineTest extends ApiTest */ public function testApiStatusesNetworkpublicTimeline() { - $response = (new NetworkPublicTimeline(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [])) + $response = (new NetworkPublicTimeline(DI::mstdnError(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [])) ->run($this->httpExceptionMock, [ 'max_id' => 10 ]); @@ -58,7 +58,7 @@ class NetworkPublicTimelineTest extends ApiTest */ public function testApiStatusesNetworkpublicTimelineWithNegativePage() { - $response = (new NetworkPublicTimeline(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [])) + $response = (new NetworkPublicTimeline(DI::mstdnError(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [])) ->run($this->httpExceptionMock, [ 'page' => -2 ]); @@ -94,7 +94,7 @@ class NetworkPublicTimelineTest extends ApiTest */ public function testApiStatusesNetworkpublicTimelineWithRss() { - $response = (new NetworkPublicTimeline(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [], [ + $response = (new NetworkPublicTimeline(DI::mstdnError(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [], [ 'extension' => ICanCreateResponses::TYPE_RSS ]))->run($this->httpExceptionMock, [ 'page' => -2 diff --git a/tests/src/Module/Api/Twitter/Statuses/RetweetTest.php b/tests/src/Module/Api/Twitter/Statuses/RetweetTest.php index ead1e607d..3de93b096 100644 --- a/tests/src/Module/Api/Twitter/Statuses/RetweetTest.php +++ b/tests/src/Module/Api/Twitter/Statuses/RetweetTest.php @@ -45,7 +45,7 @@ class RetweetTest extends ApiTest { $this->expectException(BadRequestException::class); - (new Retweet(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [])) + (new Retweet(DI::mstdnError(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [])) ->run($this->httpExceptionMock); } @@ -71,7 +71,7 @@ class RetweetTest extends ApiTest */ public function testApiStatusesRepeatWithId() { - $response = (new Retweet(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [])) + $response = (new Retweet(DI::mstdnError(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [])) ->run($this->httpExceptionMock, [ 'id' => 1 ]); @@ -88,7 +88,7 @@ class RetweetTest extends ApiTest */ public function testApiStatusesRepeatWithSharedId() { - $response = (new Retweet(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [])) + $response = (new Retweet(DI::mstdnError(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [])) ->run($this->httpExceptionMock, [ 'id' => 5 ]); diff --git a/tests/src/Module/Api/Twitter/Statuses/ShowTest.php b/tests/src/Module/Api/Twitter/Statuses/ShowTest.php index 628859df2..a3ab3d30c 100644 --- a/tests/src/Module/Api/Twitter/Statuses/ShowTest.php +++ b/tests/src/Module/Api/Twitter/Statuses/ShowTest.php @@ -39,7 +39,7 @@ class ShowTest extends ApiTest $this->expectException(BadRequestException::class); - (new Show(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [])) + (new Show(DI::mstdnError(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [])) ->run($this->httpExceptionMock); } @@ -50,7 +50,7 @@ class ShowTest extends ApiTest */ public function testApiStatusesShowWithId() { - $response = (new Show(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [])) + $response = (new Show(DI::mstdnError(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [])) ->run($this->httpExceptionMock, [ 'id' => 1 ]); @@ -68,7 +68,7 @@ class ShowTest extends ApiTest */ public function testApiStatusesShowWithConversation() { - $response = (new Show(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [])) + $response = (new Show(DI::mstdnError(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [])) ->run($this->httpExceptionMock, [ 'id' => 1, 'conversation' => 1 diff --git a/tests/src/Module/Api/Twitter/Statuses/UpdateTest.php b/tests/src/Module/Api/Twitter/Statuses/UpdateTest.php index 206e61048..4f1cd37ed 100644 --- a/tests/src/Module/Api/Twitter/Statuses/UpdateTest.php +++ b/tests/src/Module/Api/Twitter/Statuses/UpdateTest.php @@ -54,7 +54,7 @@ class UpdateTest extends ApiTest ] ]; - $response = (new Update(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [])) + $response = (new Update(DI::mstdnError(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [])) ->run($this->httpExceptionMock, [ 'status' => 'Status content #friendica', 'in_reply_to_status_id' => 0, @@ -76,7 +76,7 @@ class UpdateTest extends ApiTest */ public function testApiStatusesUpdateWithHtml() { - $response = (new Update(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [])) + $response = (new Update(DI::mstdnError(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [])) ->run($this->httpExceptionMock, [ 'htmlstatus' => 'Status content', ]); diff --git a/tests/src/Module/Api/Twitter/Statuses/UserTimelineTest.php b/tests/src/Module/Api/Twitter/Statuses/UserTimelineTest.php index e9f40d030..77b51bb7e 100644 --- a/tests/src/Module/Api/Twitter/Statuses/UserTimelineTest.php +++ b/tests/src/Module/Api/Twitter/Statuses/UserTimelineTest.php @@ -36,7 +36,7 @@ class UserTimelineTest extends ApiTest */ public function testApiStatusesUserTimeline() { - $response = (new UserTimeline(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [])) + $response = (new UserTimeline(DI::mstdnError(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [])) ->run($this->httpExceptionMock, [ 'user_id' => 42, 'max_id' => 10, @@ -61,7 +61,7 @@ class UserTimelineTest extends ApiTest */ public function testApiStatusesUserTimelineWithNegativePage() { - $response = (new UserTimeline(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [])) + $response = (new UserTimeline(DI::mstdnError(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [])) ->run($this->httpExceptionMock, [ 'user_id' => 42, 'page' => -2, @@ -84,7 +84,7 @@ class UserTimelineTest extends ApiTest */ public function testApiStatusesUserTimelineWithRss() { - $response = (new UserTimeline(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [], [ + $response = (new UserTimeline(DI::mstdnError(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [], [ 'extension' => ICanCreateResponses::TYPE_RSS ]))->run($this->httpExceptionMock); diff --git a/tests/src/Module/Api/Twitter/Users/LookupTest.php b/tests/src/Module/Api/Twitter/Users/LookupTest.php index c4f8d8568..1228d2cbc 100644 --- a/tests/src/Module/Api/Twitter/Users/LookupTest.php +++ b/tests/src/Module/Api/Twitter/Users/LookupTest.php @@ -38,7 +38,7 @@ class LookupTest extends ApiTest { $this->expectException(NotFoundException::class); - (new Lookup(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [])) + (new Lookup(DI::mstdnError(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [])) ->run($this->httpExceptionMock); } @@ -49,7 +49,7 @@ class LookupTest extends ApiTest */ public function testApiUsersLookupWithUserId() { - $response = (new Lookup(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [])) + $response = (new Lookup(DI::mstdnError(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [])) ->run($this->httpExceptionMock, [ 'user_id' => static::OTHER_USER['id'] ]); diff --git a/tests/src/Module/Api/Twitter/Users/SearchTest.php b/tests/src/Module/Api/Twitter/Users/SearchTest.php index 921d2a434..71c4e1240 100644 --- a/tests/src/Module/Api/Twitter/Users/SearchTest.php +++ b/tests/src/Module/Api/Twitter/Users/SearchTest.php @@ -37,7 +37,7 @@ class SearchTest extends ApiTest */ public function testApiUsersSearch() { - $response = (new Search(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [])) + $response = (new Search(DI::mstdnError(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [])) ->run($this->httpExceptionMock, [ 'q' => static::OTHER_USER['name'] ]); @@ -54,7 +54,7 @@ class SearchTest extends ApiTest */ public function testApiUsersSearchWithXml() { - $response = (new Search(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [], [ + $response = (new Search(DI::mstdnError(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [], [ 'extension' => ICanCreateResponses::TYPE_XML ]))->run($this->httpExceptionMock, [ 'q' => static::OTHER_USER['name'] @@ -72,7 +72,7 @@ class SearchTest extends ApiTest { $this->expectException(BadRequestException::class); - (new Search(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [])) + (new Search(DI::mstdnError(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [])) ->run($this->httpExceptionMock); } } diff --git a/tests/src/Module/Api/Twitter/Users/ShowTest.php b/tests/src/Module/Api/Twitter/Users/ShowTest.php index 3fec80181..e7fc678a8 100644 --- a/tests/src/Module/Api/Twitter/Users/ShowTest.php +++ b/tests/src/Module/Api/Twitter/Users/ShowTest.php @@ -36,7 +36,7 @@ class ShowTest extends ApiTest */ public function testApiUsersShow() { - $response = (new Show(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [])) + $response = (new Show(DI::mstdnError(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [])) ->run($this->httpExceptionMock); $json = $this->toJson($response); @@ -56,7 +56,7 @@ class ShowTest extends ApiTest */ public function testApiUsersShowWithXml() { - $response = (new Show(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [], [ + $response = (new Show(DI::mstdnError(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [], [ 'extension' => ICanCreateResponses::TYPE_XML ]))->run($this->httpExceptionMock);