The API is now using the router

This commit is contained in:
Michael 2021-11-08 07:23:18 +00:00
parent aeb75c19a3
commit 789361de5f
4 changed files with 154 additions and 32 deletions

View file

@ -0,0 +1,49 @@
<?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\Friendica;
use Friendica\DI;
use Friendica\Module\BaseApi;
/**
* api/friendica
*
* @package Friendica\Module\Api\Friendica
*/
class Index extends BaseApi
{
public static function post(array $parameters = [])
{
self::checkAllowedScope(self::SCOPE_WRITE);
}
public static function delete(array $parameters = [])
{
self::checkAllowedScope(self::SCOPE_WRITE);
}
public static function rawContent(array $parameters = [])
{
echo api_call(DI::app());
exit();
}
}

View file

@ -21,6 +21,7 @@
namespace Friendica\Module\Api\Mastodon\Timelines;
use Friendica\Core\Logger;
use Friendica\Core\Protocol;
use Friendica\Core\System;
use Friendica\Database\DBA;
@ -100,7 +101,11 @@ class PublicTimeline extends BaseApi
$statuses = [];
while ($item = Post::fetch($items)) {
self::setBoundaries($item['uri-id']);
$statuses[] = DI::mstdnStatus()->createFromUriId($item['uri-id'], $uid);
try {
$statuses[] = DI::mstdnStatus()->createFromUriId($item['uri-id'], $uid);
} catch (\Throwable $th) {
Logger::info('Post not fetchable', ['uri-id' => $item['uri-id'], 'uid' => $uid, 'error' => $th]);
}
}
DBA::close($items);