summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorMaxence Lange <maxence@artificial-owl.com>2019-07-19 10:53:38 -0100
committerMaxence Lange <maxence@artificial-owl.com>2019-07-19 10:53:38 -0100
commitd985dc87e2870430a84b7ed4573d1dde7bfc17bb (patch)
tree867a32bb8d343a1a69a5ad1cbf7b749ee43ef222 /lib
parente1abbf1987fc759d72a687f2b4efdb2cf7214b01 (diff)
limit to liked post
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/Db/CoreRequestBuilder.php53
-rw-r--r--lib/Db/StreamRequest.php6
2 files changed, 57 insertions, 2 deletions
diff --git a/lib/Db/CoreRequestBuilder.php b/lib/Db/CoreRequestBuilder.php
index 5647a4a4..cab86988 100644
--- a/lib/Db/CoreRequestBuilder.php
+++ b/lib/Db/CoreRequestBuilder.php
@@ -860,6 +860,59 @@ class CoreRequestBuilder {
/**
* @param IQueryBuilder $qb
+ * @param string $type
+ */
+ protected function leftJoinActions(IQueryBuilder &$qb, string $type) {
+ if ($qb->getType() !== QueryBuilder::SELECT || $this->viewer === null) {
+ return;
+ }
+
+ $expr = $qb->expr();
+ $func = $qb->func();
+
+ $pf = $this->defaultSelectAlias;
+
+ $qb->selectAlias('a.id', 'action_id')
+ ->selectAlias('a.actor_id', 'action_actor_id')
+ ->selectAlias('a.object_id', 'action_object_id')
+ ->selectAlias('a.type', 'action_type');
+
+ $andX = $expr->andX();
+ $andX->add($expr->eq($func->lower($pf . '.id'), $func->lower('a.object_id')));
+ $andX->add($expr->eq('a.type', $qb->createNamedParameter($type)));
+ $andX->add(
+ $expr->eq(
+ $func->lower('a.actor_id'),
+ $qb->createNamedParameter(strtolower($this->viewer->getId()))
+ )
+ );
+
+ $qb->leftJoin(
+ $this->defaultSelectAlias, CoreRequestBuilder::TABLE_ACTIONS, 'a', $andX
+ );
+ }
+
+
+ /**
+ * @param array $data
+ */
+ protected function parseActionsLeftJoin(array $data) {
+ $new = [];
+ foreach ($data as $k => $v) {
+ if (substr($k, 0, 7) === 'action_') {
+ $new[substr($k, 7)] = $v;
+ }
+ }
+
+// $action = new Action();
+// $action->importFromDatabase($new);
+
+// return $action;
+ }
+
+
+ /**
+ * @param IQueryBuilder $qb
* @param string $fieldDocumentId
*/
protected function leftJoinCacheDocuments(IQueryBuilder &$qb, string $fieldDocumentId) {
diff --git a/lib/Db/StreamRequest.php b/lib/Db/StreamRequest.php
index e2d40af8..365d83f5 100644
--- a/lib/Db/StreamRequest.php
+++ b/lib/Db/StreamRequest.php
@@ -44,6 +44,7 @@ use OCA\Social\Model\ActivityPub\ACore;
use OCA\Social\Model\ActivityPub\Actor\Person;
use OCA\Social\Model\ActivityPub\Internal\SocialAppNotification;
use OCA\Social\Model\ActivityPub\Object\Document;
+use OCA\Social\Model\ActivityPub\Object\Like;
use OCA\Social\Model\ActivityPub\Object\Note;
use OCA\Social\Model\ActivityPub\Stream;
use OCA\Social\Service\ConfigService;
@@ -524,13 +525,14 @@ class StreamRequest extends StreamRequestBuilder {
$this->limitToType($qb, Note::TYPE);
$this->leftJoinCacheActors($qb, 'attributed_to');
- $this->leftJoinStreamAction($qb);
+ $this->leftJoinActions($qb, Like::TYPE);
+ $this->filterDBField($qb, 'id', '', false, 'a');
$streams = [];
$cursor = $qb->execute();
while ($data = $cursor->fetch()) {
try {
-// $streams[] = $this->parseStreamSelectSql($data);
+ $streams[] = $this->parseStreamSelectSql($data);
} catch (Exception $e) {
}
}