summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorMarco Nassabain <marco.nassabain@hotmail.com>2021-02-27 16:07:44 +0100
committerSean Molenaar <SMillerDev@users.noreply.github.com>2021-04-08 22:31:21 +0200
commit75e81d5e0b3e982a388c0587357102420df4c495 (patch)
tree00140a0dca450c52515f1a338a5857f4e4059572 /lib
parent46cc0698637f34136365de017efd7ba5e8d7b441 (diff)
🥅 ItemService: catch NotFoundException + cleanup
Signed-off-by: Marco Nassabain <marco.nassabain@hotmail.com>
Diffstat (limited to 'lib')
-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);
}