diff --git a/src/Content/Widget/Hovercard.php b/src/Content/Widget/Hovercard.php new file mode 100644 index 0000000000..aef8195656 --- /dev/null +++ b/src/Content/Widget/Hovercard.php @@ -0,0 +1,70 @@ +. + * + */ + +namespace Friendica\Content\Widget; + +use Friendica\Core\Renderer; +use Friendica\Database\DBA; +use Friendica\Model\Contact; +use Friendica\Network\HTTPException; +use Friendica\Util\Strings; + +class Hovercard +{ + /** + * @param array $contact + * @param int $localUid Used to show user actions + * @return string + * @throws HTTPException\InternalServerErrorException + * @throws HTTPException\ServiceUnavailableException + * @throws \ImagickException + */ + public static function getHTML(array $contact, int $localUid = 0): string + { + if ($localUid) { + $actions = Contact::photoMenu($contact, $localUid); + } else { + $actions = []; + } + + // Move the contact data to the profile array so we can deliver it to + $tpl = Renderer::getMarkupTemplate('hovercard.tpl'); + return Renderer::replaceMacros($tpl, [ + '$profile' => [ + 'name' => $contact['name'], + 'nick' => $contact['nick'], + 'addr' => $contact['addr'] ?: $contact['url'], + 'thumb' => Contact::getThumb($contact), + 'url' => Contact::magicLinkByContact($contact), + 'nurl' => $contact['nurl'], + 'location' => $contact['location'], + 'about' => $contact['about'], + 'network_link' => Strings::formatNetworkName($contact['network'], $contact['url']), + 'tags' => $contact['keywords'], + 'bd' => $contact['bd'] <= DBA::NULL_DATE ? '' : $contact['bd'], + 'account_type' => Contact::getAccountType($contact['contact-type']), + 'contact_type' => $contact['contact-type'], + 'actions' => $actions, + 'self' => $contact['self'], + ], + ]); + } +} diff --git a/src/Factory/Api/Mastodon/Error.php b/src/Factory/Api/Mastodon/Error.php index 68172d6323..4cf8159fd2 100644 --- a/src/Factory/Api/Mastodon/Error.php +++ b/src/Factory/Api/Mastodon/Error.php @@ -21,81 +21,53 @@ 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() + 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 = '') + 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 = '') + 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 = '') + 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 = '') + 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/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/Model/User.php b/src/Model/User.php index 79e2386381..f985dc2a67 100644 --- a/src/Model/User.php +++ b/src/Model/User.php @@ -37,11 +37,10 @@ use Friendica\Database\DBA; use Friendica\DI; use Friendica\Module; use Friendica\Network\HTTPClient\Client\HttpClientAccept; -use Friendica\Network\HTTPException\InternalServerErrorException; -use Friendica\Security\TwoFactor\Model\AppSpecificPassword; use Friendica\Network\HTTPException; use Friendica\Object\Image; use Friendica\Protocol\Delivery; +use Friendica\Security\TwoFactor\Model\AppSpecificPassword; use Friendica\Util\Crypto; use Friendica\Util\DateTimeFormat; use Friendica\Util\Images; @@ -1638,16 +1637,24 @@ class User * @param int $uid user to remove * @return bool * @throws HTTPException\InternalServerErrorException + * @throws HTTPException\NotFoundException */ public static function remove(int $uid): bool { if (empty($uid)) { - return false; + throw new \InvalidArgumentException('uid needs to be greater than 0'); } Logger::notice('Removing user', ['user' => $uid]); - $user = DBA::selectFirst('user', [], ['uid' => $uid]); + $user = self::getById($uid); + if (!$user) { + throw new HTTPException\NotFoundException('User not found with uid: ' . $uid); + } + + if (DBA::exists('user', ['parent-uid' => $uid])) { + throw new \RuntimeException(DI::l10n()->t("User with delegates can't be removed, please remove delegate users first")); + } Hook::callAll('remove_user', $user); 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 508f374fd1..dd83e6185a 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; @@ -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 7973c3b6e8..d9031a755d 100644 --- a/src/Module/Api/Friendica/Photo.php +++ b/src/Module/Api/Friendica/Photo.php @@ -37,16 +37,16 @@ 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; } 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 780060ca23..771a35c2c0 100644 --- a/src/Module/Api/Friendica/Photo/Create.php +++ b/src/Module/Api/Friendica/Photo/Create.php @@ -41,16 +41,16 @@ 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; } 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 662107f98d..b8ba725141 100644 --- a/src/Module/Api/Friendica/Photo/Lists.php +++ b/src/Module/Api/Friendica/Photo/Lists.php @@ -43,16 +43,16 @@ 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; } 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 208e3eb40e..d9441bd195 100644 --- a/src/Module/Api/Friendica/Photo/Update.php +++ b/src/Module/Api/Friendica/Photo/Update.php @@ -41,16 +41,16 @@ 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; } 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 0a7b5ee264..66cd56cf08 100644 --- a/src/Module/Api/Friendica/Photoalbum/Show.php +++ b/src/Module/Api/Friendica/Photoalbum/Show.php @@ -43,16 +43,16 @@ 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; } 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..c436c85469 100644 --- a/src/Module/Api/Friendica/Statuses/Dislike.php +++ b/src/Module/Api/Friendica/Statuses/Dislike.php @@ -35,16 +35,16 @@ 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'])) { - DI::mstdnError()->UnprocessableEntity(); + $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity()); } $item = Post::selectFirstForUser($uid, ['id'], ['uri-id' => $this->parameters['id'], 'uid' => [$uid, 0]]); if (!DBA::isResult($item)) { - DI::mstdnError()->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 bb78884837..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'])) { - DI::mstdnError()->UnprocessableEntity(); + $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity()); } $id = $this->parameters['id']; if (!Post::exists(['uri-id' => $id, 'uid' => [0, $uid]])) { - DI::mstdnError()->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 4ede1fd945..ba53f902b2 100644 --- a/src/Module/Api/Friendica/Statuses/Undislike.php +++ b/src/Module/Api/Friendica/Statuses/Undislike.php @@ -35,16 +35,16 @@ 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'])) { - DI::mstdnError()->UnprocessableEntity(); + $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity()); } $item = Post::selectFirstForUser($uid, ['id'], ['uri-id' => $this->parameters['id'], 'uid' => [$uid, 0]]); if (!DBA::isResult($item)) { - DI::mstdnError()->RecordNotFound(); + $this->logAndJsonError(404, $this->errorFactory->RecordNotFound()); } Item::performActivity($item['id'], 'undislike', $uid); 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.php b/src/Module/Api/Mastodon/Accounts.php index bd215e3873..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'])) { - DI::mstdnError()->UnprocessableEntity(); + $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity()); } if (!empty($this->parameters['id'])) { $id = $this->parameters['id']; if (!DBA::exists('contact', ['id' => $id, 'uid' => 0])) { - DI::mstdnError()->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))) { - DI::mstdnError()->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 c4afb74a3e..f6970336d5 100644 --- a/src/Module/Api/Mastodon/Accounts/Block.php +++ b/src/Module/Api/Mastodon/Accounts/Block.php @@ -34,11 +34,11 @@ 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'])) { - DI::mstdnError()->UnprocessableEntity(); + $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity()); } Contact\User::setBlocked($this->parameters['id'], $uid, true); 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..0f565d580c 100644 --- a/src/Module/Api/Mastodon/Accounts/Follow.php +++ b/src/Module/Api/Mastodon/Accounts/Follow.php @@ -33,11 +33,11 @@ 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'])) { - DI::mstdnError()->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 65c7ac42d0..0ad6f9667c 100644 --- a/src/Module/Api/Mastodon/Accounts/Followers.php +++ b/src/Module/Api/Mastodon/Accounts/Followers.php @@ -37,16 +37,16 @@ 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'])) { - DI::mstdnError()->UnprocessableEntity(); + $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity()); } $id = $this->parameters['id']; if (!DBA::exists('contact', ['id' => $id, 'uid' => 0])) { - DI::mstdnError()->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 5da678d9d5..bd88328603 100644 --- a/src/Module/Api/Mastodon/Accounts/Following.php +++ b/src/Module/Api/Mastodon/Accounts/Following.php @@ -37,16 +37,16 @@ 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'])) { - DI::mstdnError()->UnprocessableEntity(); + $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity()); } $id = $this->parameters['id']; if (!DBA::exists('contact', ['id' => $id, 'uid' => 0])) { - DI::mstdnError()->RecordNotFound(); + $this->logAndJsonError(404, $this->errorFactory->RecordNotFound()); } $request = $this->getRequest([ 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..750ebd6810 100644 --- a/src/Module/Api/Mastodon/Accounts/Lists.php +++ b/src/Module/Api/Mastodon/Accounts/Lists.php @@ -37,16 +37,16 @@ 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'])) { - DI::mstdnError()->UnprocessableEntity(); + $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity()); } $id = $this->parameters['id']; if (!DBA::exists('contact', ['id' => $id, 'uid' => 0])) { - DI::mstdnError()->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 f08e481543..4602b18caa 100644 --- a/src/Module/Api/Mastodon/Accounts/Mute.php +++ b/src/Module/Api/Mastodon/Accounts/Mute.php @@ -33,11 +33,11 @@ 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'])) { - DI::mstdnError()->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 fc7e722478..9f36009319 100644 --- a/src/Module/Api/Mastodon/Accounts/Note.php +++ b/src/Module/Api/Mastodon/Accounts/Note.php @@ -34,11 +34,11 @@ 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'])) { - DI::mstdnError()->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'])) { - DI::mstdnError()->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 531fcadd18..8c630d7239 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([ @@ -44,7 +44,7 @@ class Relationships extends BaseApi ], $request); if (empty($request['id'])) { - DI::mstdnError()->UnprocessableEntity(); + $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity()); } if (!is_array($request['id'])) { 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/Statuses.php b/src/Module/Api/Mastodon/Accounts/Statuses.php index 93b642cd69..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'])) { - DI::mstdnError()->UnprocessableEntity(); + $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity()); } $id = $this->parameters['id']; if (!DBA::exists('contact', ['id' => $id, 'uid' => 0])) { - DI::mstdnError()->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 35b5320129..0d44c52d1d 100644 --- a/src/Module/Api/Mastodon/Accounts/Unblock.php +++ b/src/Module/Api/Mastodon/Accounts/Unblock.php @@ -33,11 +33,11 @@ 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'])) { - DI::mstdnError()->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 c4bc172006..6a19267b3f 100644 --- a/src/Module/Api/Mastodon/Accounts/Unfollow.php +++ b/src/Module/Api/Mastodon/Accounts/Unfollow.php @@ -33,16 +33,16 @@ 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'])) { - DI::mstdnError()->UnprocessableEntity(); + $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity()); } $cdata = Contact::getPublicAndUserContactID($this->parameters['id'], $uid); if (empty($cdata['user'])) { - DI::mstdnError()->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 a2cf908203..689398d10f 100644 --- a/src/Module/Api/Mastodon/Accounts/Unmute.php +++ b/src/Module/Api/Mastodon/Accounts/Unmute.php @@ -33,11 +33,11 @@ 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'])) { - DI::mstdnError()->UnprocessableEntity(); + $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity()); } Contact\User::setIgnored($this->parameters['id'], $uid, false); 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.php b/src/Module/Api/Mastodon/Apps.php index d51a8e7b0a..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'])) { - DI::mstdnError()->UnprocessableEntity(DI::l10n()->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)) { - DI::mstdnError()->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 c21e1e438a..42e8111e77 100644 --- a/src/Module/Api/Mastodon/Apps/VerifyCredentials.php +++ b/src/Module/Api/Mastodon/Apps/VerifyCredentials.php @@ -32,11 +32,11 @@ 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'])) { - DI::mstdnError()->Unauthorized(); + $this->logAndJsonError(401, $this->errorFactory->Unauthorized()); } $this->jsonExit(DI::mstdnApplication()->createFromApplicationId($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..1814922c79 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/ @@ -33,11 +34,11 @@ 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'])) { - DI::mstdnError()->UnprocessableEntity(); + $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity()); } DBA::delete('conv', ['id' => $this->parameters['id'], 'uid' => $uid]); @@ -51,7 +52,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([ @@ -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->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 e8b101634f..b78fdf8eda 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/ @@ -33,15 +34,19 @@ 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'])) { - DI::mstdnError()->UnprocessableEntity(); + $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity()); } 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->logAndJsonError(404, $this->errorFactory->RecordNotFound()); + } } } 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/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/Lists.php b/src/Module/Api/Mastodon/Lists.php index 296009cc08..b9e52f159d 100644 --- a/src/Module/Api/Mastodon/Lists.php +++ b/src/Module/Api/Mastodon/Lists.php @@ -33,19 +33,19 @@ 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'])) { - DI::mstdnError()->UnprocessableEntity(); + $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity()); } if (!Circle::exists($this->parameters['id'], $uid)) { - DI::mstdnError()->RecordNotFound(); + $this->logAndJsonError(404, $this->errorFactory->RecordNotFound()); } if (!Circle::remove($this->parameters['id'])) { - DI::mstdnError()->InternalError(); + $this->logAndJsonError(500, $this->errorFactory->InternalError()); } $this->jsonExit([]); @@ -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([ @@ -61,14 +61,14 @@ class Lists extends BaseApi ], $request); if (empty($request['title'])) { - DI::mstdnError()->UnprocessableEntity(); + $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity()); } Circle::create($uid, $request['title']); $id = Circle::getIdByName($uid, $request['title']); if (!$id) { - DI::mstdnError()->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'])) { - DI::mstdnError()->UnprocessableEntity(); + $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity()); } Circle::update($this->parameters['id'], $request['title']); @@ -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'])) { @@ -106,7 +106,7 @@ class Lists extends BaseApi $id = $this->parameters['id']; if (!Circle::exists($id, $uid)) { - DI::mstdnError()->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 2d202c34da..4db6846a27 100644 --- a/src/Module/Api/Mastodon/Lists/Accounts.php +++ b/src/Module/Api/Mastodon/Lists/Accounts.php @@ -36,14 +36,14 @@ 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 ], $request); if (empty($request['account_ids']) || empty($this->parameters['id'])) { - DI::mstdnError()->UnprocessableEntity(); + $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity()); } return Circle::removeMembers($this->parameters['id'], $request['account_ids']); @@ -51,14 +51,14 @@ 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 ], $request); if (empty($request['account_ids']) || empty($this->parameters['id'])) { - DI::mstdnError()->UnprocessableEntity(); + $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity()); } Circle::addMembers($this->parameters['id'], $request['account_ids']); @@ -69,16 +69,16 @@ 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'])) { - DI::mstdnError()->UnprocessableEntity(); + $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity()); } $id = $this->parameters['id']; if (!DBA::exists('group', ['id' => $id, 'uid' => $uid])) { - DI::mstdnError()->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 2f0a6b6b74..4bd714c117 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(); @@ -48,7 +48,7 @@ class Markers extends BaseApi } if (empty($timeline) || empty($last_read_id) || empty($application['id'])) { - DI::mstdnError()->UnprocessableEntity(); + $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity()); } $condition = ['application-id' => $application['id'], 'uid' => $uid, 'timeline' => $timeline]; @@ -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..1da6b3006b 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([ @@ -48,12 +48,12 @@ class Media extends BaseApi Logger::info('Photo post', ['request' => $request, 'files' => $_FILES]); if (empty($_FILES['file'])) { - DI::mstdnError()->UnprocessableEntity(); + $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity()); } $media = Photo::upload($uid, $_FILES['file'], '', null, null, '', '', $request['description']); if (empty($media)) { - DI::mstdnError()->UnprocessableEntity(); + $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity()); } Logger::info('Uploaded photo', ['media' => $media]); @@ -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([ @@ -74,17 +74,17 @@ class Media extends BaseApi ], $request); if (empty($this->parameters['id'])) { - DI::mstdnError()->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'])) { - DI::mstdnError()->RecordNotFound(); + $this->logAndJsonError(404, $this->errorFactory->RecordNotFound()); } if (!Post::exists(['uri-id' => $media['uri-id'], 'uid' => $uid, 'origin' => true])) { - DI::mstdnError()->RecordNotFound(); + $this->logAndJsonError(404, $this->errorFactory->RecordNotFound()); } Post\Media::updateById(['description' => $request['description']], $this->parameters['id']); $this->jsonExit(DI::mstdnAttachment()->createFromId($this->parameters['id'])); @@ -100,16 +100,16 @@ 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'])) { - DI::mstdnError()->UnprocessableEntity(); + $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity()); } $id = $this->parameters['id']; if (!Photo::exists(['id' => $id, 'uid' => $uid])) { - DI::mstdnError()->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 71c17cc511..b87da7f7b1 100644 --- a/src/Module/Api/Mastodon/Mutes.php +++ b/src/Module/Api/Mastodon/Mutes.php @@ -36,16 +36,16 @@ 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'])) { - DI::mstdnError()->UnprocessableEntity(); + $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity()); } $id = $this->parameters['id']; if (!DBA::exists('contact', ['id' => $id, 'uid' => 0])) { - DI::mstdnError()->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 94247b80b6..b359113dc4 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'])) { @@ -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->logAndJsonError(404, $this->errorFactory->RecordNotFound()); } } 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..9771f1df6f 100644 --- a/src/Module/Api/Mastodon/Notifications/Dismiss.php +++ b/src/Module/Api/Mastodon/Notifications/Dismiss.php @@ -34,11 +34,11 @@ 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'])) { - DI::mstdnError()->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 c43bdf510f..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'])) { - DI::mstdnError()->UnprocessableEntity(); + $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity()); } $this->jsonExit(DI::mstdnPoll()->createFromId($this->parameters['id'], $uid)); 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 f43d995b61..5624a1de49 100644 --- a/src/Module/Api/Mastodon/PushSubscription.php +++ b/src/Module/Api/Mastodon/PushSubscription.php @@ -39,20 +39,17 @@ 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 { - self::checkAllowedScope(self::SCOPE_PUSH); + $this->checkAllowedScope(self::SCOPE_PUSH); $uid = self::getCurrentUserID(); $application = self::getCurrentApplication(); @@ -86,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(); @@ -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->logAndJsonError(404, $this->errorFactory->RecordNotFound()); } $fields = [ @@ -125,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(); @@ -142,13 +139,13 @@ 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(); if (!Subscription::exists($application['id'], $uid)) { $this->logger->info('Subscription not found', ['application-id' => $application['id'], 'uid' => $uid]); - $this->errorFac->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/Reports.php b/src/Module/Api/Mastodon/Reports.php index cc9193620a..324fe49d89 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; @@ -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..18b5c31c41 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,15 +43,15 @@ 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'])) { - DI::mstdnError()->UnprocessableEntity(); + $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity()); } if (!DBA::exists('delayed-post', ['id' => $this->parameters['id'], 'uid' => $uid])) { - DI::mstdnError()->RecordNotFound(); + $this->logAndJsonError(404, $this->errorFactory->RecordNotFound()); } Post\Delayed::deleteById($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..75dc05e244 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([ @@ -60,7 +60,7 @@ class Search extends BaseApi ], $request); if (empty($request['q'])) { - DI::mstdnError()->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 0369d2026c..dfd81c9d45 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([ @@ -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->logAndJsonError(500, $this->errorFactory->InternalError()); } $this->jsonExit(DI::mstdnScheduledStatus()->createFromDelayedPostId($id, $uid)->toArray()); } @@ -310,25 +310,25 @@ class Statuses extends BaseApi } } - DI::mstdnError()->InternalError(); + $this->logAndJsonError(500, $this->errorFactory->InternalError()); } protected function delete(array $request = []) { - self::checkAllowedScope(self::SCOPE_READ); + $this->checkAllowedScope(self::SCOPE_READ); $uid = self::getCurrentUserID(); if (empty($this->parameters['id'])) { - DI::mstdnError()->UnprocessableEntity(); + $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity()); } $item = Post::selectFirstForUser($uid, ['id'], ['uri-id' => $this->parameters['id'], 'uid' => $uid]); if (empty($item['id'])) { - DI::mstdnError()->RecordNotFound(); + $this->logAndJsonError(404, $this->errorFactory->RecordNotFound()); } if (!Item::markForDeletionById($item['id'])) { - DI::mstdnError()->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'])) { - DI::mstdnError()->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 ff34a8529f..35ebf28d73 100644 --- a/src/Module/Api/Mastodon/Statuses/Bookmark.php +++ b/src/Module/Api/Mastodon/Statuses/Bookmark.php @@ -35,20 +35,20 @@ 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'])) { - DI::mstdnError()->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)) { - DI::mstdnError()->RecordNotFound(); + $this->logAndJsonError(404, $this->errorFactory->RecordNotFound()); } if ($item['gravity'] != Item::GRAVITY_PARENT) { - DI::mstdnError()->UnprocessableEntity(DI::l10n()->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)) { - DI::mstdnError()->RecordNotFound(); + $this->logAndJsonError(404, $this->errorFactory->RecordNotFound()); } } else { - DI::mstdnError()->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 193bb7b0cd..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'])) { - DI::mstdnError()->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 3a73569f40..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'])) { - DI::mstdnError()->UnprocessableEntity(); + $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity()); } $request = $this->getRequest([ @@ -116,7 +116,7 @@ class Context extends BaseApi } DBA::close($posts); } else { - DI::mstdnError()->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 da698c72f8..04e4c6256c 100644 --- a/src/Module/Api/Mastodon/Statuses/Favourite.php +++ b/src/Module/Api/Mastodon/Statuses/Favourite.php @@ -35,16 +35,16 @@ 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'])) { - DI::mstdnError()->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)) { - DI::mstdnError()->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 b6902a1c02..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'])) { - DI::mstdnError()->UnprocessableEntity(); + $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity()); } if (!$post = Post::selectOriginal(['uri-id'], ['uri-id' => $this->parameters['id'], 'uid' => [0, $uid]])) { - DI::mstdnError()->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 56c352b34c..fc6b642b48 100644 --- a/src/Module/Api/Mastodon/Statuses/Mute.php +++ b/src/Module/Api/Mastodon/Statuses/Mute.php @@ -35,20 +35,20 @@ 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'])) { - DI::mstdnError()->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)) { - DI::mstdnError()->RecordNotFound(); + $this->logAndJsonError(404, $this->errorFactory->RecordNotFound()); } if ($item['gravity'] != Item::GRAVITY_PARENT) { - DI::mstdnError()->UnprocessableEntity(DI::l10n()->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 c95f02e9b0..b5c8f5c6e0 100644 --- a/src/Module/Api/Mastodon/Statuses/Pin.php +++ b/src/Module/Api/Mastodon/Statuses/Pin.php @@ -34,16 +34,16 @@ 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'])) { - DI::mstdnError()->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)) { - DI::mstdnError()->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 d0cf46b06d..cf35286b2c 100644 --- a/src/Module/Api/Mastodon/Statuses/Reblog.php +++ b/src/Module/Api/Mastodon/Statuses/Reblog.php @@ -38,22 +38,25 @@ 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'])) { - DI::mstdnError()->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)) { - DI::mstdnError()->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])) { - DI::mstdnError()->UnprocessableEntity(DI::l10n()->t("Posts from %s can't be shared", ContactSelector::networkToName($item['network']))); + $this->logAndJsonError( + 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 ff0e1ba94e..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'])) { - DI::mstdnError()->UnprocessableEntity(); + $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity()); } if (!$post = Post::selectOriginal(['uri-id'], ['uri-id' => $this->parameters['id'], 'uid' => [0, $uid]])) { - DI::mstdnError()->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 db997b0a3e..8810058d62 100644 --- a/src/Module/Api/Mastodon/Statuses/Source.php +++ b/src/Module/Api/Mastodon/Statuses/Source.php @@ -37,11 +37,11 @@ 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'])) { - DI::mstdnError()->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 3bda450e48..594cde4223 100644 --- a/src/Module/Api/Mastodon/Statuses/Unbookmark.php +++ b/src/Module/Api/Mastodon/Statuses/Unbookmark.php @@ -35,20 +35,20 @@ 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'])) { - DI::mstdnError()->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)) { - DI::mstdnError()->RecordNotFound(); + $this->logAndJsonError(404, $this->errorFactory->RecordNotFound()); } if ($item['gravity'] != Item::GRAVITY_PARENT) { - DI::mstdnError()->UnprocessableEntity(DI::l10n()->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)) { - DI::mstdnError()->RecordNotFound(); + $this->logAndJsonError(404, $this->errorFactory->RecordNotFound()); } } else { - DI::mstdnError()->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 c41ed8d891..631e18dda7 100644 --- a/src/Module/Api/Mastodon/Statuses/Unfavourite.php +++ b/src/Module/Api/Mastodon/Statuses/Unfavourite.php @@ -35,16 +35,16 @@ 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'])) { - DI::mstdnError()->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)) { - DI::mstdnError()->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 3668cb9459..9fb05e8f69 100644 --- a/src/Module/Api/Mastodon/Statuses/Unmute.php +++ b/src/Module/Api/Mastodon/Statuses/Unmute.php @@ -35,20 +35,20 @@ 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'])) { - DI::mstdnError()->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)) { - DI::mstdnError()->RecordNotFound(); + $this->logAndJsonError(404, $this->errorFactory->RecordNotFound()); } if ($item['gravity'] != Item::GRAVITY_PARENT) { - DI::mstdnError()->UnprocessableEntity(DI::l10n()->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 fd23e3014b..626e18d75c 100644 --- a/src/Module/Api/Mastodon/Statuses/Unpin.php +++ b/src/Module/Api/Mastodon/Statuses/Unpin.php @@ -34,16 +34,16 @@ 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'])) { - DI::mstdnError()->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)) { - DI::mstdnError()->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 3d1f7ea9a6..2036bb1fb1 100644 --- a/src/Module/Api/Mastodon/Statuses/Unreblog.php +++ b/src/Module/Api/Mastodon/Statuses/Unreblog.php @@ -37,29 +37,32 @@ 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'])) { - DI::mstdnError()->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)) { - DI::mstdnError()->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'])) { - DI::mstdnError()->RecordNotFound(); + $this->logAndJsonError(404, $this->errorFactory->RecordNotFound()); } if (!Item::markForDeletionById($item['id'])) { - DI::mstdnError()->RecordNotFound(); + $this->logAndJsonError(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->logAndJsonError( + 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/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..00cbac0d91 100644 --- a/src/Module/Api/Mastodon/Tags.php +++ b/src/Module/Api/Mastodon/Tags.php @@ -36,11 +36,11 @@ 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'])) { - DI::mstdnError()->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 ec27ea733c..0fe6307ebc 100644 --- a/src/Module/Api/Mastodon/Tags/Follow.php +++ b/src/Module/Api/Mastodon/Tags/Follow.php @@ -33,11 +33,11 @@ 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'])) { - DI::mstdnError()->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 02847f1fd2..31e2ade4ea 100644 --- a/src/Module/Api/Mastodon/Tags/Unfollow.php +++ b/src/Module/Api/Mastodon/Tags/Unfollow.php @@ -33,11 +33,11 @@ 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'])) { - DI::mstdnError()->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 e326bc7a12..356a4fa949 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/ @@ -37,7 +38,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([ @@ -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->logAndJsonError(404, $this->errorFactory->RecordNotFound()); } if (!empty($request['min_id'])) { 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..4331fc321c 100644 --- a/src/Module/Api/Mastodon/Timelines/ListTimeline.php +++ b/src/Module/Api/Mastodon/Timelines/ListTimeline.php @@ -41,11 +41,11 @@ 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'])) { - DI::mstdnError()->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 5b3e82508b..e08453327c 100644 --- a/src/Module/Api/Mastodon/Timelines/Tag.php +++ b/src/Module/Api/Mastodon/Timelines/Tag.php @@ -41,11 +41,11 @@ 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'])) { - DI::mstdnError()->UnprocessableEntity(); + $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity()); } /** 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 a338d3ce70..948e4980e3 100644 --- a/src/Module/Api/Twitter/ContactEndpoint.php +++ b/src/Module/Api/Twitter/ContactEndpoint.php @@ -38,11 +38,11 @@ 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); + $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 1c07b4e474..06879a6590 100644 --- a/src/Module/Api/Twitter/DirectMessages/Destroy.php +++ b/src/Module/Api/Twitter/DirectMessages/Destroy.php @@ -41,15 +41,15 @@ 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; } 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 30be41be6b..f452560b67 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; @@ -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/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/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 322d02502c..2323c5003a 100644 --- a/src/Module/Api/Twitter/Friendships/Destroy.php +++ b/src/Module/Api/Twitter/Friendships/Destroy.php @@ -45,16 +45,16 @@ 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; } 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 4943d861a1..aa5f385e15 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; @@ -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 a249e4a81d..d0277bcb76 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; @@ -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 aad152c3ac..4cb7ba26af 100644 --- a/src/Module/Api/Twitter/Lists/Ownership.php +++ b/src/Module/Api/Twitter/Lists/Ownership.php @@ -44,16 +44,16 @@ 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; } 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 154db631d6..4a7ada4b38 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; @@ -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 be98f82654..59292fa162 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; @@ -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 c73f90aba6..7d21d7a8d4 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; } /** @@ -93,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.')); @@ -414,23 +418,23 @@ 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'); - DI::mstdnError()->Forbidden(); + $this->logger->notice('Empty application token'); + $this->logAndJsonError(403, $this->errorFactory->Forbidden()); } if (!isset($token[$scope])) { - Logger::warning('The requested scope does not exist', ['scope' => $scope, 'application' => $token]); - DI::mstdnError()->Forbidden(); + $this->logger->warning('The requested scope does not exist', ['scope' => $scope, 'application' => $token]); + $this->logAndJsonError(403, $this->errorFactory->Forbidden()); } if (empty($token[$scope])) { - Logger::warning('The requested scope is not allowed', ['scope' => $scope, 'application' => $token]); - DI::mstdnError()->Forbidden(); + $this->logger->warning('The requested scope is not allowed', ['scope' => $scope, 'application' => $token]); + $this->logAndJsonError(403, $this->errorFactory->Forbidden()); } } @@ -515,4 +519,16 @@ class BaseApi extends BaseModule return null; } + + /** + * @param int $errorno + * @param Error $error + * @return void + * @throws HTTPException\InternalServerErrorException + */ + 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/Contact/Hovercard.php b/src/Module/Contact/Hovercard.php index 792a3d6bbc..cea5c4b968 100644 --- a/src/Module/Contact/Hovercard.php +++ b/src/Module/Contact/Hovercard.php @@ -23,17 +23,15 @@ namespace Friendica\Module\Contact; use Friendica\App; use Friendica\BaseModule; +use Friendica\Content\Widget; use Friendica\Core\Config\Capability\IManageConfigValues; use Friendica\Core\L10n; -use Friendica\Core\Renderer; use Friendica\Core\Session\Capability\IHandleUserSessions; use Friendica\Core\System; -use Friendica\Database\DBA; use Friendica\Model\Contact; use Friendica\Module\Response; use Friendica\Network\HTTPException; use Friendica\Util\Profiler; -use Friendica\Util\Strings; use Psr\Log\LoggerInterface; /** @@ -88,35 +86,6 @@ class Hovercard extends BaseModule throw new HTTPException\NotFoundException(); } - // Get the photo_menu - the menu if possible contact actions - if ($this->userSession->isAuthenticated()) { - $actions = Contact::photoMenu($contact, $this->userSession->getLocalUserId()); - } else { - $actions = []; - } - - // Move the contact data to the profile array so we can deliver it to - $tpl = Renderer::getMarkupTemplate('hovercard.tpl'); - $o = Renderer::replaceMacros($tpl, [ - '$profile' => [ - 'name' => $contact['name'], - 'nick' => $contact['nick'], - 'addr' => $contact['addr'] ?: $contact['url'], - 'thumb' => Contact::getThumb($contact), - 'url' => Contact::magicLinkByContact($contact), - 'nurl' => $contact['nurl'], - 'location' => $contact['location'], - 'about' => $contact['about'], - 'network_link' => Strings::formatNetworkName($contact['network'], $contact['url']), - 'tags' => $contact['keywords'], - 'bd' => $contact['bd'] <= DBA::NULL_DATE ? '' : $contact['bd'], - 'account_type' => Contact::getAccountType($contact['contact-type']), - 'contact_type' => $contact['contact-type'], - 'actions' => $actions, - 'self' => $contact['self'], - ], - ]); - - $this->httpExit($o); + $this->httpExit(Widget\Hovercard::getHTML($contact, $this->userSession->getLocalUserId())); } } diff --git a/src/Module/Delegation.php b/src/Module/Delegation.php deleted file mode 100644 index 8a2b313000..0000000000 --- a/src/Module/Delegation.php +++ /dev/null @@ -1,152 +0,0 @@ -. - * - */ - -namespace Friendica\Module; - -use Friendica\BaseModule; -use Friendica\Core\Hook; -use Friendica\Core\Renderer; -use Friendica\Database\DBA; -use Friendica\DI; -use Friendica\Model\Notification; -use Friendica\Model\User; -use Friendica\Network\HTTPException\ForbiddenException; -use Friendica\Util\Proxy; - -/** - * Switches current user between delegates/parent user - */ -class Delegation extends BaseModule -{ - protected function post(array $request = []) - { - if (!DI::userSession()->getLocalUserId()) { - return; - } - - $uid = DI::userSession()->getLocalUserId(); - $orig_record = User::getById(DI::app()->getLoggedInUserId()); - - if (DI::userSession()->getSubManagedUserId()) { - $user = User::getById(DI::userSession()->getSubManagedUserId()); - if (DBA::isResult($user)) { - $uid = intval($user['uid']); - $orig_record = $user; - } - } - - $identity = intval($request['identity'] ?? 0); - if (!$identity) { - return; - } - - $limited_id = 0; - $original_id = $uid; - - $manages = DBA::selectToArray('manage', ['mid'], ['uid' => $uid]); - foreach ($manages as $manage) { - if ($identity == $manage['mid']) { - $limited_id = $manage['mid']; - break; - } - } - - if ($limited_id) { - $user = User::getById($limited_id); - } else { - // Check if the target user is one of our children - $user = DBA::selectFirst('user', [], ['uid' => $identity, 'parent-uid' => $orig_record['uid']]); - - // Check if the target user is one of our siblings - if (!DBA::isResult($user) && $orig_record['parent-uid']) { - $user = DBA::selectFirst('user', [], ['uid' => $identity, 'parent-uid' => $orig_record['parent-uid']]); - } - - // Check if it's our parent or our own user - if (!DBA::isResult($user) - && ( - $orig_record['parent-uid'] && $orig_record['parent-uid'] === $identity - || - $orig_record['uid'] && $orig_record['uid'] === $identity - ) - ) { - $user = User::getById($identity); - } - } - - if (!DBA::isResult($user)) { - return; - } - - DI::session()->clear(); - - DI::auth()->setForUser(DI::app(), $user, true, true); - - if ($limited_id) { - DI::userSession()->setSubManagedUserId($original_id); - } - - $ret = []; - Hook::callAll('home_init', $ret); - - DI::sysmsg()->addNotice($this->t('You are now logged in as %s', $user['username'])); - - DI::baseUrl()->redirect('network'); - } - - protected function content(array $request = []): string - { - if (!DI::userSession()->getLocalUserId()) { - throw new ForbiddenException(DI::l10n()->t('Permission denied.')); - } - - $identities = User::identities(DI::userSession()->getSubManagedUserId() ?: DI::userSession()->getLocalUserId()); - - //getting additional information for each identity - foreach ($identities as $key => $identity) { - $identities[$key]['thumb'] = User::getAvatarUrl($identity, Proxy::SIZE_THUMB); - - $identities[$key]['selected'] = ($identity['nickname'] === DI::app()->getLoggedInUserNickname()); - - $condition = ["`msg` != '' AND NOT (`type` IN (?, ?)) AND NOT `seen`", Notification\Type::INTRO, Notification\Type::MAIL]; - $params = ['distinct' => true, 'expression' => 'parent']; - $notifications = DI::notify()->countForUser($identity['uid'], $condition, $params); - - $params = ['distinct' => true, 'expression' => 'convid']; - $notifications += DBA::count('mail', ['uid' => $identity['uid'], 'seen' => false], $params); - - $notifications += DI::intro()->countActiveForUser($identity['uid']); - - $identities[$key]['notifications'] = $notifications; - } - - $o = Renderer::replaceMacros(Renderer::getMarkupTemplate('delegation.tpl'), [ - '$title' => DI::l10n()->t('Switch between your accounts'), - '$settings_label' => DI::l10n()->t('Manage your accounts'), - '$desc' => DI::l10n()->t('Toggle between different identities or community/group pages which share your account details or which you have been granted "manage" permissions'), - '$choose' => DI::l10n()->t('Select an identity to manage: '), - '$identities' => $identities, - '$submit' => DI::l10n()->t('Submit'), - ]); - - return $o; - } -} diff --git a/src/Module/OAuth/Authorize.php b/src/Module/OAuth/Authorize.php index ea91de5a04..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]); - DI::mstdnError()->UnprocessableEntity(DI::l10n()->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]); - DI::mstdnError()->UnprocessableEntity(DI::l10n()->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)) { - DI::mstdnError()->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) { - DI::mstdnError()->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 cde4c36c63..a20482b221 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->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 61a7f22889..7e22a88dab 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->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)) { - DI::mstdnError()->Unauthorized('invalid_client', DI::l10n()->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') { @@ -98,14 +98,14 @@ 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->logAndJsonError(401, $this->errorFactory->Unauthorized()); } $owner = User::getOwnerDataById($token['uid']); $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->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); diff --git a/src/Module/Settings/Delegation.php b/src/Module/Settings/Delegation.php index 3fd5fef49f..e122dc62d5 100644 --- a/src/Module/Settings/Delegation.php +++ b/src/Module/Settings/Delegation.php @@ -21,29 +21,48 @@ namespace Friendica\Module\Settings; +use Friendica\App; use Friendica\BaseModule; +use Friendica\Core\L10n; use Friendica\Core\Renderer; -use Friendica\Database\DBA; -use Friendica\DI; +use Friendica\Core\Session\Capability\IHandleUserSessions; +use Friendica\Database\Database; use Friendica\Model\User; use Friendica\Module\BaseSettings; +use Friendica\Module\Response; +use Friendica\Navigation\SystemMessages; use Friendica\Network\HTTPException; +use Friendica\Util\Profiler; use Friendica\Util\Strings; +use Psr\Log\LoggerInterface; /** * Account delegation settings module */ class Delegation extends BaseSettings { + /** @var SystemMessages */ + private $systemMessages; + /** @var Database */ + private $db; + + public function __construct(Database $db, SystemMessages $systemMessages, IHandleUserSessions $session, App\Page $page, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, array $server, array $parameters = []) + { + parent::__construct($session, $page, $l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters); + + $this->systemMessages = $systemMessages; + $this->db = $db; + } + protected function post(array $request = []) { - if (!DI::app()->isLoggedIn()) { - throw new HTTPException\ForbiddenException(DI::l10n()->t('Permission denied.')); + if (!$this->session->isAuthenticated()) { + return; } BaseModule::checkFormSecurityTokenRedirectOnError('settings/delegation', 'delegate'); - $parent_uid = $request['parent_user'] ?? null; + $parent_uid = $request['parent_user'] ?? null; $parent_password = $request['parent_password'] ?? ''; if ($parent_uid) { @@ -51,66 +70,63 @@ class Delegation extends BaseSettings // An integer value will trigger the direct user query on uid in User::getAuthenticationInfo $parent_uid = (int)$parent_uid; User::getIdFromPasswordAuthentication($parent_uid, $parent_password); - DI::sysmsg()->addInfo(DI::l10n()->t('Delegation successfully granted.')); + $this->systemMessages->addInfo($this->t('Delegation successfully granted.')); } catch (\Exception $ex) { - DI::sysmsg()->addNotice(DI::l10n()->t('Parent user not found, unavailable or password doesn\'t match.')); + $this->systemMessages->addNotice($this->t('Parent user not found, unavailable or password doesn\'t match.')); return; } } else { - DI::sysmsg()->addInfo(DI::l10n()->t('Delegation successfully revoked.')); + $this->systemMessages->addInfo($this->t('Delegation successfully revoked.')); } - DBA::update('user', ['parent-uid' => $parent_uid], ['uid' => DI::userSession()->getLocalUserId()]); + $this->db->update('user', ['parent-uid' => $parent_uid], ['uid' => $this->session->getLocalUserId()]); } protected function content(array $request = []): string { parent::content(); - if (!DI::userSession()->getLocalUserId()) { - throw new HTTPException\ForbiddenException(DI::l10n()->t('Permission denied.')); + if (!$this->session->isAuthenticated()) { + throw new HTTPException\ForbiddenException($this->t('Permission denied.')); } - $args = DI::args(); - - // @TODO Replace with router-provided arguments - $action = $args->get(2); - $user_id = $args->get(3); + $action = $this->parameters['action'] ?? ''; + $user_id = $this->parameters['user_id'] ?? 0; if ($action === 'add' && $user_id) { - if (DI::userSession()->getSubManagedUserId()) { - DI::sysmsg()->addNotice(DI::l10n()->t('Delegated administrators can view but not change delegation permissions.')); - DI::baseUrl()->redirect('settings/delegation'); + if ($this->session->getSubManagedUserId()) { + $this->systemMessages->addNotice($this->t('Delegated administrators can view but not change delegation permissions.')); + $this->baseUrl->redirect('settings/delegation'); } $user = User::getById($user_id, ['nickname']); - if (DBA::isResult($user)) { + if ($this->db->isResult($user)) { $condition = [ - 'uid' => DI::userSession()->getLocalUserId(), - 'nurl' => Strings::normaliseLink(DI::baseUrl() . '/profile/' . $user['nickname']) + 'uid' => $this->session->getLocalUserId(), + 'nurl' => Strings::normaliseLink($this->baseUrl . '/profile/' . $user['nickname']) ]; - if (DBA::exists('contact', $condition)) { - DBA::insert('manage', ['uid' => $user_id, 'mid' => DI::userSession()->getLocalUserId()]); + if ($this->db->exists('contact', $condition)) { + $this->db->insert('manage', ['uid' => $user_id, 'mid' => $this->session->getLocalUserId()]); } } else { - DI::sysmsg()->addNotice(DI::l10n()->t('Delegate user not found.')); + $this->systemMessages->addNotice($this->t('Delegate user not found.')); } - DI::baseUrl()->redirect('settings/delegation'); + $this->baseUrl->redirect('settings/delegation'); } if ($action === 'remove' && $user_id) { - if (DI::userSession()->getSubManagedUserId()) { - DI::sysmsg()->addNotice(DI::l10n()->t('Delegated administrators can view but not change delegation permissions.')); - DI::baseUrl()->redirect('settings/delegation'); + if ($this->session->getSubManagedUserId()) { + $this->systemMessages->addNotice($this->t('Delegated administrators can view but not change delegation permissions.')); + $this->baseUrl->redirect('settings/delegation'); } - DBA::delete('manage', ['uid' => $user_id, 'mid' => DI::userSession()->getLocalUserId()]); - DI::baseUrl()->redirect('settings/delegation'); + $this->db->delete('manage', ['uid' => $user_id, 'mid' => $this->session->getLocalUserId()]); + $this->baseUrl->redirect('settings/delegation'); } // find everybody that currently has delegated management to this account/page - $delegates = DBA::selectToArray('user', [], ['`uid` IN (SELECT `uid` FROM `manage` WHERE `mid` = ?)', DI::userSession()->getLocalUserId()]); + $delegates = $this->db->selectToArray('user', [], ['`uid` IN (SELECT `uid` FROM `manage` WHERE `mid` = ?)', $this->session->getLocalUserId()]); $uids = []; foreach ($delegates as $user) { @@ -119,69 +135,76 @@ class Delegation extends BaseSettings // find every contact who might be a candidate for delegation $potentials = []; - $nicknames = []; + $nicknames = []; - $condition = ['baseurl' => DI::baseUrl(), 'self' => false, 'uid' => DI::userSession()->getLocalUserId(), 'blocked' => false]; - $contacts = DBA::select('contact', ['nick'], $condition); - while ($contact = DBA::fetch($contacts)) { + $condition = ['baseurl' => $this->baseUrl, 'self' => false, 'uid' => $this->session->getLocalUserId(), 'blocked' => false]; + $contacts = $this->db->select('contact', ['nick'], $condition); + while ($contact = $this->db->fetch($contacts)) { $nicknames[] = $contact['nick']; } - DBA::close($contacts); + $this->db->close($contacts); // get user records for all potential page delegates who are not already delegates or managers - $potentialDelegateUsers = DBA::selectToArray('user', ['uid', 'username', 'nickname'], ['nickname' => $nicknames]); + $potentialDelegateUsers = $this->db->selectToArray( + 'user', + ['uid', 'username', 'nickname'], + [ + 'nickname' => $nicknames, + 'account_removed' => false, + 'account_expired' => false, + 'blocked' => false, + ] + ); foreach ($potentialDelegateUsers as $user) { if (!in_array($user['uid'], $uids)) { $potentials[] = $user; } } - $parent_user = null; + $parent_user = null; $parent_password = null; - $user = User::getById(DI::userSession()->getLocalUserId(), ['parent-uid', 'email']); - if (DBA::isResult($user) && !DBA::exists('user', ['parent-uid' => DI::userSession()->getLocalUserId()])) { + $user = User::getById($this->session->getLocalUserId(), ['parent-uid', 'email']); + if ($this->db->isResult($user) && !$this->db->exists('user', ['parent-uid' => $this->session->getLocalUserId()])) { $parent_uid = $user['parent-uid']; - $parents = [0 => DI::l10n()->t('No parent user')]; + $parents = [0 => $this->t('No parent user')]; - $fields = ['uid', 'username', 'nickname']; - $condition = ['email' => $user['email'], 'verified' => true, 'blocked' => false, 'parent-uid' => null]; - $parent_users = DBA::selectToArray('user', $fields, $condition); - foreach($parent_users as $parent) { - if ($parent['uid'] != DI::userSession()->getLocalUserId()) { + $fields = ['uid', 'username', 'nickname']; + $condition = ['email' => $user['email'], 'verified' => true, 'blocked' => false, 'parent-uid' => null]; + $parent_users = $this->db->selectToArray('user', $fields, $condition); + foreach ($parent_users as $parent) { + if ($parent['uid'] != $this->session->getLocalUserId()) { $parents[$parent['uid']] = sprintf('%s (%s)', $parent['username'], $parent['nickname']); } } - $parent_user = ['parent_user', DI::l10n()->t('Parent User'), $parent_uid, '', $parents]; - $parent_password = ['parent_password', DI::l10n()->t('Parent Password:'), '', DI::l10n()->t('Please enter the password of the parent account to legitimize your request.')]; + $parent_user = ['parent_user', $this->t('Parent User'), $parent_uid, '', $parents]; + $parent_password = ['parent_password', $this->t('Parent Password:'), '', $this->t('Please enter the password of the parent account to legitimize your request.')]; } $is_child_user = !empty($user['parent-uid']); - $o = Renderer::replaceMacros(Renderer::getMarkupTemplate('settings/delegation.tpl'), [ - '$form_security_token' => BaseModule::getFormSecurityToken('delegate'), - '$account_header' => DI::l10n()->t('Additional Accounts'), - '$account_desc' => DI::l10n()->t('Register additional accounts that are automatically connected to your existing account so you can manage them from this account.'), - '$add_account' => DI::l10n()->t('Register an additional account'), - '$parent_header' => DI::l10n()->t('Parent User'), - '$parent_user' => $parent_user, - '$parent_password' => $parent_password, - '$parent_desc' => DI::l10n()->t('Parent users have total control about this account, including the account settings. Please double check whom you give this access.'), - '$is_child_user' => $is_child_user, - '$submit' => DI::l10n()->t('Save Settings'), - '$header' => DI::l10n()->t('Manage Accounts'), - '$delegates_header' => DI::l10n()->t('Delegates'), - '$base' => DI::baseUrl(), - '$desc' => DI::l10n()->t('Delegates are able to manage all aspects of this account/page except for basic account settings. Please do not delegate your personal account to anybody that you do not trust completely.'), - '$head_delegates' => DI::l10n()->t('Existing Page Delegates'), - '$delegates' => $delegates, - '$head_potentials' => DI::l10n()->t('Potential Delegates'), - '$potentials' => $potentials, - '$remove' => DI::l10n()->t('Remove'), - '$add' => DI::l10n()->t('Add'), - '$none' => DI::l10n()->t('No entries.') - ]); + return Renderer::replaceMacros(Renderer::getMarkupTemplate('settings/delegation.tpl'), [ + '$l10n' => [ + 'account_header' => $this->t('Additional Accounts'), + 'account_desc' => $this->t('Register additional accounts that are automatically connected to your existing account so you can manage them from this account.'), + 'add_account' => $this->t('Register an additional account'), + 'parent_header' => $this->t('Parent User'), + 'parent_desc' => $this->t('Parent users have total control about this account, including the account settings. Please double check whom you give this access.'), + 'submit' => $this->t('Save Settings'), + 'header' => $this->t('Manage Accounts'), + 'delegates_header' => $this->t('Delegates'), + 'desc' => $this->t('Delegates are able to manage all aspects of this account/page except for basic account settings. Please do not delegate your personal account to anybody that you do not trust completely.'), + 'head_delegates' => $this->t('Existing Page Delegates'), + 'head_potentials' => $this->t('Potential Delegates'), + 'none' => $this->t('No entries.'), + ], - return $o; + '$form_security_token' => BaseModule::getFormSecurityToken('delegate'), + '$parent_user' => $parent_user, + '$parent_password' => $parent_password, + '$is_child_user' => $is_child_user, + '$delegates' => $delegates, + '$potentials' => $potentials, + ]); } } diff --git a/src/Module/Settings/RemoveMe.php b/src/Module/Settings/RemoveMe.php index 1225cc1e2e..800c2cd6c8 100644 --- a/src/Module/Settings/RemoveMe.php +++ b/src/Module/Settings/RemoveMe.php @@ -22,11 +22,10 @@ namespace Friendica\Module\Settings; use Friendica\App; -use Friendica\Core\Config\Capability\IManageConfigValues; +use Friendica\Content\Widget; use Friendica\Core\L10n; use Friendica\Core\Renderer; use Friendica\Core\Session\Capability\IHandleUserSessions; -use Friendica\Database\Database; use Friendica\DI; use Friendica\Model\User; use Friendica\Model\User\Cookie; @@ -40,10 +39,6 @@ use Psr\Log\LoggerInterface; class RemoveMe extends BaseSettings { - /** @var IManageConfigValues */ - private $config; - /** @var Database */ - private $database; /** @var Emailer */ private $emailer; /** @var SystemMessages */ @@ -51,12 +46,10 @@ class RemoveMe extends BaseSettings /** @var Cookie */ private $cookie; - public function __construct(Cookie $cookie, SystemMessages $systemMessages, Emailer $emailer, Database $database, IManageConfigValues $config, IHandleUserSessions $session, App\Page $page, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, array $server, array $parameters = []) + public function __construct(Cookie $cookie, SystemMessages $systemMessages, Emailer $emailer, IHandleUserSessions $session, App\Page $page, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, array $server, array $parameters = []) { parent::__construct($session, $page, $l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters); - $this->config = $config; - $this->database = $database; $this->emailer = $emailer; $this->systemMessages = $systemMessages; $this->cookie = $cookie; @@ -79,6 +72,9 @@ class RemoveMe extends BaseSettings try { $userId = User::getIdFromPasswordAuthentication($this->session->getLocalUserId(), trim($request[$hash])); + if ($userId != $this->session->getLocalUserId()) { + throw new \RuntimeException($this->t("There was a validation error, please make sure you're logged in with the account you want to remove and try again.") . ' ' . $this->t('If this error persists, please contact your administrator.')); + } } catch (\Throwable $e) { $this->systemMessages->addNotice($e->getMessage()); return; @@ -100,13 +96,19 @@ class RemoveMe extends BaseSettings $this->emailer->send($email); } - User::remove($userId); + try { + User::remove($userId); - $this->session->clear(); - $this->cookie->clear(); + $this->session->clear(); + $this->cookie->clear(); - $this->systemMessages->addInfo($this->t('Your user account has been successfully removed. Bye bye!')); - $this->baseUrl->redirect(); + $this->systemMessages->addInfo($this->t('Your account has been successfully removed. Bye bye!')); + $this->baseUrl->redirect(); + } catch (\RuntimeException $e) { + $this->systemMessages->addNotice($e->getMessage()); + } finally { + return; + } } protected function content(array $request = []): string @@ -128,6 +130,9 @@ class RemoveMe extends BaseSettings 'title' => DI::l10n()->t('Remove My Account'), 'desc' => DI::l10n()->t('This will completely remove your account. Once this has been done it is not recoverable.'), ], + + '$hovercard' => Widget\Hovercard::getHTML(User::getOwnerDataById($this->session->getLocalUserId())), + '$password' => [$hash, $this->t('Please enter your password for verification:'), null, null, true], ]); } diff --git a/src/Module/User/Delegation.php b/src/Module/User/Delegation.php new file mode 100644 index 0000000000..6f20b9facb --- /dev/null +++ b/src/Module/User/Delegation.php @@ -0,0 +1,195 @@ +. + * + */ + +namespace Friendica\Module\User; + +use Friendica\App; +use Friendica\BaseModule; +use Friendica\Contact\Introduction\Repository\Introduction; +use Friendica\Core\Hook; +use Friendica\Core\L10n; +use Friendica\Core\Renderer; +use Friendica\Core\Session\Capability\IHandleUserSessions; +use Friendica\Database\Database; +use Friendica\Model\Notification; +use Friendica\Model\User; +use Friendica\Module\Response; +use Friendica\Navigation\Notifications\Repository\Notify; +use Friendica\Navigation\SystemMessages; +use Friendica\Network\HTTPException\ForbiddenException; +use Friendica\Security\Authentication; +use Friendica\Util; +use Psr\Log\LoggerInterface; + +/** + * Switches current user between delegates/parent user + */ +class Delegation extends BaseModule +{ + /** @var IHandleUserSessions */ + private $session; + /** @var Database */ + private $db; + /** @var Authentication */ + private $auth; + /** @var SystemMessages */ + private $systemMessages; + /** @var Notify */ + private $notify; + /** @var Introduction */ + private $intro; + /** @var App */ + private $app; + + public function __construct(App $app, Introduction $intro, Notify $notify, SystemMessages $systemMessages, Authentication $auth, Database $db, IHandleUserSessions $session, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Util\Profiler $profiler, Response $response, array $server, array $parameters = []) + { + parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters); + + $this->session = $session; + $this->db = $db; + $this->auth = $auth; + $this->systemMessages = $systemMessages; + $this->notify = $notify; + $this->intro = $intro; + $this->app = $app; + } + + protected function post(array $request = []) + { + if (!$this->session->getLocalUserId()) { + return; + } + + $uid = $this->session->getLocalUserId(); + $orig_record = User::getById($this->session->getLocalUserId()); + + if ($this->session->getSubManagedUserId()) { + $user = User::getById($this->session->getSubManagedUserId()); + if ($this->db->isResult($user)) { + $uid = intval($user['uid']); + $orig_record = $user; + } + } + + $identity = intval($request['identity'] ?? 0); + if (!$identity) { + return; + } + + $limited_id = 0; + $original_id = $uid; + + $manages = $this->db->selectToArray('manage', ['mid'], ['uid' => $uid]); + foreach ($manages as $manage) { + if ($identity == $manage['mid']) { + $limited_id = $manage['mid']; + break; + } + } + + if ($limited_id) { + $user = User::getById($limited_id); + } else { + // Check if the target user is one of our children + $user = $this->db->selectFirst('user', [], ['uid' => $identity, 'parent-uid' => $orig_record['uid']]); + + // Check if the target user is one of our siblings + if (!$this->db->isResult($user) && $orig_record['parent-uid']) { + $user = $this->db->selectFirst('user', [], ['uid' => $identity, 'parent-uid' => $orig_record['parent-uid']]); + } + + // Check if it's our parent or our own user + if (!$this->db->isResult($user) + && ( + $orig_record['parent-uid'] && $orig_record['parent-uid'] === $identity + || + $orig_record['uid'] && $orig_record['uid'] === $identity + ) + ) { + $user = User::getById($identity); + } + } + + if (!$this->db->isResult($user)) { + return; + } + + $this->session->clear(); + + $this->auth->setForUser($this->app, $user, true, true); + + if ($limited_id) { + $this->session->setSubManagedUserId($original_id); + } + + $ret = []; + Hook::callAll('home_init', $ret); + + $this->systemMessages->addNotice($this->t('You are now logged in as %s', $user['username'])); + + $this->baseUrl->redirect('network'); + } + + protected function content(array $request = []): string + { + if (!$this->session->getLocalUserId()) { + throw new ForbiddenException($this->t('Permission denied.')); + } + + $identities = User::identities($this->session->getSubManagedUserId() ?: $this->session->getLocalUserId()); + + //getting additional information for each identity + foreach ($identities as $key => $identity) { + $identities[$key]['thumb'] = User::getAvatarUrl($identity, Util\Proxy::SIZE_THUMB); + + $identities[$key]['selected'] = ($identity['nickname'] === $this->session->getLocalUserNickname()); + + $notifications = $this->notify->countForUser( + $identity['uid'], + ["`msg` != '' AND NOT (`type` IN (?, ?)) AND NOT `seen`", Notification\Type::INTRO, Notification\Type::MAIL], + ['distinct' => true, 'expression' => 'parent'] + ); + + $notifications += $this->db->count( + 'mail', + ['uid' => $identity['uid'], 'seen' => false], + ['distinct' => true, 'expression' => 'convid'] + ); + + $notifications += $this->intro->countActiveForUser($identity['uid']); + + $identities[$key]['notifications'] = $notifications; + } + + $tpl = Renderer::getMarkupTemplate('delegation.tpl'); + return Renderer::replaceMacros($tpl, [ + '$l10n' => [ + 'title' => $this->t('Switch between your accounts'), + 'settings_label' => $this->t('Manage your accounts'), + 'desc' => $this->t('Toggle between different identities or community/group pages which share your account details or which you have been granted "manage" permissions'), + 'choose' => $this->t('Select an identity to manage: '), + 'submit' => $this->t('Submit'), + ], + + '$identities' => $identities, + ]); + } +} 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], diff --git a/static/routes.config.php b/static/routes.config.php index 1b708140ca..e1dbc6321b 100644 --- a/static/routes.config.php +++ b/static/routes.config.php @@ -423,8 +423,8 @@ return [ ], '/credits' => [Module\Credits::class, [R::GET]], - '/delegation' => [Module\Delegation::class, [R::GET, R::POST]], - '/dfrn_notify[/{nickname}]' => [Module\DFRN\Notify::class, [R::POST]], + '/delegation' => [Module\User\Delegation::class, [R::GET, R::POST]], + '/dfrn_notify[/{nickname}]' => [Module\DFRN\Notify::class, [ R::POST]], '/dfrn_poll/{nickname}' => [Module\DFRN\Poll::class, [R::GET]], '/dirfind' => [Module\Search\Directory::class, [R::GET]], '/directory' => [Module\Directory::class, [R::GET]], 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); diff --git a/view/lang/C/messages.po b/view/lang/C/messages.po index df6411a9ff..11b8d09c7c 100644 --- a/view/lang/C/messages.po +++ b/view/lang/C/messages.po @@ -46,7 +46,7 @@ msgstr "" #: mod/item.php:452 mod/message.php:67 mod/message.php:113 mod/notes.php:45 #: mod/photos.php:152 mod/photos.php:670 src/Model/Event.php:520 -#: src/Module/Attach.php:55 src/Module/BaseApi.php:99 +#: src/Module/Attach.php:55 src/Module/BaseApi.php:103 #: src/Module/BaseNotifications.php:98 src/Module/BaseSettings.php:50 #: src/Module/Calendar/Event/API.php:88 src/Module/Calendar/Event/Form.php:84 #: src/Module/Calendar/Export.php:82 src/Module/Calendar/Show.php:82 @@ -55,9 +55,9 @@ msgstr "" #: src/Module/Contact/Follow.php:160 src/Module/Contact/MatchInterests.php:86 #: src/Module/Contact/Suggestions.php:54 src/Module/Contact/Unfollow.php:66 #: src/Module/Contact/Unfollow.php:80 src/Module/Contact/Unfollow.php:112 -#: src/Module/Delegation.php:118 src/Module/FollowConfirm.php:38 -#: src/Module/FriendSuggest.php:57 src/Module/Invite.php:42 -#: src/Module/Invite.php:131 src/Module/Notifications/Notification.php:76 +#: src/Module/FollowConfirm.php:38 src/Module/FriendSuggest.php:57 +#: src/Module/Invite.php:42 src/Module/Invite.php:131 +#: src/Module/Notifications/Notification.php:76 #: src/Module/Notifications/Notification.php:107 #: src/Module/OStatus/Repair.php:60 src/Module/OStatus/Subscribe.php:66 #: src/Module/Post/Edit.php:76 src/Module/Profile/Common.php:75 @@ -69,16 +69,16 @@ msgstr "" #: src/Module/Register.php:245 src/Module/Search/Directory.php:37 #: src/Module/Settings/Account.php:50 src/Module/Settings/Account.php:408 #: src/Module/Settings/Channels.php:56 src/Module/Settings/Channels.php:114 -#: src/Module/Settings/Delegation.php:41 src/Module/Settings/Delegation.php:71 -#: src/Module/Settings/Display.php:90 src/Module/Settings/Display.php:193 +#: src/Module/Settings/Delegation.php:90 src/Module/Settings/Display.php:90 +#: src/Module/Settings/Display.php:193 #: src/Module/Settings/Profile/Photo/Crop.php:165 #: src/Module/Settings/Profile/Photo/Index.php:111 -#: src/Module/Settings/RemoveMe.php:117 src/Module/Settings/UserExport.php:80 +#: src/Module/Settings/RemoveMe.php:119 src/Module/Settings/UserExport.php:80 #: src/Module/Settings/UserExport.php:114 #: src/Module/Settings/UserExport.php:215 #: src/Module/Settings/UserExport.php:235 -#: src/Module/Settings/UserExport.php:300 src/Module/User/Import.php:84 -#: src/Module/User/Import.php:91 +#: src/Module/Settings/UserExport.php:300 src/Module/User/Delegation.php:154 +#: src/Module/User/Import.php:84 src/Module/User/Import.php:91 msgid "Permission denied." msgstr "" @@ -307,19 +307,20 @@ msgstr "" #: src/Module/Debug/ActivityPubConversion.php:140 #: src/Module/Debug/Babel.php:313 src/Module/Debug/Localtime.php:64 #: src/Module/Debug/Probe.php:54 src/Module/Debug/WebFinger.php:51 -#: src/Module/Delegation.php:147 src/Module/FriendSuggest.php:145 -#: src/Module/Install.php:234 src/Module/Install.php:274 -#: src/Module/Install.php:309 src/Module/Invite.php:178 -#: src/Module/Item/Compose.php:189 src/Module/Moderation/Item/Source.php:79 +#: src/Module/FriendSuggest.php:145 src/Module/Install.php:234 +#: src/Module/Install.php:274 src/Module/Install.php:309 +#: src/Module/Invite.php:178 src/Module/Item/Compose.php:189 +#: src/Module/Moderation/Item/Source.php:79 #: src/Module/Moderation/Report/Create.php:168 #: src/Module/Moderation/Report/Create.php:183 #: src/Module/Moderation/Report/Create.php:211 #: src/Module/Moderation/Report/Create.php:263 #: src/Module/Profile/Profile.php:274 src/Module/Profile/UnkMail.php:155 #: src/Module/Settings/Profile/Index.php:257 -#: src/Module/Settings/Server/Action.php:79 src/Object/Post.php:1106 -#: view/theme/duepuntozero/config.php:85 view/theme/frio/config.php:171 -#: view/theme/quattro/config.php:87 view/theme/vier/config.php:135 +#: src/Module/Settings/Server/Action.php:79 src/Module/User/Delegation.php:189 +#: src/Object/Post.php:1106 view/theme/duepuntozero/config.php:85 +#: view/theme/frio/config.php:171 view/theme/quattro/config.php:87 +#: view/theme/vier/config.php:135 msgid "Submit" msgstr "" @@ -960,7 +961,7 @@ msgstr "" msgid "Enter user nickname: " msgstr "" -#: src/Console/User.php:182 src/Model/User.php:711 +#: src/Console/User.php:182 src/Model/User.php:710 #: src/Module/Api/Twitter/ContactEndpoint.php:74 #: src/Module/Moderation/Users/Active.php:71 #: src/Module/Moderation/Users/Blocked.php:71 @@ -1748,7 +1749,7 @@ msgstr "" #: src/Content/GroupManager.php:152 src/Content/Nav.php:278 #: src/Content/Text/HTML.php:880 src/Content/Widget.php:537 -#: src/Model/User.php:1273 +#: src/Model/User.php:1272 msgid "Groups" msgstr "" @@ -2724,8 +2725,8 @@ msgstr "" #: src/Core/Installer.php:519 msgid "" -"The web installer needs to be able to create a file called \"local.config.php" -"\" in the \"config\" folder of your web server and it is unable to do so." +"The web installer needs to be able to create a file called \"local.config." +"php\" in the \"config\" folder of your web server and it is unable to do so." msgstr "" #: src/Core/Installer.php:520 @@ -3146,24 +3147,24 @@ msgstr "" msgid "%s: updating %s table." msgstr "" -#: src/Factory/Api/Mastodon/Error.php:55 +#: src/Factory/Api/Mastodon/Error.php:42 msgid "Record not found" msgstr "" -#: src/Factory/Api/Mastodon/Error.php:65 +#: src/Factory/Api/Mastodon/Error.php:49 msgid "Unprocessable Entity" msgstr "" -#: src/Factory/Api/Mastodon/Error.php:75 +#: src/Factory/Api/Mastodon/Error.php:56 msgid "Unauthorized" msgstr "" -#: src/Factory/Api/Mastodon/Error.php:84 +#: src/Factory/Api/Mastodon/Error.php:62 msgid "" "Token is not authorized with a valid user or is missing a required scope" msgstr "" -#: src/Factory/Api/Mastodon/Error.php:94 +#: src/Factory/Api/Mastodon/Error.php:69 msgid "Internal Server Error" msgstr "" @@ -3624,145 +3625,145 @@ msgstr "" msgid "Contact information and Social Networks" msgstr "" -#: src/Model/User.php:227 src/Model/User.php:1186 +#: src/Model/User.php:226 src/Model/User.php:1185 msgid "SERIOUS ERROR: Generation of security keys failed." msgstr "" -#: src/Model/User.php:620 src/Model/User.php:653 +#: src/Model/User.php:619 src/Model/User.php:652 msgid "Login failed" msgstr "" -#: src/Model/User.php:685 +#: src/Model/User.php:684 msgid "Not enough information to authenticate" msgstr "" -#: src/Model/User.php:806 +#: src/Model/User.php:805 msgid "Password can't be empty" msgstr "" -#: src/Model/User.php:848 +#: src/Model/User.php:847 msgid "Empty passwords are not allowed." msgstr "" -#: src/Model/User.php:852 +#: src/Model/User.php:851 msgid "" "The new password has been exposed in a public data dump, please choose " "another." msgstr "" -#: src/Model/User.php:856 +#: src/Model/User.php:855 msgid "The password length is limited to 72 characters." msgstr "" -#: src/Model/User.php:860 +#: src/Model/User.php:859 msgid "The password can't contain white spaces nor accentuated letters" msgstr "" -#: src/Model/User.php:1069 +#: src/Model/User.php:1068 msgid "Passwords do not match. Password unchanged." msgstr "" -#: src/Model/User.php:1076 +#: src/Model/User.php:1075 msgid "An invitation is required." msgstr "" -#: src/Model/User.php:1080 +#: src/Model/User.php:1079 msgid "Invitation could not be verified." msgstr "" -#: src/Model/User.php:1088 +#: src/Model/User.php:1087 msgid "Invalid OpenID url" msgstr "" -#: src/Model/User.php:1101 src/Security/Authentication.php:241 +#: src/Model/User.php:1100 src/Security/Authentication.php:241 msgid "" "We encountered a problem while logging in with the OpenID you provided. " "Please check the correct spelling of the ID." msgstr "" -#: src/Model/User.php:1101 src/Security/Authentication.php:241 +#: src/Model/User.php:1100 src/Security/Authentication.php:241 msgid "The error message was:" msgstr "" -#: src/Model/User.php:1107 +#: src/Model/User.php:1106 msgid "Please enter the required information." msgstr "" -#: src/Model/User.php:1121 +#: src/Model/User.php:1120 #, php-format msgid "" "system.username_min_length (%s) and system.username_max_length (%s) are " "excluding each other, swapping values." msgstr "" -#: src/Model/User.php:1128 +#: src/Model/User.php:1127 #, php-format msgid "Username should be at least %s character." msgid_plural "Username should be at least %s characters." msgstr[0] "" msgstr[1] "" -#: src/Model/User.php:1132 +#: src/Model/User.php:1131 #, php-format msgid "Username should be at most %s character." msgid_plural "Username should be at most %s characters." msgstr[0] "" msgstr[1] "" -#: src/Model/User.php:1140 +#: src/Model/User.php:1139 msgid "That doesn't appear to be your full (First Last) name." msgstr "" -#: src/Model/User.php:1145 +#: src/Model/User.php:1144 msgid "Your email domain is not among those allowed on this site." msgstr "" -#: src/Model/User.php:1149 +#: src/Model/User.php:1148 msgid "Not a valid email address." msgstr "" -#: src/Model/User.php:1152 +#: src/Model/User.php:1151 msgid "The nickname was blocked from registration by the nodes admin." msgstr "" -#: src/Model/User.php:1156 src/Model/User.php:1162 +#: src/Model/User.php:1155 src/Model/User.php:1161 msgid "Cannot use that email." msgstr "" -#: src/Model/User.php:1168 +#: src/Model/User.php:1167 msgid "Your nickname can only contain a-z, 0-9 and _." msgstr "" -#: src/Model/User.php:1176 src/Model/User.php:1233 +#: src/Model/User.php:1175 src/Model/User.php:1232 msgid "Nickname is already registered. Please choose another." msgstr "" -#: src/Model/User.php:1220 src/Model/User.php:1224 +#: src/Model/User.php:1219 src/Model/User.php:1223 msgid "An error occurred during registration. Please try again." msgstr "" -#: src/Model/User.php:1247 +#: src/Model/User.php:1246 msgid "An error occurred creating your default profile. Please try again." msgstr "" -#: src/Model/User.php:1254 +#: src/Model/User.php:1253 msgid "An error occurred creating your self contact. Please try again." msgstr "" -#: src/Model/User.php:1259 +#: src/Model/User.php:1258 msgid "Friends" msgstr "" -#: src/Model/User.php:1263 +#: src/Model/User.php:1262 msgid "" "An error occurred creating your default contact circle. Please try again." msgstr "" -#: src/Model/User.php:1307 +#: src/Model/User.php:1306 msgid "Profile Photos" msgstr "" -#: src/Model/User.php:1487 +#: src/Model/User.php:1486 #, php-format msgid "" "\n" @@ -3770,7 +3771,7 @@ msgid "" "\t\t\tthe administrator of %2$s has set up an account for you." msgstr "" -#: src/Model/User.php:1490 +#: src/Model/User.php:1489 #, php-format msgid "" "\n" @@ -3808,12 +3809,12 @@ msgid "" "\t\tThank you and welcome to %4$s." msgstr "" -#: src/Model/User.php:1523 src/Model/User.php:1630 +#: src/Model/User.php:1522 src/Model/User.php:1629 #, php-format msgid "Registration details for %s" msgstr "" -#: src/Model/User.php:1543 +#: src/Model/User.php:1542 #, php-format msgid "" "\n" @@ -3829,12 +3830,12 @@ msgid "" "\t\t" msgstr "" -#: src/Model/User.php:1562 +#: src/Model/User.php:1561 #, php-format msgid "Registration at %s" msgstr "" -#: src/Model/User.php:1586 +#: src/Model/User.php:1585 #, php-format msgid "" "\n" @@ -3843,7 +3844,7 @@ msgid "" "\t\t\t" msgstr "" -#: src/Model/User.php:1594 +#: src/Model/User.php:1593 #, php-format msgid "" "\n" @@ -3882,6 +3883,11 @@ msgid "" "\t\t\tThank you and welcome to %2$s." msgstr "" +#: src/Model/User.php:1656 +msgid "" +"User with delegates can't be removed, please remove delegate users first" +msgstr "" + #: src/Module/Admin/Addons/Details.php:65 msgid "Addon not found." msgstr "" @@ -3952,7 +3958,7 @@ msgstr "" #: src/Module/Settings/Account.php:561 src/Module/Settings/Addons.php:78 #: src/Module/Settings/Connectors.php:160 #: src/Module/Settings/Connectors.php:246 -#: src/Module/Settings/Delegation.php:171 src/Module/Settings/Display.php:303 +#: src/Module/Settings/Delegation.php:193 src/Module/Settings/Display.php:303 #: src/Module/Settings/Features.php:76 msgid "Save Settings" msgstr "" @@ -5351,9 +5357,9 @@ msgstr "" #: src/Module/Admin/Summary.php:98 msgid "" -"The last update failed. Please run \"php bin/console.php dbstructure update" -"\" from the command line and have a look at the errors that might appear. " -"(Some of the errors are possibly inside the logfile.)" +"The last update failed. Please run \"php bin/console.php dbstructure " +"update\" from the command line and have a look at the errors that might " +"appear. (Some of the errors are possibly inside the logfile.)" msgstr "" #: src/Module/Admin/Summary.php:102 @@ -5504,8 +5510,8 @@ msgstr "" #, php-format msgid "" "Show some informations regarding the needed information to operate the node " -"according e.g. to EU-GDPR." +"according e.g. to EU-GDPR." msgstr "" #: src/Module/Admin/Tos.php:81 @@ -5547,7 +5553,7 @@ msgstr "" msgid "Only starting posts can be muted" msgstr "" -#: src/Module/Api/Mastodon/Statuses/Reblog.php:56 +#: src/Module/Api/Mastodon/Statuses/Reblog.php:58 #, php-format msgid "Posts from %s can't be shared" msgstr "" @@ -5560,7 +5566,7 @@ msgstr "" msgid "Only starting posts can be unmuted" msgstr "" -#: src/Module/Api/Mastodon/Statuses/Unreblog.php:62 +#: src/Module/Api/Mastodon/Statuses/Unreblog.php:64 #, php-format msgid "Posts from %s can't be unshared" msgstr "" @@ -5656,26 +5662,26 @@ msgstr "" msgid "User registrations waiting for confirmation" msgstr "" -#: src/Module/BaseApi.php:451 src/Module/BaseApi.php:467 -#: src/Module/BaseApi.php:483 +#: src/Module/BaseApi.php:455 src/Module/BaseApi.php:471 +#: src/Module/BaseApi.php:487 msgid "Too Many Requests" msgstr "" -#: src/Module/BaseApi.php:452 +#: src/Module/BaseApi.php:456 #, php-format msgid "Daily posting limit of %d post reached. The post was rejected." msgid_plural "Daily posting limit of %d posts reached. The post was rejected." msgstr[0] "" msgstr[1] "" -#: src/Module/BaseApi.php:468 +#: src/Module/BaseApi.php:472 #, php-format msgid "Weekly posting limit of %d post reached. The post was rejected." msgid_plural "Weekly posting limit of %d posts reached. The post was rejected." msgstr[0] "" msgstr[1] "" -#: src/Module/BaseApi.php:484 +#: src/Module/BaseApi.php:488 #, php-format msgid "Monthly posting limit of %d post reached. The post was rejected." msgid_plural "" @@ -5790,7 +5796,7 @@ msgstr "" msgid "Social Networks" msgstr "" -#: src/Module/BaseSettings.php:146 src/Module/Settings/Delegation.php:172 +#: src/Module/BaseSettings.php:146 src/Module/Settings/Delegation.php:194 msgid "Manage Accounts" msgstr "" @@ -7054,29 +7060,6 @@ msgstr "" msgid "Lookup address:" msgstr "" -#: src/Module/Delegation.php:110 -#, php-format -msgid "You are now logged in as %s" -msgstr "" - -#: src/Module/Delegation.php:142 -msgid "Switch between your accounts" -msgstr "" - -#: src/Module/Delegation.php:143 -msgid "Manage your accounts" -msgstr "" - -#: src/Module/Delegation.php:144 -msgid "" -"Toggle between different identities or community/group pages which share " -"your account details or which you have been granted \"manage\" permissions" -msgstr "" - -#: src/Module/Delegation.php:145 -msgid "Select an identity to manage: " -msgstr "" - #: src/Module/Directory.php:74 msgid "No entries (some entries may be hidden)." msgstr "" @@ -8796,7 +8779,7 @@ msgstr "" msgid "Select a tag to remove: " msgstr "" -#: src/Module/Post/Tag/Remove.php:108 src/Module/Settings/Delegation.php:180 +#: src/Module/Post/Tag/Remove.php:108 #: src/Module/Settings/TwoFactor/Trusted.php:144 msgid "Remove" msgstr "" @@ -8861,8 +8844,8 @@ msgstr "" #: src/Module/Profile/Profile.php:158 #, php-format msgid "" -"You're currently viewing your profile as %s Cancel" +"You're currently viewing your profile as %s Cancel" msgstr "" #: src/Module/Profile/Profile.php:167 @@ -9110,11 +9093,11 @@ msgstr "" msgid "Note: This node explicitly contains adult content" msgstr "" -#: src/Module/Register.php:183 src/Module/Settings/Delegation.php:156 +#: src/Module/Register.php:183 src/Module/Settings/Delegation.php:181 msgid "Parent Password:" msgstr "" -#: src/Module/Register.php:183 src/Module/Settings/Delegation.php:156 +#: src/Module/Register.php:183 src/Module/Settings/Delegation.php:181 msgid "" "Please enter the password of the parent account to legitimize your request." msgstr "" @@ -9410,8 +9393,8 @@ msgstr "" #: src/Module/Security/TwoFactor/Verify.php:100 #, php-format msgid "" -"If you do not have access to your authentication code you can use a two-factor recovery code." +"If you do not have access to your authentication code you can use a two-factor recovery code." msgstr "" #: src/Module/Security/TwoFactor/Verify.php:101 @@ -10025,7 +10008,7 @@ msgstr "" msgid "Add new entry to the channel list" msgstr "" -#: src/Module/Settings/Channels.php:160 src/Module/Settings/Delegation.php:181 +#: src/Module/Settings/Channels.php:160 msgid "Add" msgstr "" @@ -10237,76 +10220,76 @@ msgstr "" msgid "Move to folder:" msgstr "" -#: src/Module/Settings/Delegation.php:54 +#: src/Module/Settings/Delegation.php:73 msgid "Delegation successfully granted." msgstr "" -#: src/Module/Settings/Delegation.php:56 +#: src/Module/Settings/Delegation.php:75 msgid "Parent user not found, unavailable or password doesn't match." msgstr "" -#: src/Module/Settings/Delegation.php:60 +#: src/Module/Settings/Delegation.php:79 msgid "Delegation successfully revoked." msgstr "" -#: src/Module/Settings/Delegation.php:82 src/Module/Settings/Delegation.php:104 +#: src/Module/Settings/Delegation.php:98 src/Module/Settings/Delegation.php:120 msgid "" "Delegated administrators can view but not change delegation permissions." msgstr "" -#: src/Module/Settings/Delegation.php:96 +#: src/Module/Settings/Delegation.php:112 msgid "Delegate user not found." msgstr "" -#: src/Module/Settings/Delegation.php:144 +#: src/Module/Settings/Delegation.php:169 msgid "No parent user" msgstr "" -#: src/Module/Settings/Delegation.php:155 -#: src/Module/Settings/Delegation.php:166 +#: src/Module/Settings/Delegation.php:180 +#: src/Module/Settings/Delegation.php:191 msgid "Parent User" msgstr "" -#: src/Module/Settings/Delegation.php:163 +#: src/Module/Settings/Delegation.php:188 msgid "Additional Accounts" msgstr "" -#: src/Module/Settings/Delegation.php:164 +#: src/Module/Settings/Delegation.php:189 msgid "" "Register additional accounts that are automatically connected to your " "existing account so you can manage them from this account." msgstr "" -#: src/Module/Settings/Delegation.php:165 +#: src/Module/Settings/Delegation.php:190 msgid "Register an additional account" msgstr "" -#: src/Module/Settings/Delegation.php:169 +#: src/Module/Settings/Delegation.php:192 msgid "" "Parent users have total control about this account, including the account " "settings. Please double check whom you give this access." msgstr "" -#: src/Module/Settings/Delegation.php:173 +#: src/Module/Settings/Delegation.php:195 msgid "Delegates" msgstr "" -#: src/Module/Settings/Delegation.php:175 +#: src/Module/Settings/Delegation.php:196 msgid "" "Delegates are able to manage all aspects of this account/page except for " "basic account settings. Please do not delegate your personal account to " "anybody that you do not trust completely." msgstr "" -#: src/Module/Settings/Delegation.php:176 +#: src/Module/Settings/Delegation.php:197 msgid "Existing Page Delegates" msgstr "" -#: src/Module/Settings/Delegation.php:178 +#: src/Module/Settings/Delegation.php:198 msgid "Potential Delegates" msgstr "" -#: src/Module/Settings/Delegation.php:182 +#: src/Module/Settings/Delegation.php:199 msgid "No entries." msgstr "" @@ -10700,42 +10683,52 @@ msgstr "" msgid "select a photo from your photo albums" msgstr "" -#: src/Module/Settings/RemoveMe.php:94 +#: src/Module/Settings/RemoveMe.php:76 +msgid "" +"There was a validation error, please make sure you're logged in with the " +"account you want to remove and try again." +msgstr "" + +#: src/Module/Settings/RemoveMe.php:76 +msgid "If this error persists, please contact your administrator." +msgstr "" + +#: src/Module/Settings/RemoveMe.php:90 #: src/Navigation/Notifications/Repository/Notify.php:471 #: src/Navigation/Notifications/Repository/Notify.php:492 msgid "[Friendica System Notify]" msgstr "" -#: src/Module/Settings/RemoveMe.php:94 +#: src/Module/Settings/RemoveMe.php:90 msgid "User deleted their account" msgstr "" -#: src/Module/Settings/RemoveMe.php:95 +#: src/Module/Settings/RemoveMe.php:91 msgid "" "On your Friendica node an user deleted their account. Please ensure that " "their data is removed from the backups." msgstr "" -#: src/Module/Settings/RemoveMe.php:96 +#: src/Module/Settings/RemoveMe.php:92 #, php-format msgid "The user id is %d" msgstr "" -#: src/Module/Settings/RemoveMe.php:108 -msgid "Your user account has been successfully removed. Bye bye!" +#: src/Module/Settings/RemoveMe.php:105 +msgid "Your account has been successfully removed. Bye bye!" msgstr "" -#: src/Module/Settings/RemoveMe.php:128 +#: src/Module/Settings/RemoveMe.php:130 msgid "Remove My Account" msgstr "" -#: src/Module/Settings/RemoveMe.php:129 +#: src/Module/Settings/RemoveMe.php:131 msgid "" "This will completely remove your account. Once this has been done it is not " "recoverable." msgstr "" -#: src/Module/Settings/RemoveMe.php:131 +#: src/Module/Settings/RemoveMe.php:136 msgid "Please enter your password for verification:" msgstr "" @@ -11052,8 +11045,8 @@ msgstr "" #: src/Module/Settings/TwoFactor/Verify.php:149 #, php-format msgid "" -"

Or you can open the following URL in your mobile device:

%s

" +"

Or you can open the following URL in your mobile device:

%s

" msgstr "" #: src/Module/Settings/TwoFactor/Verify.php:156 @@ -11162,9 +11155,9 @@ msgstr "" msgid "" "At any point in time a logged in user can export their account data from the " "account settings. If the user wants " -"to delete their account they can do so at " -"%1$s/settings/removeme. The deletion of the account will be permanent. " -"Deletion of the data will also be requested from the nodes of the " +"to delete their account they can do so at %1$s/settings/removeme. The deletion of the account will be " +"permanent. Deletion of the data will also be requested from the nodes of the " "communication partners." msgstr "" @@ -11184,6 +11177,29 @@ msgstr "" msgid "The requested item doesn't exist or has been deleted." msgstr "" +#: src/Module/User/Delegation.php:146 +#, php-format +msgid "You are now logged in as %s" +msgstr "" + +#: src/Module/User/Delegation.php:185 +msgid "Switch between your accounts" +msgstr "" + +#: src/Module/User/Delegation.php:186 +msgid "Manage your accounts" +msgstr "" + +#: src/Module/User/Delegation.php:187 +msgid "" +"Toggle between different identities or community/group pages which share " +"your account details or which you have been granted \"manage\" permissions" +msgstr "" + +#: src/Module/User/Delegation.php:188 +msgid "Select an identity to manage: " +msgstr "" + #: src/Module/User/Import.php:103 msgid "User imports on closed servers can only be done by an administrator." msgstr "" diff --git a/view/lang/ru/messages.po b/view/lang/ru/messages.po index 83a1480ce5..cc6fd073c2 100644 --- a/view/lang/ru/messages.po +++ b/view/lang/ru/messages.po @@ -24,7 +24,7 @@ msgid "" msgstr "" "Project-Id-Version: friendica\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2023-09-18 05:30+0000\n" +"POT-Creation-Date: 2023-10-03 08:59+0200\n" "PO-Revision-Date: 2011-05-05 10:19+0000\n" "Last-Translator: Alexander An , 2020-2023\n" "Language-Team: Russian (http://app.transifex.com/Friendica/friendica/language/ru/)\n" @@ -798,33 +798,33 @@ msgstr "Страница не найдена." msgid "You must be logged in to use addons. " msgstr "Вы должны войти в систему, чтобы использовать аддоны." -#: src/BaseModule.php:401 +#: src/BaseModule.php:403 msgid "" "The form security token was not correct. This probably happened because the " "form has been opened for too long (>3 hours) before submitting it." msgstr "Ключ формы безопасности неправильный. Вероятно, это произошло потому, что форма была открыта слишком долго (более 3 часов) до её отправки." -#: src/BaseModule.php:428 +#: src/BaseModule.php:430 msgid "All contacts" msgstr "Все контакты" -#: src/BaseModule.php:433 src/Content/Conversation/Factory/Timeline.php:62 +#: src/BaseModule.php:435 src/Content/Conversation/Factory/Timeline.php:62 #: src/Content/Widget.php:239 src/Core/ACL.php:195 src/Module/Contact.php:415 #: src/Module/PermissionTooltip.php:127 src/Module/PermissionTooltip.php:149 msgid "Followers" msgstr "Подписаны на вас" -#: src/BaseModule.php:438 src/Content/Widget.php:240 +#: src/BaseModule.php:440 src/Content/Widget.php:240 #: src/Module/Contact.php:418 msgid "Following" msgstr "Ваши подписки" -#: src/BaseModule.php:443 src/Content/Widget.php:241 +#: src/BaseModule.php:445 src/Content/Widget.php:241 #: src/Module/Contact.php:421 msgid "Mutual friends" msgstr "Взаимные друзья" -#: src/BaseModule.php:451 +#: src/BaseModule.php:453 msgid "Common" msgstr "Общее" @@ -1417,7 +1417,7 @@ msgstr "Настройки разрешений" msgid "Public post" msgstr "Публичная запись" -#: src/Content/Conversation.php:424 src/Content/Widget/VCard.php:120 +#: src/Content/Conversation.php:424 src/Content/Widget/VCard.php:125 #: src/Model/Profile.php:467 src/Module/Admin/Logs/View.php:92 #: src/Module/Post/Edit.php:181 msgid "Message" @@ -1610,60 +1610,60 @@ msgstr "Видео" msgid "Posts with videos" msgstr "Записи с видео" -#: src/Content/Conversation/Factory/Timeline.php:85 +#: src/Content/Conversation/Factory/Timeline.php:84 msgid "Local Community" msgstr "Местное сообщество" -#: src/Content/Conversation/Factory/Timeline.php:85 +#: src/Content/Conversation/Factory/Timeline.php:84 msgid "Posts from local users on this server" msgstr "Записи пользователей с этого сервера" -#: src/Content/Conversation/Factory/Timeline.php:89 +#: src/Content/Conversation/Factory/Timeline.php:88 msgid "Global Community" msgstr "Глобальное сообщество" -#: src/Content/Conversation/Factory/Timeline.php:89 +#: src/Content/Conversation/Factory/Timeline.php:88 msgid "Posts from users of the whole federated network" msgstr "Записи пользователей со всей федеративной сети" -#: src/Content/Conversation/Factory/Timeline.php:103 +#: src/Content/Conversation/Factory/Timeline.php:102 msgid "Latest Activity" msgstr "Вся активность" -#: src/Content/Conversation/Factory/Timeline.php:103 +#: src/Content/Conversation/Factory/Timeline.php:102 msgid "Sort by latest activity" msgstr "Отсортировать по свежей активности" -#: src/Content/Conversation/Factory/Timeline.php:104 +#: src/Content/Conversation/Factory/Timeline.php:103 msgid "Latest Posts" msgstr "Новые записи" -#: src/Content/Conversation/Factory/Timeline.php:104 +#: src/Content/Conversation/Factory/Timeline.php:103 msgid "Sort by post received date" msgstr "Отсортировать по времени получения записей" -#: src/Content/Conversation/Factory/Timeline.php:105 +#: src/Content/Conversation/Factory/Timeline.php:104 msgid "Latest Creation" msgstr "По времени" -#: src/Content/Conversation/Factory/Timeline.php:105 +#: src/Content/Conversation/Factory/Timeline.php:104 msgid "Sort by post creation date" msgstr "Отсортировать по времени создания записей" -#: src/Content/Conversation/Factory/Timeline.php:106 +#: src/Content/Conversation/Factory/Timeline.php:105 #: src/Module/Settings/Profile/Index.php:260 msgid "Personal" msgstr "Личные" -#: src/Content/Conversation/Factory/Timeline.php:106 +#: src/Content/Conversation/Factory/Timeline.php:105 msgid "Posts that mention or involve you" msgstr "Записи, которые упоминают вас или в которых вы участвуете" -#: src/Content/Conversation/Factory/Timeline.php:107 src/Object/Post.php:380 +#: src/Content/Conversation/Factory/Timeline.php:106 src/Object/Post.php:380 msgid "Starred" msgstr "Избранное" -#: src/Content/Conversation/Factory/Timeline.php:107 +#: src/Content/Conversation/Factory/Timeline.php:106 msgid "Favourite Posts" msgstr "Избранные записи" @@ -1802,7 +1802,7 @@ msgstr "показать больше" msgid "Create new group" msgstr "Создать новую группу" -#: src/Content/Item.php:331 src/Model/Item.php:3003 +#: src/Content/Item.php:331 src/Model/Item.php:3021 msgid "event" msgstr "мероприятие" @@ -1810,7 +1810,7 @@ msgstr "мероприятие" msgid "status" msgstr "статус" -#: src/Content/Item.php:340 src/Model/Item.php:3005 +#: src/Content/Item.php:340 src/Model/Item.php:3023 #: src/Module/Post/Tag/Add.php:123 msgid "photo" msgstr "фото" @@ -1824,32 +1824,31 @@ msgstr "%1$s tagged %2$s's %3$s в %4$s" msgid "Follow Thread" msgstr "Подписаться на обсуждение" -#: src/Content/Item.php:429 src/Model/Contact.php:1227 +#: src/Content/Item.php:429 src/Model/Contact.php:1246 msgid "View Status" msgstr "Просмотреть статус" #: src/Content/Item.php:430 src/Content/Item.php:451 -#: src/Model/Contact.php:1176 src/Model/Contact.php:1219 -#: src/Model/Contact.php:1228 src/Module/Directory.php:157 +#: src/Model/Contact.php:1176 src/Model/Contact.php:1237 +#: src/Model/Contact.php:1247 src/Module/Directory.php:157 #: src/Module/Settings/Profile/Index.php:259 msgid "View Profile" msgstr "Просмотреть профиль" -#: src/Content/Item.php:431 src/Model/Contact.php:1229 +#: src/Content/Item.php:431 src/Model/Contact.php:1248 msgid "View Photos" msgstr "Просмотреть фото" -#: src/Content/Item.php:432 src/Model/Contact.php:1220 -#: src/Model/Contact.php:1230 +#: src/Content/Item.php:432 src/Model/Contact.php:1215 msgid "Network Posts" msgstr "Записи сети" -#: src/Content/Item.php:433 src/Model/Contact.php:1221 -#: src/Model/Contact.php:1231 +#: src/Content/Item.php:433 src/Model/Contact.php:1239 +#: src/Model/Contact.php:1250 msgid "View Contact" msgstr "Просмотреть контакт" -#: src/Content/Item.php:434 src/Model/Contact.php:1232 +#: src/Content/Item.php:434 src/Model/Contact.php:1251 msgid "Send PM" msgstr "Отправить ЛС" @@ -1884,7 +1883,7 @@ msgid "Languages" msgstr "Языки" #: src/Content/Item.php:448 src/Content/Widget.php:80 -#: src/Model/Contact.php:1222 src/Model/Contact.php:1233 +#: src/Model/Contact.php:1240 src/Model/Contact.php:1252 #: src/Module/Contact/Follow.php:167 view/theme/vier/theme.php:195 msgid "Connect/Follow" msgstr "Подключиться/Подписаться" @@ -2221,8 +2220,8 @@ msgstr "Изображение / Фото" msgid "%2$s %3$s" msgstr "%2$s %3$s" -#: src/Content/Text/BBCode.php:939 src/Model/Item.php:3745 -#: src/Model/Item.php:3751 src/Model/Item.php:3752 +#: src/Content/Text/BBCode.php:939 src/Model/Item.php:3763 +#: src/Model/Item.php:3769 src/Model/Item.php:3770 msgid "Link to source" msgstr "Ссылка на источник" @@ -2254,7 +2253,7 @@ msgstr "Загружаю больше сообщений..." msgid "The end" msgstr "Конец" -#: src/Content/Text/HTML.php:859 src/Content/Widget/VCard.php:116 +#: src/Content/Text/HTML.php:859 src/Content/Widget/VCard.php:121 #: src/Model/Profile.php:461 src/Module/Contact/Profile.php:471 msgid "Follow" msgstr "Подписка" @@ -2394,7 +2393,7 @@ msgstr "Люди" msgid "Organisations" msgstr "Организации" -#: src/Content/Widget.php:536 src/Model/Contact.php:1698 +#: src/Content/Widget.php:536 src/Model/Contact.php:1718 msgid "News" msgstr "Новости" @@ -2460,17 +2459,17 @@ msgstr[3] "Популярные тэги (за %d часов)" msgid "More Trending Tags" msgstr "Больше популярных тэгов" -#: src/Content/Widget/VCard.php:109 src/Model/Profile.php:376 +#: src/Content/Widget/VCard.php:114 src/Model/Profile.php:376 #: src/Module/Contact/Profile.php:408 src/Module/Profile/Profile.php:199 msgid "XMPP:" msgstr "XMPP:" -#: src/Content/Widget/VCard.php:110 src/Model/Profile.php:377 +#: src/Content/Widget/VCard.php:115 src/Model/Profile.php:377 #: src/Module/Contact/Profile.php:410 src/Module/Profile/Profile.php:203 msgid "Matrix:" msgstr "Matrix:" -#: src/Content/Widget/VCard.php:111 src/Model/Event.php:82 +#: src/Content/Widget/VCard.php:116 src/Model/Event.php:82 #: src/Model/Event.php:109 src/Model/Event.php:471 src/Model/Event.php:963 #: src/Model/Profile.php:371 src/Module/Contact/Profile.php:406 #: src/Module/Directory.php:147 src/Module/Notifications/Introductions.php:187 @@ -2478,17 +2477,30 @@ msgstr "Matrix:" msgid "Location:" msgstr "Откуда:" -#: src/Content/Widget/VCard.php:114 src/Model/Profile.php:474 +#: src/Content/Widget/VCard.php:119 src/Model/Profile.php:474 #: src/Module/Notifications/Introductions.php:201 msgid "Network:" msgstr "Сеть:" -#: src/Content/Widget/VCard.php:118 src/Model/Contact.php:1223 -#: src/Model/Contact.php:1234 src/Model/Profile.php:463 +#: src/Content/Widget/VCard.php:123 src/Model/Contact.php:1241 +#: src/Model/Contact.php:1253 src/Model/Profile.php:463 #: src/Module/Contact/Profile.php:463 msgid "Unfollow" msgstr "Отписка" +#: src/Content/Widget/VCard.php:127 src/Model/Contact.php:1205 +#: src/Module/Moderation/Item/Source.php:85 +msgid "Mention" +msgstr "Отметка" + +#: src/Content/Widget/VCard.php:128 src/Model/Contact.php:1202 +msgid "Post to group" +msgstr "Запись для группы" + +#: src/Content/Widget/VCard.php:129 src/Model/Contact.php:1212 +msgid "View group" +msgstr "Просмотр группы" + #: src/Core/ACL.php:166 src/Module/Profile/Profile.php:269 msgid "Yourself" msgstr "Вы" @@ -2869,158 +2881,158 @@ msgstr "База данных уже используется." msgid "Could not connect to database." msgstr "Не удалось подключиться к базе данных." -#: src/Core/L10n.php:476 src/Model/Event.php:430 +#: src/Core/L10n.php:494 src/Model/Event.php:430 #: src/Module/Settings/Display.php:235 msgid "Monday" msgstr "Понедельник" -#: src/Core/L10n.php:476 src/Model/Event.php:431 +#: src/Core/L10n.php:494 src/Model/Event.php:431 #: src/Module/Settings/Display.php:236 msgid "Tuesday" msgstr "Вторник" -#: src/Core/L10n.php:476 src/Model/Event.php:432 +#: src/Core/L10n.php:494 src/Model/Event.php:432 #: src/Module/Settings/Display.php:237 msgid "Wednesday" msgstr "Среда" -#: src/Core/L10n.php:476 src/Model/Event.php:433 +#: src/Core/L10n.php:494 src/Model/Event.php:433 #: src/Module/Settings/Display.php:238 msgid "Thursday" msgstr "Четверг" -#: src/Core/L10n.php:476 src/Model/Event.php:434 +#: src/Core/L10n.php:494 src/Model/Event.php:434 #: src/Module/Settings/Display.php:239 msgid "Friday" msgstr "Пятница" -#: src/Core/L10n.php:476 src/Model/Event.php:435 +#: src/Core/L10n.php:494 src/Model/Event.php:435 #: src/Module/Settings/Display.php:240 msgid "Saturday" msgstr "Суббота" -#: src/Core/L10n.php:476 src/Model/Event.php:429 +#: src/Core/L10n.php:494 src/Model/Event.php:429 #: src/Module/Settings/Display.php:234 msgid "Sunday" msgstr "Воскресенье" -#: src/Core/L10n.php:480 src/Model/Event.php:450 +#: src/Core/L10n.php:498 src/Model/Event.php:450 msgid "January" msgstr "Январь" -#: src/Core/L10n.php:480 src/Model/Event.php:451 +#: src/Core/L10n.php:498 src/Model/Event.php:451 msgid "February" msgstr "Февраль" -#: src/Core/L10n.php:480 src/Model/Event.php:452 +#: src/Core/L10n.php:498 src/Model/Event.php:452 msgid "March" msgstr "Март" -#: src/Core/L10n.php:480 src/Model/Event.php:453 +#: src/Core/L10n.php:498 src/Model/Event.php:453 msgid "April" msgstr "Апрель" -#: src/Core/L10n.php:480 src/Core/L10n.php:499 src/Model/Event.php:441 +#: src/Core/L10n.php:498 src/Core/L10n.php:517 src/Model/Event.php:441 msgid "May" msgstr "Май" -#: src/Core/L10n.php:480 src/Model/Event.php:454 +#: src/Core/L10n.php:498 src/Model/Event.php:454 msgid "June" msgstr "Июнь" -#: src/Core/L10n.php:480 src/Model/Event.php:455 +#: src/Core/L10n.php:498 src/Model/Event.php:455 msgid "July" msgstr "Июль" -#: src/Core/L10n.php:480 src/Model/Event.php:456 +#: src/Core/L10n.php:498 src/Model/Event.php:456 msgid "August" msgstr "Август" -#: src/Core/L10n.php:480 src/Model/Event.php:457 +#: src/Core/L10n.php:498 src/Model/Event.php:457 msgid "September" msgstr "Сентябрь" -#: src/Core/L10n.php:480 src/Model/Event.php:458 +#: src/Core/L10n.php:498 src/Model/Event.php:458 msgid "October" msgstr "Октябрь" -#: src/Core/L10n.php:480 src/Model/Event.php:459 +#: src/Core/L10n.php:498 src/Model/Event.php:459 msgid "November" msgstr "Ноябрь" -#: src/Core/L10n.php:480 src/Model/Event.php:460 +#: src/Core/L10n.php:498 src/Model/Event.php:460 msgid "December" msgstr "Декабрь" -#: src/Core/L10n.php:495 src/Model/Event.php:422 +#: src/Core/L10n.php:513 src/Model/Event.php:422 msgid "Mon" msgstr "Пн" -#: src/Core/L10n.php:495 src/Model/Event.php:423 +#: src/Core/L10n.php:513 src/Model/Event.php:423 msgid "Tue" msgstr "Вт" -#: src/Core/L10n.php:495 src/Model/Event.php:424 +#: src/Core/L10n.php:513 src/Model/Event.php:424 msgid "Wed" msgstr "Ср" -#: src/Core/L10n.php:495 src/Model/Event.php:425 +#: src/Core/L10n.php:513 src/Model/Event.php:425 msgid "Thu" msgstr "Чт" -#: src/Core/L10n.php:495 src/Model/Event.php:426 +#: src/Core/L10n.php:513 src/Model/Event.php:426 msgid "Fri" msgstr "Пт" -#: src/Core/L10n.php:495 src/Model/Event.php:427 +#: src/Core/L10n.php:513 src/Model/Event.php:427 msgid "Sat" msgstr "Сб" -#: src/Core/L10n.php:495 src/Model/Event.php:421 +#: src/Core/L10n.php:513 src/Model/Event.php:421 msgid "Sun" msgstr "Вс" -#: src/Core/L10n.php:499 src/Model/Event.php:437 +#: src/Core/L10n.php:517 src/Model/Event.php:437 msgid "Jan" msgstr "Янв" -#: src/Core/L10n.php:499 src/Model/Event.php:438 +#: src/Core/L10n.php:517 src/Model/Event.php:438 msgid "Feb" msgstr "Фев" -#: src/Core/L10n.php:499 src/Model/Event.php:439 +#: src/Core/L10n.php:517 src/Model/Event.php:439 msgid "Mar" msgstr "Мрт" -#: src/Core/L10n.php:499 src/Model/Event.php:440 +#: src/Core/L10n.php:517 src/Model/Event.php:440 msgid "Apr" msgstr "Апр" -#: src/Core/L10n.php:499 src/Model/Event.php:442 +#: src/Core/L10n.php:517 src/Model/Event.php:442 msgid "Jun" msgstr "Июн" -#: src/Core/L10n.php:499 src/Model/Event.php:443 +#: src/Core/L10n.php:517 src/Model/Event.php:443 msgid "Jul" msgstr "Июл" -#: src/Core/L10n.php:499 src/Model/Event.php:444 +#: src/Core/L10n.php:517 src/Model/Event.php:444 msgid "Aug" msgstr "Авг" -#: src/Core/L10n.php:499 +#: src/Core/L10n.php:517 msgid "Sep" msgstr "Сен" -#: src/Core/L10n.php:499 src/Model/Event.php:446 +#: src/Core/L10n.php:517 src/Model/Event.php:446 msgid "Oct" msgstr "Окт" -#: src/Core/L10n.php:499 src/Model/Event.php:447 +#: src/Core/L10n.php:517 src/Model/Event.php:447 msgid "Nov" msgstr "Нбр" -#: src/Core/L10n.php:499 src/Model/Event.php:448 +#: src/Core/L10n.php:517 src/Model/Event.php:448 msgid "Dec" msgstr "Дек" @@ -3238,82 +3250,82 @@ msgstr "Название круга:" msgid "Edit circles" msgstr "Редактировать круги" -#: src/Model/Contact.php:1240 src/Module/Moderation/Users/Pending.php:102 +#: src/Model/Contact.php:1260 src/Module/Moderation/Users/Pending.php:102 #: src/Module/Notifications/Introductions.php:132 #: src/Module/Notifications/Introductions.php:204 msgid "Approve" msgstr "Одобрить" -#: src/Model/Contact.php:1694 +#: src/Model/Contact.php:1714 msgid "Organisation" msgstr "Организация" -#: src/Model/Contact.php:1702 +#: src/Model/Contact.php:1722 msgid "Group" msgstr "Группа" -#: src/Model/Contact.php:3005 +#: src/Model/Contact.php:3025 msgid "Disallowed profile URL." msgstr "Запрещенный URL профиля." -#: src/Model/Contact.php:3010 src/Module/Friendica.php:101 +#: src/Model/Contact.php:3030 src/Module/Friendica.php:101 msgid "Blocked domain" msgstr "Заблокированный домен" -#: src/Model/Contact.php:3015 +#: src/Model/Contact.php:3035 msgid "Connect URL missing." msgstr "Connect-URL отсутствует." -#: src/Model/Contact.php:3024 +#: src/Model/Contact.php:3044 msgid "" "The contact could not be added. Please check the relevant network " "credentials in your Settings -> Social Networks page." msgstr "Контакт не может быть добавлен. Пожалуйста проверьте учётные данные на странице Настройки -> Социальные сети." -#: src/Model/Contact.php:3042 +#: src/Model/Contact.php:3062 #, php-format msgid "Expected network %s does not match actual network %s" msgstr "Ожидаемая сеть %s не соответствует обнаруженной сети %s" -#: src/Model/Contact.php:3059 +#: src/Model/Contact.php:3079 msgid "The profile address specified does not provide adequate information." msgstr "Указанный адрес профиля не дает адекватной информации." -#: src/Model/Contact.php:3061 +#: src/Model/Contact.php:3081 msgid "No compatible communication protocols or feeds were discovered." msgstr "Обнаружены несовместимые протоколы связи или каналы." -#: src/Model/Contact.php:3064 +#: src/Model/Contact.php:3084 msgid "An author or name was not found." msgstr "Автор или имя не найдены." -#: src/Model/Contact.php:3067 +#: src/Model/Contact.php:3087 msgid "No browser URL could be matched to this address." msgstr "Нет URL браузера, который соответствует этому адресу." -#: src/Model/Contact.php:3070 +#: src/Model/Contact.php:3090 msgid "" "Unable to match @-style Identity Address with a known protocol or email " "contact." msgstr "Не получается совместить этот адрес с известным протоколом или контактом электронной почты." -#: src/Model/Contact.php:3071 +#: src/Model/Contact.php:3091 msgid "Use mailto: in front of address to force email check." msgstr "Bcgjkmpeqnt mailto: перед адресом для быстрого доступа к email." -#: src/Model/Contact.php:3077 +#: src/Model/Contact.php:3097 msgid "" "The profile address specified belongs to a network which has been disabled " "on this site." msgstr "Указанный адрес профиля принадлежит сети, недоступной на этом сайта." -#: src/Model/Contact.php:3082 +#: src/Model/Contact.php:3102 msgid "" "Limited profile. This person will be unable to receive direct/personal " "notifications from you." msgstr "Ограниченный профиль. Этот человек не сможет получить прямые / личные уведомления от вас." -#: src/Model/Contact.php:3148 +#: src/Model/Contact.php:3168 msgid "Unable to retrieve contact information." msgstr "Невозможно получить контактную информацию." @@ -3418,48 +3430,48 @@ msgstr "день рождения %s" msgid "Happy Birthday %s" msgstr "С днём рождения %s" -#: src/Model/Item.php:2062 +#: src/Model/Item.php:2080 #, php-format msgid "Detected languages in this post:\\n%s" msgstr "Обнаруженные в этой записи языки:\\n%s" -#: src/Model/Item.php:3007 +#: src/Model/Item.php:3025 msgid "activity" msgstr "активность" -#: src/Model/Item.php:3009 +#: src/Model/Item.php:3027 msgid "comment" msgstr "комментарий" -#: src/Model/Item.php:3012 src/Module/Post/Tag/Add.php:123 +#: src/Model/Item.php:3030 src/Module/Post/Tag/Add.php:123 msgid "post" msgstr "пост" -#: src/Model/Item.php:3182 +#: src/Model/Item.php:3200 #, php-format msgid "%s is blocked" msgstr "%s заблокирован" -#: src/Model/Item.php:3184 +#: src/Model/Item.php:3202 #, php-format msgid "%s is ignored" msgstr "%s игнорируется" -#: src/Model/Item.php:3186 +#: src/Model/Item.php:3204 #, php-format msgid "Content from %s is collapsed" msgstr "Запись от %s скрыта" -#: src/Model/Item.php:3190 +#: src/Model/Item.php:3208 #, php-format msgid "Content warning: %s" msgstr "Предупреждение о контенте: %s" -#: src/Model/Item.php:3652 +#: src/Model/Item.php:3670 msgid "bytes" msgstr "байт" -#: src/Model/Item.php:3683 +#: src/Model/Item.php:3701 #, php-format msgid "%2$s (%3$d%%, %1$d vote)" msgid_plural "%2$s (%3$d%%, %1$d votes)" @@ -3468,7 +3480,7 @@ msgstr[1] "%2$s (%3$d%%, %1$d голоса)" msgstr[2] "%2$s (%3$d%%, %1$d голосов)" msgstr[3] "%2$s (%3$d%%, %1$d голосов)" -#: src/Model/Item.php:3685 +#: src/Model/Item.php:3703 #, php-format msgid "%2$s (%1$d vote)" msgid_plural "%2$s (%1$d votes)" @@ -3477,7 +3489,7 @@ msgstr[1] "%2$s (%1$d голоса)" msgstr[2] "%2$s (%1$d голосов)" msgstr[3] "%2$s (%1$d голосов)" -#: src/Model/Item.php:3690 +#: src/Model/Item.php:3708 #, php-format msgid "%d voter. Poll end: %s" msgid_plural "%d voters. Poll end: %s" @@ -3486,7 +3498,7 @@ msgstr[1] "%d голоса. Конец опроса: %s" msgstr[2] "%d голосов. Конец опроса: %s" msgstr[3] "%d голосов. Конец опроса: %s" -#: src/Model/Item.php:3692 +#: src/Model/Item.php:3710 #, php-format msgid "%d voter." msgid_plural "%d voters." @@ -3495,12 +3507,12 @@ msgstr[1] "%d голоса." msgstr[2] "%d голосов." msgstr[3] "%d голосов." -#: src/Model/Item.php:3694 +#: src/Model/Item.php:3712 #, php-format msgid "Poll end: %s" msgstr "Конец опроса: %s" -#: src/Model/Item.php:3728 src/Model/Item.php:3729 +#: src/Model/Item.php:3746 src/Model/Item.php:3747 msgid "View on separate page" msgstr "Посмотреть в отдельной вкладке" @@ -5570,7 +5582,7 @@ msgstr "Правила сервера" msgid "Enter your system rules here. Each line represents one rule." msgstr "Введите здесь правила поведения на сервере. Каждая линия - отдельное правило." -#: src/Module/Api/ApiResponse.php:279 +#: src/Module/Api/ApiResponse.php:293 #, php-format msgid "API endpoint %s %s is not implemented but might be in the future." msgstr "" @@ -5738,7 +5750,7 @@ msgstr "У вас нет доступа к страницам модератор msgid "" "Submanaged account can't access the moderation pages. Please log back in as " "the main account." -msgstr "" +msgstr "Дополнительная учётная запись не имеет доступа к модераторским страницам. Пожалуйста, зайдите под основной." #: src/Module/BaseModeration.php:110 src/Module/Moderation/Reports.php:94 msgid "Reports" @@ -5767,7 +5779,7 @@ msgstr "Удалить запись" #: src/Module/BaseModeration.php:121 src/Module/Moderation/Item/Source.php:76 msgid "Item Source" -msgstr "" +msgstr "Исходник" #: src/Module/BaseProfile.php:52 src/Module/Contact.php:507 msgid "Profile Details" @@ -5817,10 +5829,10 @@ msgid_plural "" "%d results were filtered out because your node blocks the domain they are " "registered on. You can review the list of domains your node is currently " "blocking in the About page." -msgstr[0] "" -msgstr[1] "" -msgstr[2] "" -msgstr[3] "" +msgstr[0] "%d результато не был показан, так как ваш сервер блокирует домен источника. Вы можете посмотреть список заблокированных доменов на странице информации Об узле." +msgstr[1] "%d результатов не были показаны, так как ваш сервер блокирует домен их источника. Вы можете посмотреть список заблокированных доменов на странице информации Об узле." +msgstr[2] "%d результатов не были показаны, так как ваш сервер блокирует домен их источника. Вы можете посмотреть список заблокированных доменов на странице информации Об узле." +msgstr[3] "%d результатов не были показаны, так как ваш сервер блокирует домен их источника. Вы можете посмотреть список заблокированных доменов на странице информации Об узле." #: src/Module/BaseSettings.php:78 msgid "Account" @@ -8075,10 +8087,6 @@ msgstr "Ключевое слово" msgid "URL" msgstr "URL" -#: src/Module/Moderation/Item/Source.php:85 -msgid "Mention" -msgstr "Отметка" - #: src/Module/Moderation/Item/Source.php:86 msgid "Implicit Mention" msgstr "Неявная отметка" @@ -8807,7 +8815,7 @@ msgstr "%d ещё" #: src/Module/PermissionTooltip.php:231 #, php-format msgid "To: %s
" -msgstr "" +msgstr "Кому: %s
" #: src/Module/PermissionTooltip.php:234 #, php-format @@ -8822,12 +8830,12 @@ msgstr "" #: src/Module/PermissionTooltip.php:240 #, php-format msgid "Audience: %s
" -msgstr "" +msgstr "Аудитория: %s
" #: src/Module/PermissionTooltip.php:243 #, php-format msgid "Attributed To: %s
" -msgstr "" +msgstr "Относится к: %s
" #: src/Module/Photo.php:130 msgid "The Photo is not available." diff --git a/view/lang/ru/strings.php b/view/lang/ru/strings.php index ded02de008..944ec52f85 100644 --- a/view/lang/ru/strings.php +++ b/view/lang/ru/strings.php @@ -656,6 +656,9 @@ $a->strings['Matrix:'] = 'Matrix:'; $a->strings['Location:'] = 'Откуда:'; $a->strings['Network:'] = 'Сеть:'; $a->strings['Unfollow'] = 'Отписка'; +$a->strings['Mention'] = 'Отметка'; +$a->strings['Post to group'] = 'Запись для группы'; +$a->strings['View group'] = 'Просмотр группы'; $a->strings['Yourself'] = 'Вы'; $a->strings['Mutuals'] = 'Взаимные'; $a->strings['Post to Email'] = 'Отправить на Email'; @@ -1514,12 +1517,14 @@ $a->strings['Monthly posting limit of %d post reached. The post was rejected.'] 3 => 'Месячный лимит в %d записей достигнут. Запись была отклонена.', ]; $a->strings['You don\'t have access to moderation pages.'] = 'У вас нет доступа к страницам модераторов.'; +$a->strings['Submanaged account can\'t access the moderation pages. Please log back in as the main account.'] = 'Дополнительная учётная запись не имеет доступа к модераторским страницам. Пожалуйста, зайдите под основной.'; $a->strings['Reports'] = 'Обращения'; $a->strings['Users'] = 'Пользователи'; $a->strings['Tools'] = 'Инструменты'; $a->strings['Contact Blocklist'] = 'Чёрный список контактов'; $a->strings['Server Blocklist'] = 'Чёрный список серверов'; $a->strings['Delete Item'] = 'Удалить запись'; +$a->strings['Item Source'] = 'Исходник'; $a->strings['Profile Details'] = 'Информация о вас'; $a->strings['Conversations started'] = 'Записи этого автора'; $a->strings['Only You Can See This'] = 'Только вы можете это видеть'; @@ -1529,6 +1534,12 @@ $a->strings['Tips for New Members'] = 'Советы для новых участ $a->strings['People Search - %s'] = 'Поиск по людям - %s'; $a->strings['Group Search - %s'] = 'Поиск по группам - %s'; $a->strings['No matches'] = 'Нет соответствий'; +$a->strings['%d result was filtered out because your node blocks the domain it is registered on. You can review the list of domains your node is currently blocking in the About page.'] = [ + 0 => '%d результато не был показан, так как ваш сервер блокирует домен источника. Вы можете посмотреть список заблокированных доменов на странице информации Об узле.', + 1 => '%d результатов не были показаны, так как ваш сервер блокирует домен их источника. Вы можете посмотреть список заблокированных доменов на странице информации Об узле.', + 2 => '%d результатов не были показаны, так как ваш сервер блокирует домен их источника. Вы можете посмотреть список заблокированных доменов на странице информации Об узле.', + 3 => '%d результатов не были показаны, так как ваш сервер блокирует домен их источника. Вы можете посмотреть список заблокированных доменов на странице информации Об узле.', +]; $a->strings['Account'] = 'Аккаунт'; $a->strings['Two-factor authentication'] = 'Двухфакторная аутентификация'; $a->strings['Display'] = 'Внешний вид'; @@ -2034,7 +2045,6 @@ $a->strings['Tag'] = 'Тэг'; $a->strings['Type'] = 'Тип'; $a->strings['Term'] = 'Ключевое слово'; $a->strings['URL'] = 'URL'; -$a->strings['Mention'] = 'Отметка'; $a->strings['Implicit Mention'] = 'Неявная отметка'; $a->strings['Item not found'] = 'Элемент не найден'; $a->strings['No source recorded'] = 'Источник не сохранён'; @@ -2208,6 +2218,9 @@ $a->strings['Visible to:'] = 'Кто может видеть:'; $a->strings['Collection (%s)'] = 'Коллекция (%s)'; $a->strings['Followers (%s)'] = 'Подписчики (%s)'; $a->strings['%d more'] = '%d ещё'; +$a->strings['To: %s
'] = 'Кому: %s
'; +$a->strings['Audience: %s
'] = 'Аудитория: %s
'; +$a->strings['Attributed To: %s
'] = 'Относится к: %s
'; $a->strings['The Photo is not available.'] = 'Фото недоступно.'; $a->strings['The Photo with id %s is not available.'] = 'Фотография с id %s недоступна.'; $a->strings['Invalid external resource with url %s.'] = 'Проблема с внешним ресурсом по адресу %s.'; diff --git a/view/templates/delegation.tpl b/view/templates/delegation.tpl index 0e819cdada..1faab170e9 100644 --- a/view/templates/delegation.tpl +++ b/view/templates/delegation.tpl @@ -1,11 +1,12 @@ -

{{$title}}

-

{{$desc nofilter}}

-

{{$choose}}

+
+

{{$l10n.title}}

+

{{$l10n.desc}}

+

{{$l10n.choose}}

- - -

- {{$settings_label}} -

diff --git a/view/templates/settings/delegation.tpl b/view/templates/settings/delegation.tpl index 74e3350d60..d7c59fd636 100644 --- a/view/templates/settings/delegation.tpl +++ b/view/templates/settings/delegation.tpl @@ -1,54 +1,56 @@
-

{{$header}}

+

{{$l10n.header}}

{{if !$is_child_user}} -

{{$account_header}}

- -

{{$add_account}}

+

{{$l10n.account_header}}

+ +

{{$l10n.add_account}}

{{/if}} {{if $parent_user}} -

{{$parent_header}}

-

{{$parent_desc}}

-
-
- - {{include file="field_select.tpl" field=$parent_user}} - {{include file="field_password.tpl" field=$parent_password}} -
-
-
+

{{$l10n.parent_header}}

+

{{$l10n.parent_desc}}

+
+
+ + {{include file="field_select.tpl" field=$parent_user}} + {{include file="field_password.tpl" field=$parent_password}} +
+ +
+
+
{{/if}} -

{{$delegates_header}}

+

{{$l10n.delegates_header}}

-

{{$desc nofilter}}

+

{{$l10n.desc}}

-

{{$head_delegates}}

+

{{$l10n.head_delegates}}

{{if $delegates}} - {{foreach $delegates as $x}} - + {{foreach $delegates as $delegate}} +
+ + + +
{{/foreach}} -
+
{{else}} -

{{$none}}

+

{{$l10n.none}}

{{/if}} -

{{$head_potentials}}

+

{{$l10n.head_potentials}}

{{if $potentials}} - {{foreach $potentials as $x}} - + {{foreach $potentials as $potential}} +
+ + + +
{{/foreach}} -
+
{{else}} -

{{$none}}

+

{{$l10n.none}}

{{/if}}
diff --git a/view/templates/settings/removeme.tpl b/view/templates/settings/removeme.tpl index 0532d9c695..066cbc4470 100644 --- a/view/templates/settings/removeme.tpl +++ b/view/templates/settings/removeme.tpl @@ -4,6 +4,8 @@
{{$l10n.desc nofilter}}
+ {{$hovercard nofilter}} +
{{include file="field_password.tpl" field=$password}}