Add link headers to Mastodon trending endpoints
This commit is contained in:
parent
2754cdc5d6
commit
9187723263
|
@ -41,7 +41,7 @@ class Links extends BaseApi
|
||||||
{
|
{
|
||||||
$request = $this->getRequest([
|
$request = $this->getRequest([
|
||||||
'limit' => 10, // Maximum number of results to return. Defaults to 10.
|
'limit' => 10, // Maximum number of results to return. Defaults to 10.
|
||||||
'offset' => 0, // Offset page, Defaults to 0.
|
'offset' => 0, // Offset in set, Defaults to 0.
|
||||||
], $request);
|
], $request);
|
||||||
|
|
||||||
$condition = ["EXISTS(SELECT `id` FROM `post-media` WHERE `post-media`.`uri-id` = `post-thread-view`.`uri-id` AND `type` = ? AND NOT `name` IS NULL AND NOT `description` IS NULL) AND NOT `private` AND `commented` > ? AND `created` > ?",
|
$condition = ["EXISTS(SELECT `id` FROM `post-media` WHERE `post-media`.`uri-id` = `post-thread-view`.`uri-id` AND `type` = ? AND NOT `name` IS NULL AND NOT `description` IS NULL) AND NOT `private` AND `commented` > ? AND `created` > ?",
|
||||||
|
@ -56,6 +56,10 @@ class Links extends BaseApi
|
||||||
}
|
}
|
||||||
DBA::close($statuses);
|
DBA::close($statuses);
|
||||||
|
|
||||||
|
if (!empty($trending)) {
|
||||||
|
self::setLinkHeaderByOffsetLimit($request['offset'], $request['limit']);
|
||||||
|
}
|
||||||
|
|
||||||
System::jsonExit($trending);
|
System::jsonExit($trending);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,7 @@ class Statuses extends BaseApi
|
||||||
|
|
||||||
$request = $this->getRequest([
|
$request = $this->getRequest([
|
||||||
'limit' => 10, // Maximum number of results to return. Defaults to 10.
|
'limit' => 10, // Maximum number of results to return. Defaults to 10.
|
||||||
'offset' => 0, // Offset page, Defaults to 0.
|
'offset' => 0, // Offset in set, Defaults to 0.
|
||||||
], $request);
|
], $request);
|
||||||
|
|
||||||
$condition = ["NOT `private` AND `commented` > ? AND `created` > ?", DateTimeFormat::utc('now -1 day'), DateTimeFormat::utc('now -1 week')];
|
$condition = ["NOT `private` AND `commented` > ? AND `created` > ?", DateTimeFormat::utc('now -1 day'), DateTimeFormat::utc('now -1 week')];
|
||||||
|
@ -63,6 +63,10 @@ class Statuses extends BaseApi
|
||||||
}
|
}
|
||||||
DBA::close($statuses);
|
DBA::close($statuses);
|
||||||
|
|
||||||
|
if (!empty($trending)) {
|
||||||
|
self::setLinkHeaderByOffsetLimit($request['offset'], $request['limit']);
|
||||||
|
}
|
||||||
|
|
||||||
System::jsonExit($trending);
|
System::jsonExit($trending);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,7 +38,7 @@ class Tags extends BaseApi
|
||||||
{
|
{
|
||||||
$request = $this->getRequest([
|
$request = $this->getRequest([
|
||||||
'limit' => 20, // Maximum number of results to return. Defaults to 20.
|
'limit' => 20, // Maximum number of results to return. Defaults to 20.
|
||||||
'offset' => 0, // Offset page. Defaults to 0.
|
'offset' => 0, // Offset in set. Defaults to 0.
|
||||||
'friendica_local' => false, // Whether to return local tag trends instead of global, defaults to false
|
'friendica_local' => false, // Whether to return local tag trends instead of global, defaults to false
|
||||||
], $request);
|
], $request);
|
||||||
|
|
||||||
|
@ -56,6 +56,10 @@ class Tags extends BaseApi
|
||||||
$trending[] = $hashtag->toArray();
|
$trending[] = $hashtag->toArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
System::jsonExit(array_slice($trending, 0, $request['limit']));
|
if (!empty($trending)) {
|
||||||
|
self::setLinkHeaderByOffsetLimit($request['offset'], $request['limit']);
|
||||||
|
}
|
||||||
|
|
||||||
|
System::jsonExit($trending);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user