]> git.mxchange.org Git - friendica.git/commitdiff
New endpoint "verify_credentials" added
authorMichael <heluecht@pirati.ca>
Wed, 19 May 2021 09:35:08 +0000 (09:35 +0000)
committerMichael <heluecht@pirati.ca>
Wed, 19 May 2021 09:35:08 +0000 (09:35 +0000)
doc/API-Mastodon.md
src/Module/Api/Mastodon/Apps/VerifyCredentials.php [new file with mode: 0644]
static/routes.config.php

index 1d1f497d305a57d3db4eb00549018185f01dca2b..e94d3c04ed1ca1e90ba4ededae9f4a06fced5aab 100644 (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/)
diff --git a/src/Module/Api/Mastodon/Apps/VerifyCredentials.php b/src/Module/Api/Mastodon/Apps/VerifyCredentials.php
new file mode 100644 (file)
index 0000000..37c88f6
--- /dev/null
@@ -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']);
+               
+       }
+}
index c91751b176ed99bad621d39d7528bbf7104ab47f..a753b893d2c562a690f7c15059c3d4d606d980a7 100644 (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