summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarco Nassabain <marco.nassabain@etu.unistra.fr>2021-01-17 19:51:17 +0100
committerSean Molenaar <SMillerDev@users.noreply.github.com>2021-04-08 22:31:21 +0200
commit08171bb42de718cda797462b9f5de029ce82afb9 (patch)
treedc3b803582792b687d5454a412073cdff3eab652
parent527eef0727e3bfceb53f209bc74d096626eb1a6b (diff)
✨ NewsItem: add share routes + controller func
Signed-off-by: Marco Nassabain <marco.nassabain@hotmail.com>
-rw-r--r--appinfo/routes.php1
-rw-r--r--lib/Controller/ItemController.php20
2 files changed, 21 insertions, 0 deletions
diff --git a/appinfo/routes.php b/appinfo/routes.php
index a50f4a5b7..534f37540 100644
--- a/appinfo/routes.php
+++ b/appinfo/routes.php
@@ -52,6 +52,7 @@ return ['routes' => [
['name' => 'item#read', 'url' => '/items/{itemId}/read', 'verb' => 'POST'],
['name' => 'item#read_multiple', 'url' => '/items/read/multiple', 'verb' => 'POST'],
['name' => 'item#star', 'url' => '/items/{feedId}/{guidHash}/star', 'verb' => 'POST'],
+['name' => 'item#share', 'url' => '/items/{itemId}/share/{shareWithId}', 'verb' => 'POST'],
// export
['name' => 'export#opml', 'url' => '/export/opml', 'verb' => 'GET'],
diff --git a/lib/Controller/ItemController.php b/lib/Controller/ItemController.php
index 85f67ef7a..57ad318d2 100644
--- a/lib/Controller/ItemController.php
+++ b/lib/Controller/ItemController.php
@@ -318,4 +318,24 @@ class ItemController extends Controller
}
}
}
+
+
+ /**
+ * @NoAdminRequired
+ *
+ * @param int $itemId
+ * @param string $shareWithId
+ * @return array
+ */
+ public function share($itemId, $shareWithId)
+ {
+ try {
+ $this->itemService->shareItem($itemId, $shareWithId, $this->userId);
+ } catch (ServiceNotFoundException $ex) {
+ return $this->error($ex, Http::STATUS_NOT_FOUND);
+ }
+
+ return [];
+ }
+
}