diff options
author | Maxence Lange <maxence@artificial-owl.com> | 2018-12-06 18:18:12 -0100 |
---|---|---|
committer | Maxence Lange <maxence@artificial-owl.com> | 2018-12-06 18:18:12 -0100 |
commit | c41c43c529cabc03b23d3de76345b6626fd33074 (patch) | |
tree | 051f45f287f3c3b9ffed7296f739d55dbc6d30fe /lib/Db | |
parent | 296f8b3540847b25926358f9e2d25056d2b59bca (diff) |
moving Person $actor around instead of $actorId
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
Diffstat (limited to 'lib/Db')
-rw-r--r-- | lib/Db/NotesRequest.php | 17 | ||||
-rw-r--r-- | lib/Db/NotesRequestBuilder.php | 6 |
2 files changed, 15 insertions, 8 deletions
diff --git a/lib/Db/NotesRequest.php b/lib/Db/NotesRequest.php index c068c035..cbb96c6a 100644 --- a/lib/Db/NotesRequest.php +++ b/lib/Db/NotesRequest.php @@ -33,6 +33,7 @@ namespace OCA\Social\Db; use DateTime; use OCA\Social\Exceptions\NoteNotFoundException; use OCA\Social\Model\ActivityPub\Note; +use OCA\Social\Model\ActivityPub\Person; use OCA\Social\Service\ActivityService; use OCA\Social\Service\ConfigService; use OCA\Social\Service\MiscService; @@ -160,16 +161,16 @@ class NotesRequest extends NotesRequestBuilder { * * Own posts, * * Followed accounts * - * @param string $actorId + * @param Person $actor * @param int $since * @param int $limit * * @return array */ - public function getStreamHome(string $actorId, int $since = 0, int $limit = 5): array { + public function getStreamHome(Person $actor, int $since = 0, int $limit = 5): array { $qb = $this->getNotesSelectSql(); - $this->rightJoinFollowing($qb, $actorId); + $this->joinFollowing($qb, $actor); $this->limitPaginate($qb, $since, $limit); $this->leftJoinCacheActors($qb, 'attributed_to'); @@ -218,17 +219,21 @@ class NotesRequest extends NotesRequestBuilder { * * Private message. * - group messages. * - * @param string $actorId + * @param Person $actor * @param int $since * @param int $limit * * @return array */ - public function getStreamDirect(string $actorId, int $since = 0, int $limit = 5): array { + public function getStreamDirect(Person $actor, int $since = 0, int $limit = 5): array { $qb = $this->getNotesSelectSql(); $this->limitPaginate($qb, $since, $limit); + + $this->limitToRecipient($qb, $actor->getId(), true); + $this->filterToRecipient($qb, ActivityService::TO_PUBLIC); + $this->filterToRecipient($qb, $actor->getFollowers()); + $this->leftJoinCacheActors($qb, 'attributed_to'); - $this->limitToRecipient($qb, $actorId, true); $notes = []; $cursor = $qb->execute(); diff --git a/lib/Db/NotesRequestBuilder.php b/lib/Db/NotesRequestBuilder.php index 69681503..1e680a68 100644 --- a/lib/Db/NotesRequestBuilder.php +++ b/lib/Db/NotesRequestBuilder.php @@ -35,7 +35,9 @@ use DateTime; use Doctrine\DBAL\Query\QueryBuilder; use OCA\Social\Exceptions\InvalidResourceException; use OCA\Social\Model\ActivityPub\Note; +use OCA\Social\Model\ActivityPub\Person; use OCA\Social\Model\InstancePath; +use OCP\DB\QueryBuilder\ICompositeExpression; use OCP\DB\QueryBuilder\IQueryBuilder; class NotesRequestBuilder extends CoreRequestBuilder { @@ -124,9 +126,9 @@ class NotesRequestBuilder extends CoreRequestBuilder { /** * @param IQueryBuilder $qb - * @param string $actorId + * @param Person $actor */ - protected function rightJoinFollowing(IQueryBuilder $qb, string $actorId = '') { + protected function joinFollowing(IQueryBuilder $qb, Person $actor) { if ($qb->getType() !== QueryBuilder::SELECT) { return; } |