diff --git a/doc/API-Mastodon.md b/doc/API-Mastodon.md index d9f2ceccc6..278f5540ee 100644 --- a/doc/API-Mastodon.md +++ b/doc/API-Mastodon.md @@ -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 index 0000000000..2c69f24304 --- /dev/null +++ b/src/Module/Api/Mastodon/Accounts/Relationsships.php @@ -0,0 +1,59 @@ +. + * + */ + +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); + } +} diff --git a/src/Module/Api/Mastodon/Statuses/Bookmark.php b/src/Module/Api/Mastodon/Statuses/Bookmark.php index 5935759eff..acdf207a32 100644 --- a/src/Module/Api/Mastodon/Statuses/Bookmark.php +++ b/src/Module/Api/Mastodon/Statuses/Bookmark.php @@ -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']]); diff --git a/src/Module/Api/Mastodon/Statuses/Mute.php b/src/Module/Api/Mastodon/Statuses/Mute.php index ee3578449e..6a5d16d14b 100644 --- a/src/Module/Api/Mastodon/Statuses/Mute.php +++ b/src/Module/Api/Mastodon/Statuses/Mute.php @@ -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); diff --git a/src/Module/Api/Mastodon/Statuses/Pin.php b/src/Module/Api/Mastodon/Statuses/Pin.php index a4336a8544..2637807362 100644 --- a/src/Module/Api/Mastodon/Statuses/Pin.php +++ b/src/Module/Api/Mastodon/Statuses/Pin.php @@ -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); diff --git a/src/Module/Api/Mastodon/Statuses/Unbookmark.php b/src/Module/Api/Mastodon/Statuses/Unbookmark.php index d0bfa4b1fc..dd78d8833a 100644 --- a/src/Module/Api/Mastodon/Statuses/Unbookmark.php +++ b/src/Module/Api/Mastodon/Statuses/Unbookmark.php @@ -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']]); diff --git a/src/Module/Api/Mastodon/Statuses/Unmute.php b/src/Module/Api/Mastodon/Statuses/Unmute.php index 9d57dba535..26843be6c0 100644 --- a/src/Module/Api/Mastodon/Statuses/Unmute.php +++ b/src/Module/Api/Mastodon/Statuses/Unmute.php @@ -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); diff --git a/src/Module/Api/Mastodon/Statuses/Unpin.php b/src/Module/Api/Mastodon/Statuses/Unpin.php index ec427d3211..d16bfc33ef 100644 --- a/src/Module/Api/Mastodon/Statuses/Unpin.php +++ b/src/Module/Api/Mastodon/Statuses/Unpin.php @@ -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); diff --git a/static/routes.config.php b/static/routes.config.php index 1d8d996ef5..89256a9e61 100644 --- a/static/routes.config.php +++ b/static/routes.config.php @@ -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 diff --git a/view/lang/C/messages.po b/view/lang/C/messages.po index e35465fe22..f2e2a1293e 100644 --- a/view/lang/C/messages.po +++ b/view/lang/C/messages.po @@ -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 \n" "Language-Team: LANGUAGE \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