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 508f374fd1..04c7a405b4 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 7973c3b6e8..3653a97fdc 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 780060ca23..b08b374111 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 662107f98d..8a0a4d7ebe 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 208e3eb40e..1e40f752c1 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 0a7b5ee264..8e6d77ae56 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 bf968b638b..7096174786 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 5e7511c028..7469e1c63f 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 f43d995b61..a801880131 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 cc9193620a..2706aefe3c 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 a338d3ce70..1ff9c78339 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 1c07b4e474..7108263ba8 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 30be41be6b..d111f98cb2 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 6de21281d0..d1c713289d 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 322d02502c..05cc304886 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 4943d861a1..ed4650adc6 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 a249e4a81d..0e13ac9b25 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 aad152c3ac..11b85c51a3 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 154db631d6..6e12f5908c 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 be98f82654..17fd4636b9 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 c73f90aba6..d8bf657329 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 10e4c9db04..ee9d098da4 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 3dc0f00e74..e637a8e553 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 67128d99c1..d78f6e83f7 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 d8edfd1a3e..e0935c8ef2 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 8998dbdd95..ab38950aee 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 3bbe5bc7b3..3e40ecf6db 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 c6936dbe3c..c9e6f981d5 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 d43082c794..b44d14290c 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 04c7a405b4..dd83e6185a 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 aa9fc0dac8..eff8096858 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 edc1c5936b..57bfe15b86 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 b148c94e30..94d040aa17 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 a0986d8b0e..dd349205a4 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 f61d3451c9..896b719d73 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 c0c50dbe70..5699b15888 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 3653a97fdc..d9031a755d 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 b08b374111..771a35c2c0 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 8a0a4d7ebe..b8ba725141 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 1e40f752c1..d9441bd195 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 023d96797a..2058edff56 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 af294585ed..12de0df41b 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 8e6d77ae56..66cd56cf08 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 cba99b436b..2ea498c394 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 6aa2e8b66d..8e68421f42 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 01bfeba90c..5491bf1890 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 4ede1fd945..a646045e53 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 522b237b6c..b7dff6f8c7 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 c4afb74a3e..1ddafda569 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 52c0c2831f..c57b63cf66 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 ad290f5ab4..a666f2f91d 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 65c7ac42d0..e433943c8f 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 5da678d9d5..3b19e1eedc 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 ac2f2ab55e..97ec4ecbd1 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 d39f790810..4a494838b0 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 f08e481543..4169cb90fa 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 fc7e722478..24df3b3578 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 531fcadd18..4ae5b06690 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 a4936092ce..70b42494f4 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 35b5320129..8d8fb3e39c 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 c4bc172006..83676f25a2 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 a2cf908203..7708e1472b 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 170861461a..69c992c48d 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 d59549ae8b..2e6d64ff6e 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 8e05659474..10f6037e77 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 c21e1e438a..82e0016ef4 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 1495b76357..f4256f165d 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 dab072b307..fb4694055b 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 abffff9ede..71239a0ff1 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 e8b101634f..5bb7b3526c 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 56beb93be2..141099edd0 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 3af93d24cb..5a40574a47 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 78efa4819a..9947e8d482 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 9052290063..a327db727e 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 296009cc08..571927a168 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 2d202c34da..135701904e 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 2f0a6b6b74..eb19acf8eb 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 3fe8dfa3d8..b2424f0227 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 71c17cc511..177b618776 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 94247b80b6..ee3a253b3d 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 cb2604337c..1f843f0487 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 753c0ac5dc..50d1be27b5 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 d1f9d2d307..7a8eb11759 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 a801880131..a03d0250cc 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 2706aefe3c..324fe49d89 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 6ac9430c67..5204ab5563 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 e0f629527a..ec4527f00d 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 0369d2026c..749e0aa39f 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 ff34a8529f..f2e5ff40d4 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 da698c72f8..d8cf8054ee 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 56c352b34c..d282770dfd 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 c95f02e9b0..d9f95132c3 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 d0cf46b06d..6c368b019a 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 db997b0a3e..408df3aad5 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 3bda450e48..36902fb218 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 c41ed8d891..c6a924b2a4 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 3668cb9459..edf14925d0 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 fd23e3014b..0f5d44afac 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 3d1f7ea9a6..4f72eac25d 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 f18637b3d5..7c5d534496 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 474bbe0796..d636dd9126 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 ec27ea733c..a450b2248e 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 02847f1fd2..b4a1a7e73d 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 e326bc7a12..c1e7109709 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 e9985508c4..d92a87636f 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 fa4605128b..2834b63fc3 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 5b3e82508b..9bbafd587e 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 c58b8d24c8..2dfd2fb24d 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 f6ac2d1984..421963a48e 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 738c08e5a2..b6f608a83a 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 e08dcf40fb..d4798b2f3e 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 ec5d711200..51d682ec1b 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 1ff9c78339..948e4980e3 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 cfd43ed845..8df7516770 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 91157e9701..6b3e0a1d38 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 7108263ba8..06879a6590 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 798cceb410..b163ca29b6 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 d111f98cb2..f452560b67 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 2db0d48346..03f62406ba 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 771e0ef489..fbb0a9641e 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 86a3988046..28c4adcedc 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 e481f8a9f2..0c7f9acae0 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 21adc682b3..7b7104c700 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 b4064fc27b..48201134f3 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 e12d67aae5..4b4a0e1287 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 617d70e4db..216e299f35 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 05cc304886..2323c5003a 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 62c372fa28..47980608c1 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 6dd1c1d200..950cac488b 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 ed4650adc6..aa5f385e15 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 0e13ac9b25..d0277bcb76 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 8ebef3789f..dbb7e820b9 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 11b85c51a3..4cb7ba26af 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 6e12f5908c..4a7ada4b38 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 17fd4636b9..59292fa162 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 be79636372..68ac12f0c6 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 0ea93f87be..d7400e68bd 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 8a6e5ced82..7a0d6fdb1f 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 ec13f00dc0..9bf8ac2824 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 bde3ee678d..8d86e06149 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 d7caea65dd..22715a3717 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 18d56f1a17..aaacb9f065 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 1f4cbc1b44..6069bc96e4 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 49b9c986f9..511e4465b7 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 6640f880c6..e94632b655 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 67a0b31af5..4d37420a37 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 b3f0dd8a6f..064eac08a5 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 2c58fd6aff..361c8dba2f 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 960239f226..4c39ae92b8 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 2ca30afac7..6f26488e65 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 158c3f18dc..25e6012bff 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 d8bf657329..95eb8f0424 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 68172d6323..dec56ba90f 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 b53d846fcd..4bf5609b9a 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 5491bf1890..a0dcd7077d 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 bb78884837..fcae9990ce 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 a646045e53..f304fb9db9 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 bd215e3873..4ebd0d4bd3 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 e433943c8f..22b99ee4d6 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 3b19e1eedc..0fde1404e3 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 4a494838b0..f0187a2861 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 24df3b3578..52c76ab693 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 93b642cd69..599a2eff8a 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 83676f25a2..cfe3b3cb1e 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 71239a0ff1..c45144c98d 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 5bb7b3526c..86a5090e37 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 571927a168..9d9e6955b1 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 135701904e..ffa63caf44 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 b2424f0227..91c88ee181 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 177b618776..71b1949f57 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 ee3a253b3d..6045d24653 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 a03d0250cc..b91f8e7ba3 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 5204ab5563..f136c2708f 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 749e0aa39f..0940befbad 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 f2e5ff40d4..1ba0d6e040 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 3a73569f40..c171c0ccae 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 d8cf8054ee..384abc3d82 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 b6902a1c02..bce95610a9 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 d282770dfd..68491c8b70 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 d9f95132c3..99f097740f 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 6c368b019a..3e37a94a7d 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 ff0e1ba94e..9c508e42a9 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 36902fb218..4eccc97b2e 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 c6a924b2a4..ada587b2fe 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 edf14925d0..511ae15407 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 0f5d44afac..c11f89f6e0 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 4f72eac25d..c99011ae43 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 c1e7109709..730b639104 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 dec56ba90f..1dad4d9c8e 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 a0dcd7077d..99c8eb857a 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 fcae9990ce..3c13120873 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 f304fb9db9..5387f1b105 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 4ebd0d4bd3..6b88b84ef3 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 1ddafda569..1582f3299c 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 a666f2f91d..272b989ee4 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 22b99ee4d6..19f2a43883 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 0fde1404e3..061e22663d 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 f0187a2861..8fdcade664 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 4169cb90fa..ea8d0ce309 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 52c76ab693..72a7e0838d 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 4ae5b06690..f757151724 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 599a2eff8a..fd8fbcdab1 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 8d8fb3e39c..f2e2f2e411 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 cfe3b3cb1e..6a3c68cb32 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 7708e1472b..651233daed 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 d51a8e7b0a..9d6729216c 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 c45144c98d..532db4bcda 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 86a5090e37..2e876fcb5d 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 9d9e6955b1..beb1a3b9a6 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 ffa63caf44..f72f8cad82 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 eb19acf8eb..25b56d72ea 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 91c88ee181..738feab7c8 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 71b1949f57..6557b770b8 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 50d1be27b5..cc89479726 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 c43bdf510f..a5e4fb33a1 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 f136c2708f..cedafb8ab7 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 ec4527f00d..fb222beff2 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 0940befbad..def4d51f63 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 1ba0d6e040..cdbdcb6e6b 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 193bb7b0cd..ea5705186c 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 c171c0ccae..dbce15058c 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 384abc3d82..103de86790 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 bce95610a9..d91eff0b80 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 68491c8b70..0931cd733d 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 99f097740f..fbd2f00cee 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 3e37a94a7d..54ada1d1f9 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 9c508e42a9..eab40c665e 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 408df3aad5..1e72f33a02 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 4eccc97b2e..c64a6c8a77 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 ada587b2fe..78e9fb350f 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 511ae15407..e54380dbe5 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 c11f89f6e0..f04ff5306e 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 c99011ae43..50931cecd7 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 d636dd9126..d61ee88acf 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 a450b2248e..03844a7ddc 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 b4a1a7e73d..07b93d95a2 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 2834b63fc3..baed01e0ec 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 9bbafd587e..60bdab8373 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 ea91de5a04..e9ef07c62f 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 61a7f22889..ab9cd3ec26 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 1dad4d9c8e..6614100642 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 82e0016ef4..69d470306a 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 cde4c36c63..9791144348 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 ab9cd3ec26..0186f28519 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 6614100642..7d8e026767 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 95eb8f0424..b2d729f286 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 7d8e026767..4f7159b7ec 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 9d6729216c..5ebe3e2aba 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 beb1a3b9a6..3e66b9d51e 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 def4d51f63..5b6f8550aa 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 4f7159b7ec..4cf8159fd2 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 830b7fec38..20415e3fe7 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 99c8eb857a..c436c85469 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 3c13120873..f6470330d5 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 5387f1b105..ba53f902b2 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 6b88b84ef3..fcf443056d 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 1582f3299c..f6970336d5 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 272b989ee4..0f565d580c 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 19f2a43883..0ad6f9667c 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 061e22663d..bd88328603 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 8fdcade664..750ebd6810 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 ea8d0ce309..4602b18caa 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 72a7e0838d..9f36009319 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 f757151724..8c630d7239 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 fd8fbcdab1..b4e09b613e 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 f2e2f2e411..0d44c52d1d 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 6a3c68cb32..6a19267b3f 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 651233daed..689398d10f 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 5ebe3e2aba..012a2b1c27 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 69d470306a..42e8111e77 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 532db4bcda..1814922c79 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 2e876fcb5d..b78fdf8eda 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 3e66b9d51e..b9e52f159d 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 f72f8cad82..4db6846a27 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 25b56d72ea..4bd714c117 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 738feab7c8..1da6b3006b 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 6557b770b8..b87da7f7b1 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 6045d24653..b359113dc4 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 cc89479726..9771f1df6f 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 a5e4fb33a1..51d46c45ba 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 b91f8e7ba3..5624a1de49 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 cedafb8ab7..18b5c31c41 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 fb222beff2..75dc05e244 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 5b6f8550aa..dfd81c9d45 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 cdbdcb6e6b..35ebf28d73 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 ea5705186c..ef38f66a82 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 dbce15058c..6e35d717bf 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 103de86790..04e4c6256c 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 d91eff0b80..96c86dfb1a 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 0931cd733d..fc6b642b48 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 fbd2f00cee..b5c8f5c6e0 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 54ada1d1f9..cf35286b2c 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 eab40c665e..0c8376fd07 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 1e72f33a02..8810058d62 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 c64a6c8a77..594cde4223 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 78e9fb350f..631e18dda7 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 e54380dbe5..9fb05e8f69 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 f04ff5306e..626e18d75c 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 50931cecd7..2036bb1fb1 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 d61ee88acf..00cbac0d91 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 03844a7ddc..0fe6307ebc 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 07b93d95a2..31e2ade4ea 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 730b639104..356a4fa949 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 baed01e0ec..4331fc321c 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 60bdab8373..e08453327c 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 b2d729f286..7d21d7a8d4 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 e9ef07c62f..31db02b017 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 9791144348..a20482b221 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 0186f28519..7e22a88dab 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 c997984412..e17afb9be3 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 aaf7022024..06191e3d32 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 637ff95812..7e30095598 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 1cc255c365..7d483f1fd0 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 3812c7ffb7..4d8c7ff7fa 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 b6166fc400..db16070065 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 2b636565ae..11fa444efb 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 1b7934a196..452211bb0d 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 6afa44b835..06a3b8614b 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 960599e07a..2a4cc0e406 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 2e452e3d52..71817022dc 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 8a61ad88fd..2476315a07 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 6ed3e15dc3..c04097cd8b 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 f194d2a364..0dc9ba8e8f 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 509a65a7eb..d699fb7131 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 c73592261d..6aa9db5a44 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 d5df5e4adc..e0c9b070d5 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 7886c8cffd..a2355bca99 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 9ddffeef6f..74f64e65ea 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 8dd4435bcd..94c363abc9 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 c25cb86094..34c344f5fc 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 fdbfb55f25..e44c27005e 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 70b28557d3..0b2f4cd4ee 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 076edd4f67..0b8d069803 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 b393c3b7b9..8b6b9ed756 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 c830260d1c..7ab2bcc207 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 2e9ba9990e..c92d949ea3 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 b93cb327ca..a08e2e5d86 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 2e2f3cc0eb..41a1fcd4cc 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 8ae8945520..7903ac4819 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 ead1e607db..3de93b096e 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 628859df24..a3ab3d30cc 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 206e610487..4f1cd37ed3 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 e9f40d030d..77b51bb7e4 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 c4f8d8568f..1228d2cbc2 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 921d2a434a..71c4e1240d 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 3fec80181a..e7fc678a8d 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);