diff options
author | Maxence Lange <maxence@artificial-owl.com> | 2019-07-19 09:59:15 -0100 |
---|---|---|
committer | Maxence Lange <maxence@artificial-owl.com> | 2019-07-19 09:59:15 -0100 |
commit | e1abbf1987fc759d72a687f2b4efdb2cf7214b01 (patch) | |
tree | df1f3e0180bb0fc1fd2e53dcd2cbeb5ef7465246 /lib | |
parent | ba7d78952e86c2f1ea0b192827ef19e893dcab8c (diff) |
adding liked stream
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Controller/LocalController.php | 22 | ||||
-rw-r--r-- | lib/Db/CoreRequestBuilder.php | 2 | ||||
-rw-r--r-- | lib/Db/StreamRequest.php | 37 | ||||
-rw-r--r-- | lib/Service/NoteService.php | 15 |
4 files changed, 71 insertions, 5 deletions
diff --git a/lib/Controller/LocalController.php b/lib/Controller/LocalController.php index 69294bf8..b731be2e 100644 --- a/lib/Controller/LocalController.php +++ b/lib/Controller/LocalController.php @@ -468,6 +468,28 @@ class LocalController extends Controller { /** + * Get liked post + * + * @NoAdminRequired + * + * @param int $since + * @param int $limit + * + * @return DataResponse + */ + public function streamLiked(int $since = 0, int $limit = 5): DataResponse { + try { + $this->initViewer(true); + $posts = $this->noteService->getStreamLiked($since, $limit); + + return $this->success($posts); + } catch (Exception $e) { + return $this->fail($e); + } + } + + + /** * @NoAdminRequired * * @param string $account diff --git a/lib/Db/CoreRequestBuilder.php b/lib/Db/CoreRequestBuilder.php index 214a3b4c..5647a4a4 100644 --- a/lib/Db/CoreRequestBuilder.php +++ b/lib/Db/CoreRequestBuilder.php @@ -1100,6 +1100,6 @@ class CoreRequestBuilder { $qb->where($this->exprLimitToDBField($qb, 'class', 'OCA\Social\Cron\Queue', true, true)); $qb->execute(); } - + } diff --git a/lib/Db/StreamRequest.php b/lib/Db/StreamRequest.php index 737dfd3d..e2d40af8 100644 --- a/lib/Db/StreamRequest.php +++ b/lib/Db/StreamRequest.php @@ -483,10 +483,7 @@ class StreamRequest extends StreamRequestBuilder { $qb = $this->getStreamSelectSql(); $this->limitPaginate($qb, $since, $limit); -// if ($localOnly) { $this->limitToLocal($qb, $localOnly); -// } - $this->limitToType($qb, Note::TYPE); $this->leftJoinCacheActors($qb, 'attributed_to'); @@ -511,6 +508,40 @@ class StreamRequest extends StreamRequestBuilder { /** * Should returns: + * * All liked posts + * + * @param int $since + * @param int $limit + * @param bool $localOnly + * + * @return array + * @throws Exception + */ + public function getLiked(int $since = 0, int $limit = 5, bool $localOnly = true): array { + $qb = $this->getStreamSelectSql(); + $this->limitPaginate($qb, $since, $limit); + + $this->limitToType($qb, Note::TYPE); + + $this->leftJoinCacheActors($qb, 'attributed_to'); + $this->leftJoinStreamAction($qb); + + $streams = []; + $cursor = $qb->execute(); + while ($data = $cursor->fetch()) { + try { +// $streams[] = $this->parseStreamSelectSql($data); + } catch (Exception $e) { + } + } + $cursor->closeCursor(); + + return $streams; + } + + + /** + * Should returns: * - All public post related to a tag (not yet) * - direct message related to a tag (not yet) * - message to followers related to a tag (not yet) diff --git a/lib/Service/NoteService.php b/lib/Service/NoteService.php index 27327709..b9043175 100644 --- a/lib/Service/NoteService.php +++ b/lib/Service/NoteService.php @@ -442,7 +442,7 @@ class NoteService { } - /**m + /** * * @param int $since * @param int $limit @@ -456,6 +456,19 @@ class NoteService { /** + * + * @param int $since + * @param int $limit + * + * @return Note[] + * @throws Exception + */ + public function getStreamLiked(int $since = 0, int $limit = 5): array { + return $this->streamRequest->getLiked($since, $limit); + } + + + /** * @param $noteId * * @return Person |