diff options
author | Maxence Lange <maxence@artificial-owl.com> | 2023-03-16 13:02:10 -0100 |
---|---|---|
committer | Maxence Lange <maxence@artificial-owl.com> | 2023-03-16 13:02:10 -0100 |
commit | 35641aa2eb229d939bc76aad48984333a101902d (patch) | |
tree | 2c0c7745a8d79a909d65a52287103dbe193444d9 /lib | |
parent | 521447b4f7dcc0eabeb7c44710ad7c0d1716c684 (diff) |
hashtags timeline
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Command/Timeline.php | 9 | ||||
-rw-r--r-- | lib/Db/StreamRequest.php | 16 |
2 files changed, 21 insertions, 4 deletions
diff --git a/lib/Command/Timeline.php b/lib/Command/Timeline.php index 3eee7c3f..e2144088 100644 --- a/lib/Command/Timeline.php +++ b/lib/Command/Timeline.php @@ -140,7 +140,14 @@ class Timeline extends ExtendedBase { if ($input->getOption('local')) { $options->setLocal(true); } - $options->setProbe($input->getArgument('timeline')); + + $timeline = $input->getArgument('timeline'); + if (str_starts_with($timeline, '#')) { + $options->setProbe(ProbeOptions::HASHTAG) + ->setArgument(substr($timeline, 1)); + } else { + $options->setProbe($timeline); + } if ($input->getOption('account') !== '') { $local = $this->cacheActorService->getFromLocalAccount($input->getOption('account')); diff --git a/lib/Db/StreamRequest.php b/lib/Db/StreamRequest.php index da9922f3..0a812657 100644 --- a/lib/Db/StreamRequest.php +++ b/lib/Db/StreamRequest.php @@ -395,7 +395,7 @@ class StreamRequest extends StreamRequestBuilder { $result = $this->getTimelineFavourites($options); break; case ProbeOptions::HASHTAG: - $result = $this->getTimelineHashtag($options, $options->getArgument()); + $result = $this->getTimelineHashtag($options); break; case ProbeOptions::NOTIFICATIONS: $options->setFormat(ACore::FORMAT_NOTIFICATION); @@ -528,10 +528,20 @@ class StreamRequest extends StreamRequestBuilder { * * @return Stream[] */ - private function getTimelineHashtag(ProbeOptions $options, string $hashtag): array { + private function getTimelineHashtag(ProbeOptions $options): array { $qb = $this->getStreamSelectSql($options->getFormat()); + $qb->limitToType(Note::TYPE); + $qb->paginate($options); + + $expr = $qb->expr(); + $qb->linkToCacheActors('ca', 's.attributed_to_prim'); + $qb->linkToStreamTags('st', 's.id_prim'); + $qb->andWhere($qb->exprLimitToDBField('hashtag', $options->getArgument(), true, false, 'st')); - return []; + $qb->limitToViewer('sd', 'f', true); + $qb->andWhere($expr->eq('s.attributed_to_prim', 'ca.id_prim')); + + $qb->leftJoinStreamAction('sa'); return $this->getStreamsFromRequest($qb); } |