summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/Controller/ApiV2ResponseTrait.php6
-rw-r--r--lib/Db/IAPI.php2
-rw-r--r--lib/Db/Item.php12
3 files changed, 14 insertions, 6 deletions
diff --git a/lib/Controller/ApiV2ResponseTrait.php b/lib/Controller/ApiV2ResponseTrait.php
index 2a8ed18ab..3538f1948 100644
--- a/lib/Controller/ApiV2ResponseTrait.php
+++ b/lib/Controller/ApiV2ResponseTrait.php
@@ -27,10 +27,10 @@ trait ApiV2ResponseTrait
*
* @return array
*/
- public function serialize($data): array
+ public function serialize($data, bool $reduced = false): array
{
if ($data instanceof IAPI) {
- return $data->toAPI2();
+ return $data->toAPI2($reduced);
}
$return = [];
@@ -40,7 +40,7 @@ trait ApiV2ResponseTrait
foreach ($data as $entity) {
if ($entity instanceof IAPI) {
- $return[] = $entity->toAPI2();
+ $return[] = $entity->toAPI2($reduced);
}
}
return $return;
diff --git a/lib/Db/IAPI.php b/lib/Db/IAPI.php
index 120d5551c..3184d7a79 100644
--- a/lib/Db/IAPI.php
+++ b/lib/Db/IAPI.php
@@ -18,5 +18,5 @@ namespace OCA\News\Db;
interface IAPI
{
public function toAPI();
- public function toAPI2();
+ public function toAPI2(bool $reduced = false);
}
diff --git a/lib/Db/Item.php b/lib/Db/Item.php
index 9fae011f1..4b679dfa0 100644
--- a/lib/Db/Item.php
+++ b/lib/Db/Item.php
@@ -576,8 +576,16 @@ class Item extends Entity implements IAPI, \JsonSerializable
];
}
- public function toAPI2(): array
- {
+ public function toAPI2(bool $reduced = false): array
+ {
+ if ($reduced) {
+ return [
+ 'id' => $this->getId(),
+ 'isUnread' => $this->isUnread(),
+ 'isStarred' => $this->isStarred()
+ ];
+ }
+
return [
'id' => $this->getId(),
'url' => $this->getUrl(),