summaryrefslogtreecommitdiffstats
path: root/lib/Service/ItemServiceV2.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Service/ItemServiceV2.php')
-rw-r--r--lib/Service/ItemServiceV2.php11
1 files changed, 6 insertions, 5 deletions
diff --git a/lib/Service/ItemServiceV2.php b/lib/Service/ItemServiceV2.php
index 1f5acc070..43fcc7e00 100644
--- a/lib/Service/ItemServiceV2.php
+++ b/lib/Service/ItemServiceV2.php
@@ -449,10 +449,12 @@ class ItemServiceV2 extends Service
*/
public function share(string $userId, int $id, string $shareWithId): Entity
{
- // TODO: check if item is already shared with the user
-
- /** @var Item $item */
- $item = $this->find($userId, $id);
+ // find item to share
+ try {
+ $item = $this->find($userId, $id);
+ } catch (DoesNotExistException $ex) {
+ throw ServiceNotFoundException::from($ex);
+ }
// duplicate the item
$sharedItem = Item::fromImport($item->jsonSerialize());
@@ -469,7 +471,6 @@ class ItemServiceV2 extends Service
$sharedItem->setSharedBy($userId);
$sharedItem->setSharedWith($shareWithId);
- // return $this->mapper->update($item);
return $this->mapper->insert($sharedItem);
}