diff --git a/main.php b/main.php index f231756..e13c649 100644 --- a/main.php +++ b/main.php @@ -41,7 +41,7 @@ function get_item() Json::error('No item was found with the given ID')->die(); } - return Json::new($item->getUri()); + return $item->getJson(); } function post_item() @@ -49,11 +49,7 @@ function post_item() // The checks are performed internally $item = Item::upload($_FILES['file']); - return Json::new([ - 'type' => 'success', - 'id' => $item->getHash(), - 'link' => $item->getUri(), - ]); + return $item->getJson(); }; class MediaDB @@ -237,6 +233,15 @@ class Item $this->extension, ); } + + public function getJson(): Json + { + return Json::new([ + 'id' => $this->hash, + 'link' => $this->getUri(), + 'tags' => $this->tags, + ]); + } } class Json