Merge pull request #10220 from annando/api-timelines

API: We now support two more timeline api endpoints
This commit is contained in:
Hypolite Petovan 2021-05-08 09:00:27 -04:00 committed by GitHub
commit a5d7662c97
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
21 changed files with 867 additions and 77 deletions

View file

@ -17,6 +17,7 @@ These endpoints use the [Mastodon API entities](https://docs.joinmastodon.org/en
- [`GET /api/v1//accounts/:id`](https://docs.joinmastodon.org/methods/accounts/#retrieve-information) - [`GET /api/v1//accounts/:id`](https://docs.joinmastodon.org/methods/accounts/#retrieve-information)
- [`GET /api/v1//accounts/:id/statuses`](https://docs.joinmastodon.org/methods/accounts/#retrieve-information) - [`GET /api/v1//accounts/:id/statuses`](https://docs.joinmastodon.org/methods/accounts/#retrieve-information)
- [`GET /api/v1//accounts/verify_credentials`](https://docs.joinmastodon.org/methods/accounts)
- [`GET /api/v1/custom_emojis`](https://docs.joinmastodon.org/methods/instance/custom_emojis/) - [`GET /api/v1/custom_emojis`](https://docs.joinmastodon.org/methods/instance/custom_emojis/)
- Doesn't return unicode emojis since they aren't using an image URL - Doesn't return unicode emojis since they aren't using an image URL
@ -36,7 +37,12 @@ These endpoints use the [Mastodon API entities](https://docs.joinmastodon.org/en
- [`GET /api/v1/instance`](https://docs.joinmastodon.org/methods/instance#fetch-instance) - [`GET /api/v1/instance`](https://docs.joinmastodon.org/methods/instance#fetch-instance)
- [`GET /api/v1/instance/peers`](https://docs.joinmastodon.org/methods/instance#list-of-connected-domains) - [`GET /api/v1/instance/peers`](https://docs.joinmastodon.org/methods/instance#list-of-connected-domains)
- [`GET /api/v1/statuses/:id`](https://docs.joinmastodon.org/methods/statuses/)
- [`GET /api/v1/suggestions`](https://docs.joinmastodon.org/methods/accounts/suggestions/)
- [`GET /api/v1/timelines/home`](https://docs.joinmastodon.org/methods/timelines/)
- [`GET /api/v1/timelines/list/:id`](https://docs.joinmastodon.org/methods/timelines/)
- [`GET /api/v1/timelines/public`](https://docs.joinmastodon.org/methods/timelines/) - [`GET /api/v1/timelines/public`](https://docs.joinmastodon.org/methods/timelines/)
- [`GET /api/v1/timelines/tag/:hashtag`](https://docs.joinmastodon.org/methods/timelines/)
- [`GET /api/v1/trends`](https://docs.joinmastodon.org/methods/instance/trends/) - [`GET /api/v1/trends`](https://docs.joinmastodon.org/methods/instance/trends/)
## Non-implemented endpoints ## Non-implemented endpoints

View file

@ -276,11 +276,23 @@ class Module
$profiler->set(microtime(true) - $timestamp, 'init'); $profiler->set(microtime(true) - $timestamp, 'init');
if ($server['REQUEST_METHOD'] === 'POST') { if ($server['REQUEST_METHOD'] === Router::DELETE) {
call_user_func([$this->module_class, 'delete'], $this->module_parameters);
}
if ($server['REQUEST_METHOD'] === Router::PATCH) {
call_user_func([$this->module_class, 'patch'], $this->module_parameters);
}
if ($server['REQUEST_METHOD'] === Router::POST) {
Core\Hook::callAll($this->module . '_mod_post', $post); Core\Hook::callAll($this->module . '_mod_post', $post);
call_user_func([$this->module_class, 'post'], $this->module_parameters); call_user_func([$this->module_class, 'post'], $this->module_parameters);
} }
if ($server['REQUEST_METHOD'] === Router::PUT) {
call_user_func([$this->module_class, 'put'], $this->module_parameters);
}
Core\Hook::callAll($this->module . '_mod_afterpost', $placeholder); Core\Hook::callAll($this->module . '_mod_afterpost', $placeholder);
call_user_func([$this->module_class, 'afterpost'], $this->module_parameters); call_user_func([$this->module_class, 'afterpost'], $this->module_parameters);

View file

@ -72,6 +72,26 @@ abstract class BaseModule
return $o; return $o;
} }
/**
* Module DELETE method to process submitted data
*
* Extend this method if the module is supposed to process DELETE requests.
* Doesn't display any content
*/
public static function delete(array $parameters = [])
{
}
/**
* Module PATCH method to process submitted data
*
* Extend this method if the module is supposed to process PATCH requests.
* Doesn't display any content
*/
public static function patch(array $parameters = [])
{
}
/** /**
* Module POST method to process submitted data * Module POST method to process submitted data
* *
@ -92,6 +112,16 @@ abstract class BaseModule
{ {
} }
/**
* Module PUT method to process submitted data
*
* Extend this method if the module is supposed to process PUT requests.
* Doesn't display any content
*/
public static function put(array $parameters = [])
{
}
/* /*
* Functions used to protect against Cross-Site Request Forgery * Functions used to protect against Cross-Site Request Forgery
* The security token has to base on at least one value that an attacker can't know - here it's the session ID and the private key. * The security token has to base on at least one value that an attacker can't know - here it's the session ID and the private key.

View file

@ -23,6 +23,7 @@ namespace Friendica\Factory\Api\Mastodon;
use Friendica\App\BaseURL; use Friendica\App\BaseURL;
use Friendica\BaseFactory; use Friendica\BaseFactory;
use Friendica\Content\ContactSelector;
use Friendica\Content\Text\BBCode; use Friendica\Content\Text\BBCode;
use Friendica\Database\DBA; use Friendica\Database\DBA;
use Friendica\DI; use Friendica\DI;
@ -60,9 +61,9 @@ class Status extends BaseFactory
*/ */
public function createFromUriId(int $uriId, $uid = 0) public function createFromUriId(int $uriId, $uid = 0)
{ {
$fields = ['uri-id', 'uid', 'author-id', 'starred', 'app', 'title', 'body', 'raw-body', 'created', $fields = ['uri-id', 'uid', 'author-id', 'author-link', 'starred', 'app', 'title', 'body', 'raw-body', 'created', 'network',
'thr-parent-id', 'parent-author-id', 'language', 'uri', 'plink', 'private', 'vid', 'gravity']; 'thr-parent-id', 'parent-author-id', 'language', 'uri', 'plink', 'private', 'vid', 'gravity'];
$item = Post::selectFirst($fields, ['uri-id' => $uriId, 'uid' => $uid]); $item = Post::selectFirst($fields, ['uri-id' => $uriId, 'uid' => [0, $uid]], ['order' => ['uid' => true]]);
if (!$item) { if (!$item) {
throw new HTTPException\NotFoundException('Item with URI ID ' . $uriId . 'not found' . ($uid ? ' for user ' . $uid : '.')); throw new HTTPException\NotFoundException('Item with URI ID ' . $uriId . 'not found' . ($uid ? ' for user ' . $uid : '.'));
} }
@ -70,21 +71,21 @@ class Status extends BaseFactory
$account = DI::mstdnAccount()->createFromContactId($item['author-id']); $account = DI::mstdnAccount()->createFromContactId($item['author-id']);
$counts = new \Friendica\Object\Api\Mastodon\Status\Counts( $counts = new \Friendica\Object\Api\Mastodon\Status\Counts(
Post::count(['thr-parent-id' => $uriId, 'uid' => $uid, 'gravity' => GRAVITY_COMMENT]), Post::count(['thr-parent-id' => $uriId, 'gravity' => GRAVITY_COMMENT], [], false),
Post::count(['thr-parent-id' => $uriId, 'uid' => $uid, 'gravity' => GRAVITY_ACTIVITY, 'vid' => Verb::getID(Activity::ANNOUNCE)]), Post::count(['thr-parent-id' => $uriId, 'gravity' => GRAVITY_ACTIVITY, 'vid' => Verb::getID(Activity::ANNOUNCE)], [], false),
Post::count(['thr-parent-id' => $uriId, 'uid' => $uid, 'gravity' => GRAVITY_ACTIVITY, 'vid' => Verb::getID(Activity::LIKE)]) Post::count(['thr-parent-id' => $uriId, 'gravity' => GRAVITY_ACTIVITY, 'vid' => Verb::getID(Activity::LIKE)], [], false)
); );
$userAttributes = new \Friendica\Object\Api\Mastodon\Status\UserAttributes( $userAttributes = new \Friendica\Object\Api\Mastodon\Status\UserAttributes(
Post::exists(['thr-parent-id' => $uriId, 'uid' => $uid, 'origin' => true, 'gravity' => GRAVITY_ACTIVITY, 'vid' => Verb::getID(Activity::LIKE)]), Post::exists(['thr-parent-id' => $uriId, 'uid' => $uid, 'origin' => true, 'gravity' => GRAVITY_ACTIVITY, 'vid' => Verb::getID(Activity::LIKE)]),
Post::exists(['thr-parent-id' => $uriId, 'uid' => $uid, 'origin' => true, 'gravity' => GRAVITY_ACTIVITY, 'vid' => Verb::getID(Activity::ANNOUNCE)]), Post::exists(['thr-parent-id' => $uriId, 'uid' => $uid, 'origin' => true, 'gravity' => GRAVITY_ACTIVITY, 'vid' => Verb::getID(Activity::ANNOUNCE)]),
Post\ThreadUser::getIgnored($uriId, $item['uid']), Post\ThreadUser::getIgnored($uriId, $uid),
(bool)$item['starred'], (bool)$item['starred'],
Post\ThreadUser::getPinned($uriId, $item['uid']) Post\ThreadUser::getPinned($uriId, $uid)
); );
$sensitive = DBA::exists('tag-view', ['uri-id' => $uriId, 'name' => 'nsfw']); $sensitive = DBA::exists('tag-view', ['uri-id' => $uriId, 'name' => 'nsfw']);
$application = new \Friendica\Object\Api\Mastodon\Application($item['app'] ?? ''); $application = new \Friendica\Object\Api\Mastodon\Application($item['app'] ?: ContactSelector::networkToName($item['network'], $item['author-link']));
$mentions = DI::mstdnMention()->createFromUriId($uriId); $mentions = DI::mstdnMention()->createFromUriId($uriId);
$tags = DI::mstdnTag()->createFromUriId($uriId); $tags = DI::mstdnTag()->createFromUriId($uriId);
@ -95,7 +96,7 @@ class Status extends BaseFactory
if ($item['vid'] == Verb::getID(Activity::ANNOUNCE)) { if ($item['vid'] == Verb::getID(Activity::ANNOUNCE)) {
$reshare = $this->createFromUriId($item['thr-parent-id'], $uid)->toArray(); $reshare = $this->createFromUriId($item['thr-parent-id'], $uid)->toArray();
$reshared_item = Post::selectFirst(['title', 'body'], ['uri-id' => $item['thr-parent-id'], 'uid' => $uid]); $reshared_item = Post::selectFirst(['title', 'body'], ['uri-id' => $item['thr-parent-id'], 'uid' => [0, $uid]]);
$item['title'] = $reshared_item['title'] ?? $item['title']; $item['title'] = $reshared_item['title'] ?? $item['title'];
$item['body'] = $reshared_item['body'] ?? $item['body']; $item['body'] = $reshared_item['body'] ?? $item['body'];
} else { } else {

View file

@ -127,12 +127,13 @@ class Post
* Check if post data exists * Check if post data exists
* *
* @param array $condition array of fields for condition * @param array $condition array of fields for condition
* @param bool $user_mode true = post-user-view, false = post-view
* *
* @return boolean Are there rows for that condition? * @return boolean Are there rows for that condition?
* @throws \Exception * @throws \Exception
*/ */
public static function exists($condition) { public static function exists($condition, bool $user_mode = true) {
return DBA::exists('post-user-view', $condition); return DBA::exists($user_mode ? 'post-user-view' : 'post-view', $condition);
} }
/** /**
@ -140,6 +141,7 @@ class Post
* *
* @param array $condition array of fields for condition * @param array $condition array of fields for condition
* @param array $params Array of several parameters * @param array $params Array of several parameters
* @param bool $user_mode true = post-user-view, false = post-view
* *
* @return int * @return int
* *
@ -151,9 +153,9 @@ class Post
* $count = Post::count($condition); * $count = Post::count($condition);
* @throws \Exception * @throws \Exception
*/ */
public static function count(array $condition = [], array $params = []) public static function count(array $condition = [], array $params = [], bool $user_mode = true)
{ {
return DBA::count('post-user-view', $condition, $params); return DBA::count($user_mode ? 'post-user-view' : 'post-view', $condition, $params);
} }
/** /**

View file

@ -21,7 +21,6 @@
namespace Friendica\Model\Post; namespace Friendica\Model\Post;
use Friendica\Content\PageInfo;
use Friendica\Content\Text\BBCode; use Friendica\Content\Text\BBCode;
use Friendica\Core\Logger; use Friendica\Core\Logger;
use Friendica\Core\System; use Friendica\Core\System;
@ -67,6 +66,11 @@ class Media
return; return;
} }
if (DBA::exists('post-media', ['uri-id' => $media['uri-id'], 'preview' => $media['url']])) {
Logger::info('Media already exists as preview', ['uri-id' => $media['uri-id'], 'url' => $media['url'], 'callstack' => System::callstack()]);
return;
}
// "document" has got the lowest priority. So when the same file is both attached as document // "document" has got the lowest priority. So when the same file is both attached as document
// and embedded as picture then we only store the picture or replace the document // and embedded as picture then we only store the picture or replace the document
$found = DBA::selectFirst('post-media', ['type'], ['uri-id' => $media['uri-id'], 'url' => $media['url']]); $found = DBA::selectFirst('post-media', ['type'], ['uri-id' => $media['uri-id'], 'url' => $media['url']]);
@ -499,6 +503,7 @@ class Media
$height = 0; $height = 0;
$selected = ''; $selected = '';
$previews = [];
foreach ($media as $medium) { foreach ($media as $medium) {
foreach ($links as $link) { foreach ($links as $link) {
@ -507,6 +512,17 @@ class Media
} }
} }
// Avoid adding separate media entries for previews
foreach ($previews as $preview) {
if (Strings::compareLink($preview, $medium['url'])) {
continue 2;
}
}
if (!empty($medium['preview'])) {
$previews[] = $medium['preview'];
}
$type = explode('/', current(explode(';', $medium['mimetype']))); $type = explode('/', current(explode(';', $medium['mimetype'])));
if (count($type) < 2) { if (count($type) < 2) {
Logger::info('Unknown MimeType', ['type' => $type, 'media' => $medium]); Logger::info('Unknown MimeType', ['type' => $type, 'media' => $medium]);

View file

@ -46,7 +46,7 @@ class Accounts extends BaseApi
DI::mstdnError()->RecordNotFound(); DI::mstdnError()->RecordNotFound();
} }
$account = DI::mstdnAccount()->createFromContactId($id); $account = DI::mstdnAccount()->createFromContactId($id, self::getCurrentUserID());
System::jsonExit($account); System::jsonExit($account);
} }
} }

View file

@ -0,0 +1,86 @@
<?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\System;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Module\BaseApi;
/**
* @see https://docs.joinmastodon.org/methods/accounts/
*/
class Followers 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()->RecordNotFound();
}
$id = $parameters['id'];
if (!DBA::exists('contact', ['id' => $id, 'uid' => 0])) {
DI::mstdnError()->RecordNotFound();
}
// Return results older than this id
$max_id = (int)!isset($_REQUEST['max_id']) ? 0 : $_REQUEST['max_id'];
// Return results newer than this id
$since_id = (int)!isset($_REQUEST['since_id']) ? 0 : $_REQUEST['since_id'];
// Maximum number of results to return. Defaults to 20.
$limit = (int)!isset($_REQUEST['limit']) ? 20 : $_REQUEST['limit'];
$params = ['order' => ['cid' => true], 'limit' => $limit];
$condition = ['relation-cid' => $id, 'follows' => true];
if (!empty($max_id)) {
$condition = DBA::mergeConditions($condition, ["`cid` < ?", $max_id]);
}
if (!empty($since_id)) {
$condition = DBA::mergeConditions($condition, ["`cid` > ?", $since_id]);
}
if (!empty($min_id)) {
$condition = DBA::mergeConditions($condition, ["`cid` > ?", $min_id]);
$params['order'] = ['cid'];
}
$followers = DBA::select('contact-relation', ['cid'], $condition, $parameters);
while ($follower = DBA::fetch($followers)) {
$accounts[] = DI::mstdnAccount()->createFromContactId($follower['cid'], $uid);
}
DBA::close($followers);
System::jsonExit($accounts);
}
}

View file

@ -0,0 +1,86 @@
<?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\System;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Module\BaseApi;
/**
* @see https://docs.joinmastodon.org/methods/accounts/
*/
class Following 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()->RecordNotFound();
}
$id = $parameters['id'];
if (!DBA::exists('contact', ['id' => $id, 'uid' => 0])) {
DI::mstdnError()->RecordNotFound();
}
// Return results older than this id
$max_id = (int)!isset($_REQUEST['max_id']) ? 0 : $_REQUEST['max_id'];
// Return results newer than this id
$since_id = (int)!isset($_REQUEST['since_id']) ? 0 : $_REQUEST['since_id'];
// Maximum number of results to return. Defaults to 20.
$limit = (int)!isset($_REQUEST['limit']) ? 20 : $_REQUEST['limit'];
$params = ['order' => ['relation-cid' => true], 'limit' => $limit];
$condition = ['cid' => $id, 'follows' => true];
if (!empty($max_id)) {
$condition = DBA::mergeConditions($condition, ["`relation-cid` < ?", $max_id]);
}
if (!empty($since_id)) {
$condition = DBA::mergeConditions($condition, ["`relation-cid` > ?", $since_id]);
}
if (!empty($min_id)) {
$condition = DBA::mergeConditions($condition, ["`relation-cid` > ?", $min_id]);
$params['order'] = ['cid'];
}
$followers = DBA::select('contact-relation', ['relation-cid'], $condition, $parameters);
while ($follower = DBA::fetch($followers)) {
$accounts[] = DI::mstdnAccount()->createFromContactId($follower['relation-cid'], $uid);
}
DBA::close($followers);
System::jsonExit($accounts);
}
}

View file

@ -64,12 +64,23 @@ class Statuses extends BaseApi
$params = ['order' => ['uri-id' => true], 'limit' => $limit]; $params = ['order' => ['uri-id' => true], 'limit' => $limit];
$condition = ['author-id' => $id, 'private' => [Item::PUBLIC, Item::UNLISTED], $uid = self::getCurrentUserID();
'uid' => 0, 'network' => Protocol::FEDERATED];
if (!$uid) {
$condition = ['author-id' => $id, 'private' => [Item::PUBLIC, Item::UNLISTED],
'uid' => 0, 'network' => Protocol::FEDERATED];
} else {
$condition = ["`author-id` = ? AND (`uid` = 0 OR (`uid` = ? AND NOT `global`))", $id, $uid];
}
$condition = DBA::mergeConditions($condition, ["(`gravity` IN (?, ?) OR (`gravity` = ? AND `vid` = ?))", $condition = DBA::mergeConditions($condition, ["(`gravity` IN (?, ?) OR (`gravity` = ? AND `vid` = ?))",
GRAVITY_PARENT, GRAVITY_COMMENT, GRAVITY_ACTIVITY, Verb::getID(Activity::ANNOUNCE)]); GRAVITY_PARENT, GRAVITY_COMMENT, GRAVITY_ACTIVITY, Verb::getID(Activity::ANNOUNCE)]);
if ($only_media) {
$condition = DBA::mergeConditions($condition, ["`uri-id` IN (SELECT `uri-id` FROM `post-media` WHERE `type` IN (?, ?, ?))",
Post\Media::AUDIO, Post\Media::IMAGE, Post\Media::VIDEO]);
}
if (!empty($max_id)) { if (!empty($max_id)) {
$condition = DBA::mergeConditions($condition, ["`uri-id` < ?", $max_id]); $condition = DBA::mergeConditions($condition, ["`uri-id` < ?", $max_id]);
} }
@ -83,11 +94,11 @@ class Statuses extends BaseApi
$params['order'] = ['uri-id']; $params['order'] = ['uri-id'];
} }
$items = Post::selectForUser(0, ['uri-id', 'uid'], $condition, $params); $items = Post::selectForUser($uid, ['uri-id'], $condition, $params);
$statuses = []; $statuses = [];
while ($item = Post::fetch($items)) { while ($item = Post::fetch($items)) {
$statuses[] = DI::mstdnStatus()->createFromUriId($item['uri-id'], $item['uid']); $statuses[] = DI::mstdnStatus()->createFromUriId($item['uri-id'], $uid);
} }
DBA::close($items); DBA::close($items);

View file

@ -0,0 +1,58 @@
<?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\System;
use Friendica\DI;
use Friendica\Model\Contact;
use Friendica\Model\User;
use Friendica\Module\BaseApi;
/**
* @see https://docs.joinmastodon.org/methods/accounts/
*/
class VerifyCredentials extends BaseApi
{
/**
* @param array $parameters
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function rawContent(array $parameters = [])
{
self::login();
$uid = self::getCurrentUserID();
$self = User::getOwnerDataById($uid);
if (empty($self)) {
DI::mstdnError()->RecordNotFound();
}
$cdata = Contact::getPublicAndUserContacID($self['id'], $uid);
if (empty($cdata)) {
DI::mstdnError()->RecordNotFound();
}
// @todo Support the source property,
$account = DI::mstdnAccount()->createFromContactId($cdata['user'], $uid);
System::jsonExit($account);
}
}

View file

@ -0,0 +1,50 @@
<?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;
use Friendica\Core\System;
use Friendica\DI;
use Friendica\Module\BaseApi;
/**
* @see https://docs.joinmastodon.org/methods/statuses/
*/
class Statuses extends BaseApi
{
public static function delete(array $parameters = [])
{
self::unsupported('delete');
}
/**
* @param array $parameters
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function rawContent(array $parameters = [])
{
if (empty($parameters['id'])) {
DI::mstdnError()->RecordNotFound();
}
System::jsonExit(DI::mstdnStatus()->createFromUriId($parameters['id'], self::getCurrentUserID()));
}
}

View file

@ -0,0 +1,56 @@
<?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;
use Friendica\Core\System;
use Friendica\DI;
use Friendica\Model\Contact;
use Friendica\Module\BaseApi;
/**
* @see https://docs.joinmastodon.org/methods/accounts/suggestions/
*/
class Suggestions extends BaseApi
{
/**
* @param array $parameters
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function rawContent(array $parameters = [])
{
self::login();
$uid = self::getCurrentUserID();
// Maximum number of results to return. Defaults to 40.
$limit = (int)!isset($_REQUEST['limit']) ? 40 : $_REQUEST['limit'];
$suggestions = Contact\Relation::getSuggestions($uid, 0, $limit);
$accounts = [];
foreach ($suggestions as $suggestion) {
$accounts[] = DI::mstdnAccount()->createFromContactId($suggestion['id'], $uid);
}
System::jsonExit($accounts);
}
}

View file

@ -0,0 +1,92 @@
<?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\Timelines;
use Friendica\Core\System;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Post;
use Friendica\Module\BaseApi;
use Friendica\Network\HTTPException;
/**
* @see https://docs.joinmastodon.org/methods/timelines/
*/
class Home extends BaseApi
{
/**
* @param array $parameters
* @throws HTTPException\InternalServerErrorException
*/
public static function rawContent(array $parameters = [])
{
self::login();
$uid = self::getCurrentUserID();
// Return results older than id
$max_id = (int)!isset($_REQUEST['max_id']) ? 0 : $_REQUEST['max_id'];
// Return results newer than id
$since_id = (int)!isset($_REQUEST['since_id']) ? 0 : $_REQUEST['since_id'];
// Return results immediately newer than id
$min_id = (int)!isset($_REQUEST['min_id']) ? 0 : $_REQUEST['min_id'];
// Maximum number of results to return. Defaults to 20.
$limit = (int)!isset($_REQUEST['limit']) ? 20 : $_REQUEST['limit'];
// Return only local statuses? Defaults to false.
$local = (bool)!isset($_REQUEST['local']) ? false : ($_REQUEST['local'] == 'true');
$params = ['order' => ['uri-id' => true], 'limit' => $limit];
$condition = ['gravity' => [GRAVITY_PARENT, GRAVITY_COMMENT], 'uid' => $uid];
if ($local) {
$condition = DBA::mergeConditions($condition, ["`uri-id` IN (SELECT `uri-id` FROM `post-user` WHERE `origin`)"]);
}
if (!empty($max_id)) {
$condition = DBA::mergeConditions($condition, ["`uri-id` < ?", $max_id]);
}
if (!empty($since_id)) {
$condition = DBA::mergeConditions($condition, ["`uri-id` > ?", $since_id]);
}
if (!empty($min_id)) {
$condition = DBA::mergeConditions($condition, ["`uri-id` > ?", $min_id]);
$params['order'] = ['uri-id'];
}
$items = Post::selectForUser($uid, ['uri-id'], $condition, $params);
$statuses = [];
while ($item = Post::fetch($items)) {
$statuses[] = DI::mstdnStatus()->createFromUriId($item['uri-id'], $uid);
}
DBA::close($items);
if (!empty($min_id)) {
array_reverse($statuses);
}
System::jsonExit($statuses);
}
}

View file

@ -0,0 +1,91 @@
<?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\Timelines;
use Friendica\Core\System;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Post;
use Friendica\Module\BaseApi;
use Friendica\Network\HTTPException;
/**
* @see https://docs.joinmastodon.org/methods/timelines/
*/
class ListTimeline extends BaseApi
{
/**
* @param array $parameters
* @throws HTTPException\InternalServerErrorException
*/
public static function rawContent(array $parameters = [])
{
self::login();
$uid = self::getCurrentUserID();
if (empty($parameters['id'])) {
DI::mstdnError()->RecordNotFound();
}
// Return results older than id
$max_id = (int)!isset($_REQUEST['max_id']) ? 0 : $_REQUEST['max_id'];
// Return results newer than id
$since_id = (int)!isset($_REQUEST['since_id']) ? 0 : $_REQUEST['since_id'];
// Return results immediately newer than id
$min_id = (int)!isset($_REQUEST['min_id']) ? 0 : $_REQUEST['min_id'];
// Maximum number of results to return. Defaults to 20.
$limit = (int)!isset($_REQUEST['limit']) ? 20 : $_REQUEST['limit'];
$params = ['order' => ['uri-id' => true], 'limit' => $limit];
$condition = ["`uid` = ? AND `gravity` IN (?, ?) AND `contact-id` IN (SELECT `contact-id` FROM `group_member` WHERE `gid` = ?)",
$uid, GRAVITY_PARENT, GRAVITY_COMMENT, $parameters['id']];
if (!empty($max_id)) {
$condition = DBA::mergeConditions($condition, ["`uri-id` < ?", $max_id]);
}
if (!empty($since_id)) {
$condition = DBA::mergeConditions($condition, ["`uri-id` > ?", $since_id]);
}
if (!empty($min_id)) {
$condition = DBA::mergeConditions($condition, ["`uri-id` > ?", $min_id]);
$params['order'] = ['uri-id'];
}
$items = Post::selectForUser($uid, ['uri-id'], $condition, $params);
$statuses = [];
while ($item = Post::fetch($items)) {
$statuses[] = DI::mstdnStatus()->createFromUriId($item['uri-id'], $uid);
}
DBA::close($items);
if (!empty($min_id)) {
array_reverse($statuses);
}
System::jsonExit($statuses);
}
}

View file

@ -69,6 +69,11 @@ class PublicTimeline extends BaseApi
$condition = DBA::mergeConditions($condition, ["NOT `uri-id` IN (SELECT `uri-id` FROM `post-user` WHERE `origin`)"]); $condition = DBA::mergeConditions($condition, ["NOT `uri-id` IN (SELECT `uri-id` FROM `post-user` WHERE `origin`)"]);
} }
if ($only_media) {
$condition = DBA::mergeConditions($condition, ["`uri-id` IN (SELECT `uri-id` FROM `post-media` WHERE `type` IN (?, ?, ?))",
Post\Media::AUDIO, Post\Media::IMAGE, Post\Media::VIDEO]);
}
if (!empty($max_id)) { if (!empty($max_id)) {
$condition = DBA::mergeConditions($condition, ["`uri-id` < ?", $max_id]); $condition = DBA::mergeConditions($condition, ["`uri-id` < ?", $max_id]);
} }

View file

@ -0,0 +1,106 @@
<?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\Timelines;
use Friendica\Core\Protocol;
use Friendica\Core\System;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Post;
use Friendica\Module\BaseApi;
use Friendica\Network\HTTPException;
/**
* @see https://docs.joinmastodon.org/methods/timelines/
*/
class Tag extends BaseApi
{
/**
* @param array $parameters
* @throws HTTPException\InternalServerErrorException
*/
public static function rawContent(array $parameters = [])
{
self::login();
$uid = self::getCurrentUserID();
if (empty($parameters['hashtag'])) {
DI::mstdnError()->RecordNotFound();
}
// If true, return only local statuses. Defaults to false.
$local = (bool)!isset($_REQUEST['local']) ? false : ($_REQUEST['local'] == 'true');
// If true, return only statuses with media attachments. Defaults to false.
$only_media = (bool)!isset($_REQUEST['only_media']) ? false : ($_REQUEST['only_media'] == 'true'); // Currently not supported
// Return results older than this ID.
$max_id = (int)!isset($_REQUEST['max_id']) ? 0 : $_REQUEST['max_id'];
// Return results newer than this ID.
$since_id = (int)!isset($_REQUEST['since_id']) ? 0 : $_REQUEST['since_id'];
// Return results immediately newer than this ID.
$min_id = (int)!isset($_REQUEST['min_id']) ? 0 : $_REQUEST['min_id'];
// Maximum number of results to return. Defaults to 20.
$limit = (int)!isset($_REQUEST['limit']) ? 20 : $_REQUEST['limit'];
$params = ['order' => ['uri-id' => true], 'limit' => $limit];
$condition = ["`name` = ? AND (`uid` = ? OR (`uid` = ? AND NOT `global`))
AND (`network` IN (?, ?, ?, ?) OR (`uid` = ? AND `uid` != ?))",
$parameters['hashtag'], 0, $uid, Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS, $uid, 0];
if ($local) {
$condition = DBA::mergeConditions($condition, ["`uri-id` IN (SELECT `uri-id` FROM `post-user` WHERE `origin`)"]);
}
if ($only_media) {
$condition = DBA::mergeConditions($condition, ["`uri-id` IN (SELECT `uri-id` FROM `post-media` WHERE `type` IN (?, ?, ?))",
Post\Media::AUDIO, Post\Media::IMAGE, Post\Media::VIDEO]);
}
if (!empty($max_id)) {
$condition = DBA::mergeConditions($condition, ["`uri-id` < ?", $max_id]);
}
if (!empty($since_id)) {
$condition = DBA::mergeConditions($condition, ["`uri-id` > ?", $since_id]);
}
if (!empty($min_id)) {
$condition = DBA::mergeConditions($condition, ["`uri-id` > ?", $min_id]);
$params['order'] = ['uri-id'];
}
$items = DBA::select('tag-search-view', ['uri-id'], $condition, $params);
$statuses = [];
while ($item = Post::fetch($items)) {
$statuses[] = DI::mstdnStatus()->createFromUriId($item['uri-id'], $uid);
}
DBA::close($items);
if (!empty($min_id)) {
array_reverse($statuses);
}
System::jsonExit($statuses);
}
}

View file

@ -21,9 +21,6 @@
namespace Friendica\Module\Api\Mastodon; namespace Friendica\Module\Api\Mastodon;
use Friendica\Core\Logger;
use Friendica\Core\System;
use Friendica\DI;
use Friendica\Module\BaseApi; use Friendica\Module\BaseApi;
/** /**
@ -31,17 +28,48 @@ use Friendica\Module\BaseApi;
*/ */
class Unimplemented extends BaseApi class Unimplemented extends BaseApi
{ {
/**
* @param array $parameters
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function delete(array $parameters = [])
{
self::unsupported('delete');
}
/**
* @param array $parameters
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function patch(array $parameters = [])
{
self::unsupported('patch');
}
/**
* @param array $parameters
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function post(array $parameters = [])
{
self::unsupported('post');
}
/**
* @param array $parameters
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function put(array $parameters = [])
{
self::unsupported('put');
}
/** /**
* @param array $parameters * @param array $parameters
* @throws \Friendica\Network\HTTPException\InternalServerErrorException * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/ */
public static function rawContent(array $parameters = []) public static function rawContent(array $parameters = [])
{ {
$path = DI::args()->getQueryString(); self::unsupported('get');
Logger::info('Unimplemented API call', ['path' => $path]);
$error = DI::l10n()->t('API endpoint "%s" is not implemented', $path);
$error_description = DI::l10n()->t('The API endpoint is currently not implemented but might be in the future.');;
$errorobj = new \Friendica\Object\Api\Mastodon\Error($error, $error_description);
System::jsonError(501, $errorobj->toArray());
} }
} }

View file

@ -22,6 +22,8 @@
namespace Friendica\Module; namespace Friendica\Module;
use Friendica\BaseModule; use Friendica\BaseModule;
use Friendica\Core\Logger;
use Friendica\Core\System;
use Friendica\DI; use Friendica\DI;
use Friendica\Network\HTTPException; use Friendica\Network\HTTPException;
@ -53,6 +55,32 @@ class BaseApi extends BaseModule
} }
} }
public static function delete(array $parameters = [])
{
if (!api_user()) {
throw new HTTPException\UnauthorizedException(DI::l10n()->t('Permission denied.'));
}
$a = DI::app();
if (!empty($a->user['uid']) && $a->user['uid'] != api_user()) {
throw new HTTPException\ForbiddenException(DI::l10n()->t('Permission denied.'));
}
}
public static function patch(array $parameters = [])
{
if (!api_user()) {
throw new HTTPException\UnauthorizedException(DI::l10n()->t('Permission denied.'));
}
$a = DI::app();
if (!empty($a->user['uid']) && $a->user['uid'] != api_user()) {
throw new HTTPException\ForbiddenException(DI::l10n()->t('Permission denied.'));
}
}
public static function post(array $parameters = []) public static function post(array $parameters = [])
{ {
if (!api_user()) { if (!api_user()) {
@ -66,6 +94,29 @@ class BaseApi extends BaseModule
} }
} }
public static function put(array $parameters = [])
{
if (!api_user()) {
throw new HTTPException\UnauthorizedException(DI::l10n()->t('Permission denied.'));
}
$a = DI::app();
if (!empty($a->user['uid']) && $a->user['uid'] != api_user()) {
throw new HTTPException\ForbiddenException(DI::l10n()->t('Permission denied.'));
}
}
public static function unsupported(string $method = 'all')
{
$path = DI::args()->getQueryString();
Logger::info('Unimplemented API call', ['path' => $path, 'method' => $method]);
$error = DI::l10n()->t('API endpoint %s %s is not implemented', strtoupper($method), $path);
$error_description = DI::l10n()->t('The API endpoint is currently not implemented but might be in the future.');;
$errorobj = new \Friendica\Object\Api\Mastodon\Error($error, $error_description);
System::jsonError(501, $errorobj->toArray());
}
/** /**
* Log in user via OAuth1 or Simple HTTP Auth. * Log in user via OAuth1 or Simple HTTP Auth.
* *

View file

@ -60,8 +60,8 @@ return [
'/accounts' => [Module\Api\Mastodon\Unimplemented::class, [ R::POST]], '/accounts' => [Module\Api\Mastodon\Unimplemented::class, [ R::POST]],
'/accounts/{id:\d+}' => [Module\Api\Mastodon\Accounts::class, [R::GET ]], '/accounts/{id:\d+}' => [Module\Api\Mastodon\Accounts::class, [R::GET ]],
'/accounts/{id:\d+}/statuses' => [Module\Api\Mastodon\Accounts\Statuses::class, [R::GET ]], '/accounts/{id:\d+}/statuses' => [Module\Api\Mastodon\Accounts\Statuses::class, [R::GET ]],
'/accounts/{id:\d+}/followers' => [Module\Api\Mastodon\Unimplemented::class, [R::GET ]], '/accounts/{id:\d+}/followers' => [Module\Api\Mastodon\Accounts\Followers::class, [R::GET ]],
'/accounts/{id:\d+}/following' => [Module\Api\Mastodon\Unimplemented::class, [R::GET ]], '/accounts/{id:\d+}/following' => [Module\Api\Mastodon\Accounts\Followers::class, [R::GET ]],
'/accounts/{id:\d+}/lists' => [Module\Api\Mastodon\Unimplemented::class, [R::GET ]], '/accounts/{id:\d+}/lists' => [Module\Api\Mastodon\Unimplemented::class, [R::GET ]],
'/accounts/{id:\d+}/identity_proofs' => [Module\Api\Mastodon\Unimplemented::class, [R::GET ]], '/accounts/{id:\d+}/identity_proofs' => [Module\Api\Mastodon\Unimplemented::class, [R::GET ]],
'/accounts/{id:\d+}/follow' => [Module\Api\Mastodon\Unimplemented::class, [ R::POST]], '/accounts/{id:\d+}/follow' => [Module\Api\Mastodon\Unimplemented::class, [ R::POST]],
@ -75,7 +75,7 @@ return [
'/accounts/{id:\d+}/note' => [Module\Api\Mastodon\Unimplemented::class, [ R::POST]], '/accounts/{id:\d+}/note' => [Module\Api\Mastodon\Unimplemented::class, [ R::POST]],
'/accounts/relationships' => [Module\Api\Mastodon\Unimplemented::class, [R::GET ]], '/accounts/relationships' => [Module\Api\Mastodon\Unimplemented::class, [R::GET ]],
'/accounts/search' => [Module\Api\Mastodon\Unimplemented::class, [R::GET ]], '/accounts/search' => [Module\Api\Mastodon\Unimplemented::class, [R::GET ]],
'/accounts/verify_credentials' => [Module\Api\Mastodon\Unimplemented::class, [R::GET ]], '/accounts/verify_credentials' => [Module\Api\Mastodon\Accounts\VerifyCredentials::class, [R::GET ]],
'/accounts/update_credentials' => [Module\Api\Mastodon\Unimplemented::class, [R::PATCH ]], '/accounts/update_credentials' => [Module\Api\Mastodon\Unimplemented::class, [R::PATCH ]],
'/admin/accounts' => [Module\Api\Mastodon\Unimplemented::class, [R::GET ]], '/admin/accounts' => [Module\Api\Mastodon\Unimplemented::class, [R::GET ]],
'/admin/accounts/{id:\d+}' => [Module\Api\Mastodon\Unimplemented::class, [R::GET ]], '/admin/accounts/{id:\d+}' => [Module\Api\Mastodon\Unimplemented::class, [R::GET ]],
@ -126,7 +126,7 @@ return [
'/scheduled_statuses' => [Module\Api\Mastodon\Unimplemented::class, [R::GET ]], '/scheduled_statuses' => [Module\Api\Mastodon\Unimplemented::class, [R::GET ]],
'/scheduled_statuses/{id:\d+}' => [Module\Api\Mastodon\Unimplemented::class, [R::GET, R::PUT, R::DELETE]], '/scheduled_statuses/{id:\d+}' => [Module\Api\Mastodon\Unimplemented::class, [R::GET, R::PUT, R::DELETE]],
'/statuses' => [Module\Api\Mastodon\Unimplemented::class, [ R::POST]], '/statuses' => [Module\Api\Mastodon\Unimplemented::class, [ R::POST]],
'/statuses/{id:\d+}' => [Module\Api\Mastodon\Unimplemented::class, [R::GET, R::DELETE]], '/statuses/{id:\d+}' => [Module\Api\Mastodon\Statuses::class, [R::GET, R::DELETE]],
'/statuses/{id:\d+}/context' => [Module\Api\Mastodon\Unimplemented::class, [R::GET ]], '/statuses/{id:\d+}/context' => [Module\Api\Mastodon\Unimplemented::class, [R::GET ]],
'/statuses/{id:\d+}/reblogged_by' => [Module\Api\Mastodon\Unimplemented::class, [R::GET ]], '/statuses/{id:\d+}/reblogged_by' => [Module\Api\Mastodon\Unimplemented::class, [R::GET ]],
'/statuses/{id:\d+}/favourited_by' => [Module\Api\Mastodon\Unimplemented::class, [R::GET ]], '/statuses/{id:\d+}/favourited_by' => [Module\Api\Mastodon\Unimplemented::class, [R::GET ]],
@ -140,12 +140,12 @@ return [
'/statuses/{id:\d+}/unmute' => [Module\Api\Mastodon\Unimplemented::class, [ R::POST]], '/statuses/{id:\d+}/unmute' => [Module\Api\Mastodon\Unimplemented::class, [ R::POST]],
'/statuses/{id:\d+}/pin' => [Module\Api\Mastodon\Unimplemented::class, [ R::POST]], '/statuses/{id:\d+}/pin' => [Module\Api\Mastodon\Unimplemented::class, [ R::POST]],
'/statuses/{id:\d+}/unpin' => [Module\Api\Mastodon\Unimplemented::class, [ R::POST]], '/statuses/{id:\d+}/unpin' => [Module\Api\Mastodon\Unimplemented::class, [ R::POST]],
'/suggestions' => [Module\Api\Mastodon\Unimplemented::class, [R::GET ]], '/suggestions' => [Module\Api\Mastodon\Suggestions::class, [R::GET ]],
'/suggestions/{id:\d+}' => [Module\Api\Mastodon\Unimplemented::class, [R::DELETE ]], '/suggestions/{id:\d+}' => [Module\Api\Mastodon\Unimplemented::class, [R::DELETE ]],
'/timelines/home' => [Module\Api\Mastodon\Unimplemented::class, [R::GET ]], '/timelines/home' => [Module\Api\Mastodon\Timelines\Home::class, [R::GET ]],
'/timelines/list/{id:\d+}' => [Module\Api\Mastodon\Unimplemented::class, [R::GET ]], '/timelines/list/{id:\d+}' => [Module\Api\Mastodon\Timelines\ListTimeline::class, [R::GET ]],
'/timelines/public' => [Module\Api\Mastodon\Timelines\PublicTimeline::class, [R::GET ]], '/timelines/public' => [Module\Api\Mastodon\Timelines\PublicTimeline::class, [R::GET ]],
'/timelines/tag/{hashtag}' => [Module\Api\Mastodon\Unimplemented::class, [R::GET ]], '/timelines/tag/{hashtag}' => [Module\Api\Mastodon\Timelines\Tag::class, [R::GET ]],
'/trends' => [Module\Api\Mastodon\Trends::class, [R::GET ]], '/trends' => [Module\Api\Mastodon\Trends::class, [R::GET ]],
], ],
'/v2' => [ '/v2' => [

View file

@ -8,7 +8,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: 2021.06-dev\n" "Project-Id-Version: 2021.06-dev\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2021-05-04 09:08-0400\n" "POT-Creation-Date: 2021-05-08 12:25+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
@ -829,7 +829,10 @@ msgstr ""
#: mod/unfollow.php:82 mod/wall_attach.php:78 mod/wall_attach.php:81 #: mod/unfollow.php:82 mod/wall_attach.php:78 mod/wall_attach.php:81
#: mod/wall_upload.php:99 mod/wall_upload.php:102 mod/wallmessage.php:35 #: mod/wall_upload.php:99 mod/wall_upload.php:102 mod/wallmessage.php:35
#: mod/wallmessage.php:59 mod/wallmessage.php:96 mod/wallmessage.php:120 #: mod/wallmessage.php:59 mod/wallmessage.php:96 mod/wallmessage.php:120
#: src/Module/Attach.php:56 src/Module/BaseApi.php:59 src/Module/BaseApi.php:65 #: src/Module/Attach.php:56 src/Module/BaseApi.php:61 src/Module/BaseApi.php:67
#: src/Module/BaseApi.php:74 src/Module/BaseApi.php:80
#: src/Module/BaseApi.php:87 src/Module/BaseApi.php:93
#: src/Module/BaseApi.php:100 src/Module/BaseApi.php:106
#: src/Module/BaseNotifications.php:88 src/Module/Contact.php:385 #: src/Module/BaseNotifications.php:88 src/Module/Contact.php:385
#: src/Module/Contact/Advanced.php:43 src/Module/Delegation.php:118 #: src/Module/Contact/Advanced.php:43 src/Module/Delegation.php:118
#: src/Module/FollowConfirm.php:16 src/Module/FriendSuggest.php:44 #: src/Module/FollowConfirm.php:16 src/Module/FriendSuggest.php:44
@ -1163,8 +1166,8 @@ msgstr ""
#: mod/dfrn_request.php:600 mod/display.php:179 mod/photos.php:836 #: mod/dfrn_request.php:600 mod/display.php:179 mod/photos.php:836
#: mod/videos.php:129 src/Module/Conversation/Community.php:188 #: mod/videos.php:129 src/Module/Conversation/Community.php:188
#: src/Module/Debug/Probe.php:39 src/Module/Debug/WebFinger.php:38 #: src/Module/Debug/Probe.php:39 src/Module/Debug/WebFinger.php:38
#: src/Module/Directory.php:49 src/Module/Search/Index.php:51 #: src/Module/Directory.php:49 src/Module/Search/Index.php:50
#: src/Module/Search/Index.php:56 #: src/Module/Search/Index.php:55
msgid "Public access denied." msgid "Public access denied."
msgstr "" msgstr ""
@ -3043,31 +3046,31 @@ msgstr ""
msgid "Page not found." msgid "Page not found."
msgstr "" msgstr ""
#: src/BaseModule.php:150 #: src/BaseModule.php:180
msgid "" msgid ""
"The form security token was not correct. This probably happened because the " "The form security token was not correct. This probably happened because the "
"form has been opened for too long (>3 hours) before submitting it." "form has been opened for too long (>3 hours) before submitting it."
msgstr "" msgstr ""
#: src/BaseModule.php:179 #: src/BaseModule.php:209
msgid "All contacts" msgid "All contacts"
msgstr "" msgstr ""
#: src/BaseModule.php:184 src/Content/Widget.php:238 src/Core/ACL.php:183 #: src/BaseModule.php:214 src/Content/Widget.php:238 src/Core/ACL.php:183
#: src/Module/Contact.php:860 src/Module/PermissionTooltip.php:77 #: src/Module/Contact.php:860 src/Module/PermissionTooltip.php:77
#: src/Module/PermissionTooltip.php:99 #: src/Module/PermissionTooltip.php:99
msgid "Followers" msgid "Followers"
msgstr "" msgstr ""
#: src/BaseModule.php:189 src/Content/Widget.php:239 src/Module/Contact.php:861 #: src/BaseModule.php:219 src/Content/Widget.php:239 src/Module/Contact.php:861
msgid "Following" msgid "Following"
msgstr "" msgstr ""
#: src/BaseModule.php:194 src/Content/Widget.php:240 src/Module/Contact.php:862 #: src/BaseModule.php:224 src/Content/Widget.php:240 src/Module/Contact.php:862
msgid "Mutual friends" msgid "Mutual friends"
msgstr "" msgstr ""
#: src/BaseModule.php:202 #: src/BaseModule.php:232
msgid "Common" msgid "Common"
msgstr "" msgstr ""
@ -3504,7 +3507,7 @@ msgid "Addon applications, utilities, games"
msgstr "" msgstr ""
#: src/Content/Nav.php:220 src/Content/Text/HTML.php:899 #: src/Content/Nav.php:220 src/Content/Text/HTML.php:899
#: src/Module/Search/Index.php:100 #: src/Module/Search/Index.php:99
msgid "Search" msgid "Search"
msgstr "" msgstr ""
@ -3662,39 +3665,39 @@ msgstr ""
msgid "last" msgid "last"
msgstr "" msgstr ""
#: src/Content/Text/BBCode.php:941 src/Content/Text/BBCode.php:1615 #: src/Content/Text/BBCode.php:942 src/Content/Text/BBCode.php:1605
#: src/Content/Text/BBCode.php:1616 #: src/Content/Text/BBCode.php:1606
msgid "Image/photo" msgid "Image/photo"
msgstr "" msgstr ""
#: src/Content/Text/BBCode.php:1063 #: src/Content/Text/BBCode.php:1064
#, php-format #, php-format
msgid "" msgid ""
"<a href=\"%1$s\" target=\"_blank\" rel=\"noopener noreferrer\">%2$s</a> %3$s" "<a href=\"%1$s\" target=\"_blank\" rel=\"noopener noreferrer\">%2$s</a> %3$s"
msgstr "" msgstr ""
#: src/Content/Text/BBCode.php:1088 src/Model/Item.php:3020 #: src/Content/Text/BBCode.php:1089 src/Model/Item.php:3024
#: src/Model/Item.php:3026 #: src/Model/Item.php:3030
msgid "link to source" msgid "link to source"
msgstr "" msgstr ""
#: src/Content/Text/BBCode.php:1533 src/Content/Text/HTML.php:951 #: src/Content/Text/BBCode.php:1523 src/Content/Text/HTML.php:951
msgid "Click to open/close" msgid "Click to open/close"
msgstr "" msgstr ""
#: src/Content/Text/BBCode.php:1564 #: src/Content/Text/BBCode.php:1554
msgid "$1 wrote:" msgid "$1 wrote:"
msgstr "" msgstr ""
#: src/Content/Text/BBCode.php:1618 src/Content/Text/BBCode.php:1619 #: src/Content/Text/BBCode.php:1608 src/Content/Text/BBCode.php:1609
msgid "Encrypted content" msgid "Encrypted content"
msgstr "" msgstr ""
#: src/Content/Text/BBCode.php:1832 #: src/Content/Text/BBCode.php:1822
msgid "Invalid source protocol" msgid "Invalid source protocol"
msgstr "" msgstr ""
#: src/Content/Text/BBCode.php:1847 #: src/Content/Text/BBCode.php:1837
msgid "Invalid link protocol" msgid "Invalid link protocol"
msgstr "" msgstr ""
@ -4846,15 +4849,15 @@ msgstr ""
msgid "Content warning: %s" msgid "Content warning: %s"
msgstr "" msgstr ""
#: src/Model/Item.php:2985 #: src/Model/Item.php:2989
msgid "bytes" msgid "bytes"
msgstr "" msgstr ""
#: src/Model/Item.php:3014 #: src/Model/Item.php:3018
msgid "View on separate page" msgid "View on separate page"
msgstr "" msgstr ""
#: src/Model/Item.php:3015 #: src/Model/Item.php:3019
msgid "view on separate page" msgid "view on separate page"
msgstr "" msgstr ""
@ -7218,16 +7221,6 @@ msgstr ""
msgid "Deny" msgid "Deny"
msgstr "" msgstr ""
#: src/Module/Api/Mastodon/Unimplemented.php:42
#, php-format
msgid "API endpoint \"%s\" is not implemented"
msgstr ""
#: src/Module/Api/Mastodon/Unimplemented.php:43
msgid ""
"The API endpoint is currently not implemented but might be in the future."
msgstr ""
#: src/Module/Api/Twitter/ContactEndpoint.php:65 src/Module/Contact.php:400 #: src/Module/Api/Twitter/ContactEndpoint.php:65 src/Module/Contact.php:400
msgid "Contact not found" msgid "Contact not found"
msgstr "" msgstr ""
@ -7330,6 +7323,16 @@ msgstr ""
msgid "User registrations waiting for confirmation" msgid "User registrations waiting for confirmation"
msgstr "" msgstr ""
#: src/Module/BaseApi.php:114
#, php-format
msgid "API endpoint %s %s is not implemented"
msgstr ""
#: src/Module/BaseApi.php:115
msgid ""
"The API endpoint is currently not implemented but might be in the future."
msgstr ""
#: src/Module/BaseProfile.php:55 src/Module/Contact.php:947 #: src/Module/BaseProfile.php:55 src/Module/Contact.php:947
msgid "Profile Details" msgid "Profile Details"
msgstr "" msgstr ""
@ -7684,7 +7687,7 @@ msgstr ""
msgid "Search your contacts" msgid "Search your contacts"
msgstr "" msgstr ""
#: src/Module/Contact.php:883 src/Module/Search/Index.php:193 #: src/Module/Contact.php:883 src/Module/Search/Index.php:192
#, php-format #, php-format
msgid "Results for: %s" msgid "Results for: %s"
msgstr "" msgstr ""
@ -7924,8 +7927,8 @@ msgstr ""
msgid "Hide" msgid "Hide"
msgstr "" msgstr ""
#: src/Module/Conversation/Community.php:149 src/Module/Search/Index.php:140 #: src/Module/Conversation/Community.php:149 src/Module/Search/Index.php:139
#: src/Module/Search/Index.php:180 #: src/Module/Search/Index.php:179
msgid "No results." msgid "No results."
msgstr "" msgstr ""
@ -9107,15 +9110,15 @@ msgid ""
"or <strong>%s</strong> directly on your system." "or <strong>%s</strong> directly on your system."
msgstr "" msgstr ""
#: src/Module/Search/Index.php:55 #: src/Module/Search/Index.php:54
msgid "Only logged in users are permitted to perform a search." msgid "Only logged in users are permitted to perform a search."
msgstr "" msgstr ""
#: src/Module/Search/Index.php:77 #: src/Module/Search/Index.php:76
msgid "Only one search per minute is permitted for not logged in users." msgid "Only one search per minute is permitted for not logged in users."
msgstr "" msgstr ""
#: src/Module/Search/Index.php:191 #: src/Module/Search/Index.php:190
#, php-format #, php-format
msgid "Items tagged with: %s" msgid "Items tagged with: %s"
msgstr "" msgstr ""