]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Throw exception when we can't get the url for a notice
authorMikael Nordfeldth <mmn@hethane.se>
Fri, 18 Apr 2014 21:17:15 +0000 (23:17 +0200)
committerMikael Nordfeldth <mmn@hethane.se>
Fri, 18 Apr 2014 21:17:15 +0000 (23:17 +0200)
classes/Notice.php

index cdf6a202320a7f7619d9b7e673f449f2a0144b6a..aadfc78cd06c790a765b814ae4f9bc258858b687 100644 (file)
@@ -213,7 +213,15 @@ class Notice extends Managed_DataObject
     public function getUrl()
     {
         // The risk is we start having empty urls and non-http uris...
-        return $this->url ?: $this->uri;
+        // and we can't really handle any other protocol right now.
+        switch (true) {
+        case common_valid_http_url($this->url):
+            return $this->url;
+        case common_valid_http_url($this->uri):
+            return $this->uri;
+        default:
+            throw new ServerException('No URL available for notice.');
+        }
     }
 
     public function get_object_type($canonical=false) {