]> git.mxchange.org Git - friendica.git/commitdiff
Fixed message, relationships endpoint added
authorMichael <heluecht@pirati.ca>
Sat, 15 May 2021 10:55:41 +0000 (10:55 +0000)
committerMichael <heluecht@pirati.ca>
Sat, 15 May 2021 10:55:41 +0000 (10:55 +0000)
doc/API-Mastodon.md
src/Module/Api/Mastodon/Accounts/Relationsships.php [new file with mode: 0644]
src/Module/Api/Mastodon/Statuses/Bookmark.php
src/Module/Api/Mastodon/Statuses/Mute.php
src/Module/Api/Mastodon/Statuses/Pin.php
src/Module/Api/Mastodon/Statuses/Unbookmark.php
src/Module/Api/Mastodon/Statuses/Unmute.php
src/Module/Api/Mastodon/Statuses/Unpin.php
static/routes.config.php
view/lang/C/messages.po

index d9f2ceccc63a025516b3251f8a118aa597b448fb..278f5540ee61218511b06bcda68a0e79f150354e 100644 (file)
@@ -47,6 +47,7 @@ These endpoints use the [Mastodon API entities](https://docs.joinmastodon.org/en
 - [`GET /api/v1/accounts/:id/followers`](https://docs.joinmastodon.org/methods/accounts/)
 - [`GET /api/v1/accounts/:id/following`](https://docs.joinmastodon.org/methods/accounts/)
 - [`GET /api/v1/accounts/:id/lists`](https://docs.joinmastodon.org/methods/accounts/)
+- [`GET /api/v1/accounts/relationships`](https://docs.joinmastodon.org/methods/accounts/)
 - [`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/)
@@ -115,7 +116,6 @@ These endpoints use the [Mastodon API entities](https://docs.joinmastodon.org/en
 These emdpoints are planned to be implemented
 
 - [`POST /api/v1/accounts/:id/note`](https://docs.joinmastodon.org/methods/accounts/)
-- [`GET /api/v1/accounts/relationships`](https://docs.joinmastodon.org/methods/accounts/)
 - [`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/)
diff --git a/src/Module/Api/Mastodon/Accounts/Relationsships.php b/src/Module/Api/Mastodon/Accounts/Relationsships.php
new file mode 100644 (file)
index 0000000..2c69f24
--- /dev/null
@@ -0,0 +1,59 @@
+<?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\Accounts;
+
+use Friendica\Core\Search as CoreSearch;
+use Friendica\Core\System;
+use Friendica\Database\DBA;
+use Friendica\DI;
+use Friendica\Model\Contact;
+use Friendica\Module\BaseApi;
+use Friendica\Object\Search\ContactResult;
+
+/**
+ * @see https://docs.joinmastodon.org/methods/accounts/
+ */
+class Relationships extends BaseApi
+{
+       /**
+        * @param array $parameters
+        * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+        */
+       public static function rawContent(array $parameters = [])
+       {
+               self::login();
+               $uid = self::getCurrentUserID();
+
+
+               if (empty($parameters['id'])) {
+                       DI::mstdnError()->UnprocessableEntity();
+               }
+
+               $relationsships = [];
+
+               foreach ($parameters['id'] as $id) {
+                       $relationsships[] = DI::mstdnRelationship()->createFromPublicContactId($id, $uid);
+               }
+
+               System::jsonExit($relationsships);
+       }
+}
index 5935759effef601e830db9640d9de209ba2a6a08..acdf207a3247324296aac66b7f40c2704dde4bd5 100644 (file)
@@ -48,7 +48,7 @@ class Bookmark extends BaseApi
                }
 
                if ($item['gravity'] != GRAVITY_PARENT) {
-                       DI::mstdnError()->UnprocessableEntity(DI::l10n()->t('Only starting post can be bookmarked'));
+                       DI::mstdnError()->UnprocessableEntity(DI::l10n()->t('Only starting posts can be bookmarked'));
                }
 
                Item::update(['starred' => true], ['id' => $item['id']]);
index ee3578449e2c32a5a8b15f0176e7f078859411e2..6a5d16d14b8f62ad005352b0215dc1ee06037ccb 100644 (file)
@@ -47,7 +47,7 @@ class Mute extends BaseApi
                }
 
                if ($item['gravity'] != GRAVITY_PARENT) {
-                       DI::mstdnError()->UnprocessableEntity(DI::l10n()->t('Only starting post can be muted'));
+                       DI::mstdnError()->UnprocessableEntity(DI::l10n()->t('Only starting posts can be muted'));
                }
 
                Post\ThreadUser::setIgnored($parameters['id'], $uid, true);
index a4336a8544649c9fc45db4a153c6ee295bedd7f9..2637807362716e0e6c270b32125c44a137532b94 100644 (file)
@@ -47,7 +47,7 @@ class Pin extends BaseApi
                }
 
                if ($item['gravity'] != GRAVITY_PARENT) {
-                       DI::mstdnError()->UnprocessableEntity(DI::l10n()->t('Only starting post can be pinned'));
+                       DI::mstdnError()->UnprocessableEntity(DI::l10n()->t('Only starting posts can be pinned'));
                }
 
                Post\ThreadUser::setPinned($parameters['id'], $uid, true);
index d0bfa4b1fc21304c6350829d25085d89b46aeeba..dd78d8833a1fa7fad86644434e547fd87093db22 100644 (file)
@@ -48,7 +48,7 @@ class Unbookmark extends BaseApi
                }
 
                if ($item['gravity'] != GRAVITY_PARENT) {
-                       DI::mstdnError()->UnprocessableEntity(DI::l10n()->t('Only starting post can be unbookmarked'));
+                       DI::mstdnError()->UnprocessableEntity(DI::l10n()->t('Only starting posts can be unbookmarked'));
                }
 
                Item::update(['starred' => false], ['id' => $item['id']]);
index 9d57dba535171aee92720f9cf5c1e8a2964bdd0b..26843be6c02166615fd2896e3764797bafba5f1f 100644 (file)
@@ -47,7 +47,7 @@ class Unmute extends BaseApi
                }
 
                if ($item['gravity'] != GRAVITY_PARENT) {
-                       DI::mstdnError()->UnprocessableEntity(DI::l10n()->t('Only starting post can be unmuted'));
+                       DI::mstdnError()->UnprocessableEntity(DI::l10n()->t('Only starting posts can be unmuted'));
                }
 
                Post\ThreadUser::setIgnored($parameters['id'], $uid, false);
