add public timeline for mastodon api

Signed-off-by: Robin Appelman <robin@icewind.nl>
pull/1090/head
Robin Appelman 2020-10-22 15:01:15 +02:00
rodzic d045973449
commit 8c070ee248
3 zmienionych plików z 40 dodań i 8 usunięć

Wyświetl plik

@ -169,12 +169,12 @@ class Timeline extends ExtendedBase {
break;
case 'local':
$stream = $this->streamRequest->getTimelineGlobal(0, $this->count, true);
$stream = $this->streamRequest->getTimelineGlobal_dep(0, $this->count, true);
$this->outputStreams($stream);
break;
case 'global':
$stream = $this->streamRequest->getTimelineGlobal(0, $this->count, false);
$stream = $this->streamRequest->getTimelineGlobal_dep(0, $this->count, false);
$this->outputStreams($stream);
break;

Wyświetl plik

@ -412,7 +412,7 @@ class StreamRequest extends StreamRequestBuilder {
*
* @return Stream[]
* @throws DateTimeException
* @deprecated - use GetTimeline()
* @deprecated - use getTimelineHome()
*/
public function getTimelineHome_dep(
int $since = 0, int $limit = 5, int $format = Stream::FORMAT_ACTIVITYPUB
@ -521,6 +521,37 @@ class StreamRequest extends StreamRequestBuilder {
return $this->getStreamsFromRequest($qb);
}
/**
* Should returns:
* * All local public/federated posts
*
* @param TimelineOptions $options
*
* @return Stream[]
* @throws DateTimeException
*/
public function getTimelinePublic(TimelineOptions $options): array {
$qb = $this->getStreamSelectSql($options->getFormat());
$qb->paginate($options);
$qb->limitToLocal($options->isLocal());
$qb->limitToType(Note::TYPE);
$qb->linkToCacheActors('ca', 's.attributed_to_prim');
$qb->leftJoinStreamAction();
$qb->selectDestFollowing('sd', '');
$qb->innerJoinSteamDest('recipient', 'id_prim', 'sd', 's');
$qb->limitToDest(ACore::CONTEXT_PUBLIC, 'recipient', 'to', 'sd');
$result = $this->getStreamsFromRequest($qb);
if ($options->isInverted()) {
$result = array_reverse($result);
}
return $result;
}
/**
* Should returns:
@ -532,8 +563,9 @@ class StreamRequest extends StreamRequestBuilder {
*
* @return Stream[]
* @throws DateTimeException
* @deprecated - use getTimelinePublic()
*/
public function getTimelineGlobal(int $since = 0, int $limit = 5, bool $localOnly = true
public function getTimelineGlobal_dep(int $since = 0, int $limit = 5, bool $localOnly = true
): array {
$qb = $this->getStreamSelectSql();
$qb->limitPaginate($since, $limit);

Wyświetl plik

@ -426,9 +426,9 @@ class StreamService {
public function getTimeline(TimelineOptions $options): array {
if ($options->getTimeline() === 'home') {
return $this->streamRequest->getTimelineHome($options);
} else if ($options->getTimeline() === 'public') {
return $this->streamRequest->getTimelinePublic($options);
}
}
/**
@ -480,7 +480,7 @@ class StreamService {
* @deprecated
*/
public function getStreamLocalTimeline(int $since = 0, int $limit = 5): array {
return $this->streamRequest->getTimelineGlobal($since, $limit, true);
return $this->streamRequest->getTimelineGlobal_dep($since, $limit, true);
}
@ -518,7 +518,7 @@ class StreamService {
* @throws Exception
*/
public function getStreamGlobalTimeline(int $since = 0, int $limit = 5): array {
return $this->streamRequest->getTimelineGlobal($since, $limit, false);
return $this->streamRequest->getTimelineGlobal_dep($since, $limit, false);
}