diff options
author | Maxence Lange <maxence@artificial-owl.com> | 2023-03-08 13:42:14 -0100 |
---|---|---|
committer | Maxence Lange <maxence@artificial-owl.com> | 2023-03-08 13:42:19 -0100 |
commit | b39fb7f90fb0e13a5ab73bdcd80b0069ef3500c9 (patch) | |
tree | 808edb611109f4ea15f40ae5d42da12135004883 /lib/Db/FollowsRequest.php | |
parent | fb3e07a8632673a14009978033124c0de34414dc (diff) |
add relationships api
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
Diffstat (limited to 'lib/Db/FollowsRequest.php')
-rw-r--r-- | lib/Db/FollowsRequest.php | 25 |
1 files changed, 25 insertions, 0 deletions
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); + } } |