summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorJulius Härtl <jus@bitgrid.net>2018-11-22 16:11:46 +0100
committerJulius Härtl <jus@bitgrid.net>2018-11-22 18:57:18 +0100
commit69201a9ce28c56a8accf69cef8bcadce9b563534 (patch)
treea8492f287c3a49bd14d87cf1f6d15a066dbbb4d3 /lib
parent9375d246b9b72942b22ae89fc0f09234e6a1e287 (diff)
Load streams with pagination
Signed-off-by: Julius Härtl <jus@bitgrid.net>
Diffstat (limited to 'lib')
-rw-r--r--lib/Controller/ActivityPubController.php3
-rw-r--r--lib/Controller/LocalController.php8
-rw-r--r--lib/Db/NotesRequest.php6
-rw-r--r--lib/Service/ActivityPub/NoteService.php8
4 files changed, 14 insertions, 11 deletions
diff --git a/lib/Controller/ActivityPubController.php b/lib/Controller/ActivityPubController.php
index f4be158d..bd0512dd 100644
--- a/lib/Controller/ActivityPubController.php
+++ b/lib/Controller/ActivityPubController.php
@@ -124,10 +124,11 @@ class ActivityPubController extends Controller {
* @param string $username
*
* @return Response
+ * @throws \OC\User\NoUserException
*/
public function actor(string $username): Response {
if (!$this->checkSourceActivityStreams()) {
- return $this->navigationController->public();
+ return $this->navigationController->public($username);
}
try {
diff --git a/lib/Controller/LocalController.php b/lib/Controller/LocalController.php
index ece994b8..c824aeaa 100644
--- a/lib/Controller/LocalController.php
+++ b/lib/Controller/LocalController.php
@@ -181,11 +181,11 @@ class LocalController extends Controller {
*
* @return DataResponse
*/
- public function streamHome(): DataResponse {
+ public function streamHome(int $since = 0, int $limit = 5): DataResponse {
try {
$actor = $this->actorService->getActorFromUserId($this->userId);
- $posts = $this->noteService->getHomeNotesForActor($actor);
+ $posts = $this->noteService->getHomeNotesForActor($actor, $since, $limit);
return $this->success($posts);
} catch (Exception $e) {
@@ -203,11 +203,11 @@ class LocalController extends Controller {
*
* @return DataResponse
*/
- public function streamDirect(): DataResponse {
+ public function streamDirect(int $since = 0, int $limit = 5): DataResponse {
try {
$actor = $this->actorService->getActorFromUserId($this->userId);
- $posts = $this->noteService->getDirectNotesForActor($actor);
+ $posts = $this->noteService->getDirectNotesForActor($actor, $since, $limit);
return $this->success($posts);
} catch (Exception $e) {
diff --git a/lib/Db/NotesRequest.php b/lib/Db/NotesRequest.php
index c8795d6a..715a722a 100644
--- a/lib/Db/NotesRequest.php
+++ b/lib/Db/NotesRequest.php
@@ -142,11 +142,12 @@ class NotesRequest extends NotesRequestBuilder {
*
* @return array
*/
- public function getHomeNotesForActorId(string $actorId): array {
+ public function getHomeNotesForActorId(string $actorId, $since, $limit): array {
$qb = $this->getNotesSelectSql();
$this->rightJoinFollowing($qb);
$this->limitToActorId($qb, $actorId, 'f');
+ $this->limitPaginate($qb, $since, $limit);
// $this->leftJoinCacheActors($qb, 'attributed_to');
$notes = [];
@@ -192,9 +193,10 @@ class NotesRequest extends NotesRequestBuilder {
*
* @return array
*/
- public function getDirectNotesForActorId(string $actorId): array {
+ public function getDirectNotesForActorId(string $actorId, $since, $limit): array {
$qb = $this->getNotesSelectSql();
$this->limitToRecipient($qb, $actorId);
+ $this->limitPaginate($qb, $since, $limit);
$this->leftJoinCacheActors($qb, 'attributed_to');
$notes = [];
diff --git a/lib/Service/ActivityPub/NoteService.php b/lib/Service/ActivityPub/NoteService.php
index cc005ce0..2adecf1c 100644
--- a/lib/Service/ActivityPub/NoteService.php
+++ b/lib/Service/ActivityPub/NoteService.php
@@ -312,8 +312,8 @@ class NoteService implements ICoreService {
*
* @return Note[]
*/
- public function getHomeNotesForActor(Person $actor): array {
- return $this->notesRequest->getHomeNotesForActorId($actor->getId());
+ public function getHomeNotesForActor(Person $actor, $since, $limit): array {
+ return $this->notesRequest->getHomeNotesForActorId($actor->getId(), $since, $limit);
}
@@ -322,8 +322,8 @@ class NoteService implements ICoreService {
*
* @return Note[]
*/
- public function getDirectNotesForActor(Person $actor): array {
- return $this->notesRequest->getDirectNotesForActorId($actor->getId());
+ public function getDirectNotesForActor(Person $actor, $since, $limit): array {
+ return $this->notesRequest->getDirectNotesForActorId($actor->getId(), $since, $limit);
}