diff options
Diffstat (limited to 'lib/Db')
-rw-r--r-- | lib/Db/CacheActorsRequest.php | 16 | ||||
-rw-r--r-- | lib/Db/FollowsRequest.php | 25 |
2 files changed, 41 insertions, 0 deletions
diff --git a/lib/Db/CacheActorsRequest.php b/lib/Db/CacheActorsRequest.php index 4c17abed..462f52eb 100644 --- a/lib/Db/CacheActorsRequest.php +++ b/lib/Db/CacheActorsRequest.php @@ -345,4 +345,20 @@ class CacheActorsRequest extends CacheActorsRequestBuilder { return $this->getCacheActorsFromRequest($qb); } + + /** + * As of today, returned format is not important. Remove this line if this method + * is used somewhere else with the need of a specific format + * + * @param array $ids + * + * @return array + */ + public function getFromNids(array $ids): array { + $qb = $this->getCacheActorsSelectSql(); + + $qb->limitInArray('nid', $ids); + + return $this->getCacheActorsFromRequest($qb); + } } diff --git a/lib/Db/FollowsRequest.php b/lib/Db/FollowsRequest.php index edf6e76a..920fe44b 100644 --- a/lib/Db/FollowsRequest.php +++ b/lib/Db/FollowsRequest.php @@ -333,4 +333,29 @@ class FollowsRequest extends FollowsRequestBuilder { $qb->executeStatement(); } + + + /** + * Returns everything related to a list of actorIds. + * Looking at actor_id_prim and object_id_prim. + * + * @param array $actorIds + * + * @return Follow[] + */ + public function getFollows(array $actorIds): array { + $qb = $this->getFollowsSelectSql(); + $qb->limitToType(Follow::TYPE); + + $prims = []; + foreach ($actorIds as $actorId) { + $prims[] = $qb->prim($actorId); + } + + $orX = $qb->expr()->orX(); + $orX->add($qb->exprLimitInArray('actor_id_prim', $prims)); + $orX->add($qb->exprLimitInArray('object_id_prim', $prims)); + + return $this->getFollowsFromRequest($qb); + } } |