summaryrefslogtreecommitdiffstats
path: root/lib/Db/FollowsRequest.php
diff options
context:
space:
mode:
authorMaxence Lange <maxence@artificial-owl.com>2023-03-08 13:42:14 -0100
committerMaxence Lange <maxence@artificial-owl.com>2023-03-08 13:42:19 -0100
commitb39fb7f90fb0e13a5ab73bdcd80b0069ef3500c9 (patch)
tree808edb611109f4ea15f40ae5d42da12135004883 /lib/Db/FollowsRequest.php
parentfb3e07a8632673a14009978033124c0de34414dc (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.php25
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);
+ }
}