From 08982fc54088677cf4e9c5a0340a90e6eb406319 Mon Sep 17 00:00:00 2001 From: Marco Nassabain Date: Wed, 24 Feb 2021 23:33:36 +0100 Subject: =?UTF-8?q?=E2=9C=A8=20Add=20findAllSharedAfter=20-=20adapted=20Co?= =?UTF-8?q?ntroller,=20Service=20and=20Mapper=20(newItems)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Marco Nassabain --- lib/Db/ItemMapperV2.php | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'lib/Db') diff --git a/lib/Db/ItemMapperV2.php b/lib/Db/ItemMapperV2.php index 0e90fca40..5399272ce 100644 --- a/lib/Db/ItemMapperV2.php +++ b/lib/Db/ItemMapperV2.php @@ -391,6 +391,36 @@ class ItemMapperV2 extends NewsMapperV2 return $this->findEntities($builder); } + /** + * @param string $userId + * @param int|null $folderId + * @param int $updatedSince + * @param bool $hideRead + * + * @return Item[] + */ + public function findAllSharedAfter( + string $userId, + int $updatedSince, + bool $hideRead + ): array { + $builder = $this->db->getQueryBuilder(); + + $builder->select('items.*') + ->from($this->tableName, 'items') + ->andWhere('items.last_modified >= :updatedSince') + ->andWhere('items.shared_with = :sharedWith') + ->setParameters(['updatedSince' => $updatedSince, 'sharedWith' => $userId]) + ->orderBy('items.last_modified', 'DESC') + ->addOrderBy('items.id', 'DESC'); + + if ($hideRead === true) { + $builder->andWhere('items.unread = 1'); + } + + return $this->findEntities($builder); + } + /** * @param string $userId * @param int $updatedSince -- cgit v1.2.3