From 61a28c21711332edca0642ca153f6854ed33591c Mon Sep 17 00:00:00 2001 From: Maxence Lange Date: Tue, 4 Dec 2018 23:01:07 -0100 Subject: get public messages from an account Signed-off-by: Maxence Lange --- lib/Db/NotesRequest.php | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) (limited to 'lib/Db/NotesRequest.php') 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 -- cgit v1.2.3