diff --git a/doc/API-Mastodon.md b/doc/API-Mastodon.md index 1d1f497d30..e94d3c04ed 100644 --- a/doc/API-Mastodon.md +++ b/doc/API-Mastodon.md @@ -48,6 +48,7 @@ These endpoints use the [Mastodon API entities](https://docs.joinmastodon.org/en - [`GET /api/v1/accounts/search`](https://docs.joinmastodon.org/methods/accounts) - [`GET /api/v1/accounts/verify_credentials`](https://docs.joinmastodon.org/methods/accounts) - [`POST /api/v1/apps`](https://docs.joinmastodon.org/methods/apps/) +- [`GET /api/v1/apps/verify_credentials`](https://docs.joinmastodon.org/methods/apps/) - [`GET /api/v1/blocks`](https://docs.joinmastodon.org/methods/accounts/blocks/) - [`GET /api/v1/bookmarks`](https://docs.joinmastodon.org/methods/accounts/bookmarks/) - [`GET /api/v1/custom_emojis`](https://docs.joinmastodon.org/methods/instance/custom_emojis/) @@ -117,7 +118,6 @@ These endpoints use the [Mastodon API entities](https://docs.joinmastodon.org/en These emdpoints are planned to be implemented - [`PATCH /api/v1/accounts/update_credentials`](https://docs.joinmastodon.org/methods/accounts/) -- [`GET /api/v1/apps/verify_credentials`](https://docs.joinmastodon.org/methods/apps/) - [`GET /api/v1/conversations`](https://docs.joinmastodon.org/methods/timelines/conversations/) - [`DELETE /api/v1/conversations/:id`](https://docs.joinmastodon.org/methods/timelines/conversations/) - [`POST /api/v1/conversations/:id/read`](https://docs.joinmastodon.org/methods/timelines/conversations/) diff --git a/src/Module/Api/Mastodon/Apps/VerifyCredentials.php b/src/Module/Api/Mastodon/Apps/VerifyCredentials.php new file mode 100644 index 0000000000..37c88f689e --- /dev/null +++ b/src/Module/Api/Mastodon/Apps/VerifyCredentials.php @@ -0,0 +1,47 @@ +. + * + */ + +namespace Friendica\Module\Api\Mastodon\Apps; + +use Friendica\Core\System; +use Friendica\Database\DBA; +use Friendica\DI; +use Friendica\Module\BaseApi; +use Friendica\Util\Network; + +/** + * @see https://docs.joinmastodon.org/methods/apps/ + */ +class VerifyCredentials extends BaseApi +{ + public static function rawContent(array $parameters = []) + { + self::login(self::SCOPE_READ); + $application = self::getCurrentApplication(); + + if (empty($application['id'])) { + DI::mstdnError()->Unauthorized(); + } + + System::jsonExit($application['id']); + + } +} diff --git a/static/routes.config.php b/static/routes.config.php index c91751b176..a753b893d2 100644 --- a/static/routes.config.php +++ b/static/routes.config.php @@ -87,7 +87,7 @@ return [ '/announcements/{id:\d+}/dismiss' => [Module\Api\Mastodon\Unimplemented::class, [ R::POST]], // not supported '/announcements/{id:\d+}/reactions/{name}' => [Module\Api\Mastodon\Unimplemented::class, [R::PUT, R::DELETE]], // not supported '/apps' => [Module\Api\Mastodon\Apps::class, [ R::POST]], - '/apps/verify_credentials' => [Module\Api\Mastodon\Unimplemented::class, [R::GET ]], // @todo + '/apps/verify_credentials' => [Module\Api\Mastodon\Apps\VerifyCredentials::class, [R::GET ]], '/blocks' => [Module\Api\Mastodon\Blocks::class, [R::GET ]], '/bookmarks' => [Module\Api\Mastodon\Bookmarks::class, [R::GET ]], '/conversations' => [Module\Api\Mastodon\Unimplemented::class, [R::GET ]], // @todo