From f533ef2d32824a93d5cac9436b0b661fdbef4282 Mon Sep 17 00:00:00 2001 From: Diogo Cordeiro Date: Mon, 9 Jul 2018 00:07:14 +0100 Subject: [PATCH] Minor corrections --- utils/discovery.php | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/utils/discovery.php b/utils/discovery.php index d1fed4d..4bf93d4 100644 --- a/utils/discovery.php +++ b/utils/discovery.php @@ -1,4 +1,7 @@ get ($url, $headers); $this->response = json_decode ($response->getBody (), JSON_UNESCAPED_SLASHES); - if (!$response->isOk ()) - ActivityPubReturn::error ("Invalid Actor URL", 404); + if (!$response->isOk()) { + throw new NoResultException ("Invalid Actor URL."); + } return $this->storeProfile (); } - public function storeProfile () + private function storeProfile () { - $res = $this->response; + $res = $this->response; + // Validate response + if (!isset ($res["url"], $res["nickname"], $res["display_name"], $res["summary"])) { + throw new NoProfileException("Invalid Actor URL."); + } + $profile = new Profile; $profile->profileurl = $res["url"]; $profile->nickname = $res["nickname"];