index ec427d32116d69fd37cd30599560621f34f67357..d16bfc33ef43989691ae6cb7b3176c8053a71162 100644 (file)
@@ -47,7 +47,7 @@ class Unpin extends BaseApi
                }
 
                if ($item['gravity'] != GRAVITY_PARENT) {
-                       DI::mstdnError()->UnprocessableEntity(DI::l10n()->t('Only starting post can be pinned'));
+                       DI::mstdnError()->UnprocessableEntity(DI::l10n()->t('Only starting posts can be pinned'));
                }
 
                Post\ThreadUser::setPinned($parameters['id'], $uid, false);
index 1d8d996ef501bfe2451be01cf09bfe55790a55bc..89256a9e614347d8223dfd8858f8bf5139c0fbfd 100644 (file)
@@ -73,7 +73,7 @@ return [
                        '/accounts/{id:\d+}/pin'             => [Module\Api\Mastodon\Unimplemented::class,            [        R::POST]], // not supported
                        '/accounts/{id:\d+}/unpin'           => [Module\Api\Mastodon\Unimplemented::class,            [        R::POST]], // not supported
                        '/accounts/{id:\d+}/note'            => [Module\Api\Mastodon\Unimplemented::class,            [        R::POST]], // @todo
-                       '/accounts/relationships'            => [Module\Api\Mastodon\Unimplemented::class,            [R::GET         ]], // @todo
+                       '/accounts/relationships'            => [Module\Api\Mastodon\Accounts\Relationships::class,   [R::GET         ]],
                        '/accounts/search'                   => [Module\Api\Mastodon\Accounts\Search::class,          [R::GET         ]],
                        '/accounts/verify_credentials'       => [Module\Api\Mastodon\Accounts\VerifyCredentials::class, [R::GET       ]],
                        '/accounts/update_credentials'       => [Module\Api\Mastodon\Unimplemented::class,            [R::PATCH       ]], // @todo
index e35465fe22db715ade1f4b75ba09af917f3107bc..f2e2a1293e71fdaea2b26f395d6058cb066165d4 100644 (file)
@@ -8,7 +8,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: 2021.06-dev\n"
 "Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2021-05-15 10:13+0000\n"
+"POT-Creation-Date: 2021-05-15 10:54+0000\n"
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
 "Language-Team: LANGUAGE <LL@li.org>\n"
@@ -7201,16 +7201,16 @@ msgid "Missing parameters"
 msgstr ""
 
 #: src/Module/Api/Mastodon/Statuses/Bookmark.php:51
-msgid "Only starting post can be bookmarked"
+msgid "Only starting posts can be bookmarked"
 msgstr ""
 
 #: src/Module/Api/Mastodon/Statuses/Mute.php:50
-msgid "Only starting post can be muted"
+msgid "Only starting posts can be muted"
 msgstr ""
 
 #: src/Module/Api/Mastodon/Statuses/Pin.php:50
 #: src/Module/Api/Mastodon/Statuses/Unpin.php:50
-msgid "Only starting post can be pinned"
+msgid "Only starting posts can be pinned"
 msgstr ""
 
 #: src/Module/Api/Mastodon/Statuses/Reblog.php:53
@@ -7219,11 +7219,11 @@ msgid "Posts from %s can't be shared"
 msgstr ""
 
 #: src/Module/Api/Mastodon/Statuses/Unbookmark.php:51
-msgid "Only starting post can be unbookmarked"
+msgid "Only starting posts can be unbookmarked"
 msgstr ""
 
 #: src/Module/Api/Mastodon/Statuses/Unmute.php:50
-msgid "Only starting post can be unmuted"
+msgid "Only starting posts can be unmuted"
 msgstr ""
 
 #: src/Module/Api/Mastodon/Statuses/Unreblog.php:53