diff options
author | Maxence Lange <maxence@artificial-owl.com> | 2018-12-04 23:01:07 -0100 |
---|---|---|
committer | Julius Härtl <jus@bitgrid.net> | 2018-12-05 09:53:24 +0100 |
commit | 61a28c21711332edca0642ca153f6854ed33591c (patch) | |
tree | 9f4b9590ab7190d67a16a59ac0eb7ecdb1fa4ed4 | |
parent | 6af499a81781a65e6e6f5a20f3e616b8ada480d1 (diff) |
get public messages from an account
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
-rw-r--r-- | appinfo/routes.php | 1 | ||||
-rw-r--r-- | lib/Db/NotesRequest.php | 32 | ||||
-rw-r--r-- | lib/Service/ActivityPub/NoteService.php | 2 |
3 files changed, 32 insertions, 3 deletions
diff --git a/appinfo/routes.php b/appinfo/routes.php index 7fc4b1fb..6a595a4e 100644 --- a/appinfo/routes.php +++ b/appinfo/routes.php @@ -68,6 +68,7 @@ return [ ['name' => 'Local#streamTimeline', 'url' => '/api/v1/stream/timeline', 'verb' => 'GET'], ['name' => 'Local#streamFederated', 'url' => '/api/v1/stream/federated', 'verb' => 'GET'], ['name' => 'Local#streamDirect', 'url' => '/api/v1/stream/direct', 'verb' => 'GET'], + ['name' => 'Local#streamAccount', 'url' => '/api/v1/account/{username}/stream', 'verb' => 'GET'], ['name' => 'Local#postCreate', 'url' => '/api/v1/post', 'verb' => 'POST'], ['name' => 'Local#postDelete', 'url' => '/api/v1/post', 'verb' => 'DELETE'], diff --git a/lib/Db/NotesRequest.php b/lib/Db/NotesRequest.php index cc3fd342..ec9aca9f 100644 --- a/lib/Db/NotesRequest.php +++ b/lib/Db/NotesRequest.php @@ -189,10 +189,38 @@ class NotesRequest extends NotesRequestBuilder { /** - * Should returns: + * Should returns: + * * public message from actorId. + * - to followers-only if follower is logged. + * + * @param string $actorId + * @param int $since + * @param int $limit + * + * @return array + */ + public function getStreamAccount(string $actorId, int $since = 0, int $limit = 5): array { + $qb = $this->getNotesSelectSql(); + $this->limitToRecipient($qb, ActivityService::TO_PUBLIC); + $this->limitPaginate($qb, $since, $limit); + $this->limitToAttributedTo($qb, $actorId); + + $notes = []; + $cursor = $qb->execute(); + while ($data = $cursor->fetch()) { + $notes[] = $this->parseNotesSelectSql($data); + } + $cursor->closeCursor(); + + return $notes; + } + + + /** + * Should returns: * * Private message. * - group messages. - + * * @param string $actorId * @param int $since * @param int $limit diff --git a/lib/Service/ActivityPub/NoteService.php b/lib/Service/ActivityPub/NoteService.php index f99dd13a..8bddea7b 100644 --- a/lib/Service/ActivityPub/NoteService.php +++ b/lib/Service/ActivityPub/NoteService.php @@ -370,7 +370,7 @@ class NoteService implements ICoreService { * @return Note[] */ public function getStreamAccount(string $actorId, int $since = 0, int $limit = 5): array { - return $this->notesRequest->getStreamHome($actorId, $since, $limit); + return $this->notesRequest->getStreamAccount($actorId, $since, $limit); } |