diff --git a/src/Controller/RelatedRorController.php b/src/Controller/RelatedRorController.php index 0bbd8a5..27e4076 100644 --- a/src/Controller/RelatedRorController.php +++ b/src/Controller/RelatedRorController.php @@ -87,7 +87,10 @@ class RelatedRorController extends ControllerBase { $nid = intval($nid); $node = \Drupal\node\Entity\Node::load($nid); if($node == null) { - return new Response("Node not found", 400, array('Content-Type' => 'text/plain')); + return new Response("Node not found", 404, array('Content-Type' => 'text/plain')); + } + if($this->isFilteredOut($node)) { + return new Response("Node has no similarity", 404, array('Content-Type' => 'text/plain')); } $time = intval($node->getCreatedTime()); $nearnodes = $this->presentNids(array_filter( @@ -138,6 +141,13 @@ class RelatedRorController extends ControllerBase { return $resp; } + private function isFilteredOut(\Drupal\node\Entity\Node $node) { + if($node->getType() === 'page') + return true; + + return false; + } + public function relatedTopic() { // TODO: get node time // TODO: queryNearInTime($time) @@ -151,7 +161,10 @@ class RelatedRorController extends ControllerBase { $nid = intval($nid); $node = \Drupal\node\Entity\Node::load($nid); if($node == null) { - return new Response("Node not found", 400, array('Content-Type' => 'text/plain')); + return new Response("Node not found", 404, array('Content-Type' => 'text/plain')); + } + if($this->isFilteredOut($node)) { + return new Response("Node similarity disallowed", 403, array('Content-Type' => 'text/plain')); } $orig_arr = $node->toArray(); $time = intval($node->getCreatedTime());