summaryrefslogtreecommitdiffstats
path: root/lib/Service
diff options
context:
space:
mode:
authorPaul Tirk <paultirk@paultirk.com>2022-04-11 10:11:33 +0200
committerBenjamin Brahmer <info@b-brahmer.de>2022-04-30 20:04:30 +0200
commit98028e4422fe6f2c1af297271d0c5bcd01af70d4 (patch)
treecdc1c2200255a0e5cdf573a7fda3470f348a61ee /lib/Service
parent397eba14d92144f463ee3b879b43a790d62a2bc8 (diff)
add routes for starring/unstarring items by id
Signed-off-by: Paul Tirk <paultirk@paultirk.com>
Diffstat (limited to 'lib/Service')
-rw-r--r--lib/Service/ItemServiceV2.php26
1 files changed, 26 insertions, 0 deletions
diff --git a/lib/Service/ItemServiceV2.php b/lib/Service/ItemServiceV2.php
index 57804a8c3..4f314105b 100644
--- a/lib/Service/ItemServiceV2.php
+++ b/lib/Service/ItemServiceV2.php
@@ -212,6 +212,32 @@ class ItemServiceV2 extends Service
}
/**
+ * Mark an item as starred by id
+ *
+ * @param string $userId Item owner
+ * @param int $itemId
+ * @param bool $starred
+ *
+ * @return Item
+ * @throws ServiceConflictException
+ * @throws ServiceNotFoundException
+ */
+ public function starByItemId(string $userId, int $itemId, bool $starred): Entity
+ {
+ try {
+ $item = $this->mapper->findFromUser($userId, $itemId);
+ } catch (DoesNotExistException $ex) {
+ throw ServiceNotFoundException::from($ex);
+ } catch (MultipleObjectsReturnedException $ex) {
+ throw ServiceConflictException::from($ex);
+ }
+
+ $item->setStarred($starred);
+
+ return $this->mapper->update($item);
+ }
+
+ /**
* Mark all items as read
*
* @param string $userId Item owner