New endpoint "verify_credentials" added

This commit is contained in:
Michael 2021-05-19 09:35:08 +00:00
parent 3172b0bcf2
commit 1c7d1c7c47
3 changed files with 49 additions and 2 deletions

View file

@ -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/)

View file

@ -0,0 +1,47 @@
<?php
/**
* @copyright Copyright (C) 2010-2021, the Friendica project
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
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']);
}
}

View file

@ -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