mirror of
https://github.com/friendica/friendica
synced 2025-04-19 05:50:10 +00:00
API: Tredning statuses added
This commit is contained in:
parent
6b36bd893b
commit
c00004f6ea
8 changed files with 85 additions and 12 deletions
57
src/Module/Api/Mastodon/Trends/Statuses.php
Normal file
57
src/Module/Api/Mastodon/Trends/Statuses.php
Normal file
|
@ -0,0 +1,57 @@
|
|||
<?php
|
||||
/**
|
||||
* @copyright Copyright (C) 2010-2022, 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\Trends;
|
||||
|
||||
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\Util\DateTimeFormat;
|
||||
|
||||
/**
|
||||
* @see https://docs.joinmastodon.org/methods/trends/#statuses
|
||||
*/
|
||||
class Statuses extends BaseApi
|
||||
{
|
||||
/**
|
||||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||
*/
|
||||
protected function rawContent(array $request = [])
|
||||
{
|
||||
$request = $this->getRequest([
|
||||
'limit' => 10, // Maximum number of results to return. Defaults to 10.
|
||||
], $request);
|
||||
|
||||
$trending = [];
|
||||
$condition = ["NOT `private` AND `commented` > ?", DateTimeFormat::utc('now -1 day')];
|
||||
$condition = DBA::mergeConditions($condition, ['network' => Protocol::FEDERATED]);
|
||||
$statuses = Post::selectPostThread(['uri-id'], $condition, ['limit' => $request['limit'], 'order' => ['total-comments' => true]]);
|
||||
while ($status = Post::fetch($statuses)) {
|
||||
$trending[] = DI::mstdnStatus()->createFromUriId($status['uri-id']);
|
||||
}
|
||||
DBA::close($statuses);
|
||||
|
||||
System::jsonExit($trending);
|
||||
}
|
||||
}
|
|
@ -19,7 +19,7 @@
|
|||
*
|
||||
*/
|
||||
|
||||
namespace Friendica\Module\Api\Mastodon;
|
||||
namespace Friendica\Module\Api\Mastodon\Trends;
|
||||
|
||||
use Friendica\Core\System;
|
||||
use Friendica\DI;
|
||||
|
@ -29,7 +29,7 @@ use Friendica\Module\BaseApi;
|
|||
/**
|
||||
* @see https://docs.joinmastodon.org/methods/instance/trends/
|
||||
*/
|
||||
class Trends extends BaseApi
|
||||
class Tags extends BaseApi
|
||||
{
|
||||
/**
|
||||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
Loading…
Add table
Add a link
Reference in a new issue