+ public function getUri()
+ {
+ return $this->uri;
+ }
+
+ /*
+ * @param $root boolean If true, link to just the conversation root.
+ *
+ * @return URL to conversation
+ */
+ public function getConversationUrl($anchor=true)
+ {
+ return Conversation::getUrlFromNotice($this, $anchor);
+ }
+
+ /*
+ * Get the local representation URL of this notice.
+ */
+ public function getLocalUrl()
+ {
+ return common_local_url('shownotice', array('notice' => $this->id), null, null, false);
+ }
+
+ /*
+ * Get the original representation URL of this notice.
+ */
+ public function getUrl()
+ {
+ // The risk is we start having empty urls and non-http uris...
+ // and we can't really handle any other protocol right now.
+ switch (true) {
+ case common_valid_http_url($this->url): // should we allow non-http/https URLs?
+ return $this->url;
+ case $this->isLocal():
+ // let's generate a valid link to our locally available notice on demand
+ return common_local_url('shownotice', array('notice' => $this->id), null, null, false);
+ case common_valid_http_url($this->uri):
+ return $this->uri;
+ default:
+ common_debug('No URL available for notice: id='.$this->id);
+ throw new InvalidUrlException($this->url);
+ }
+ }
+
+ public function get_object_type($canonical=false) {
+ return $canonical
+ ? ActivityObject::canonicalType($this->object_type)
+ : $this->object_type;
+ }
+
+ public static function getByUri($uri)
+ {
+ $notice = new Notice();
+ $notice->uri = $uri;
+ if (!$notice->find(true)) {
+ throw new NoResultException($notice);
+ }
+ return $notice;
+ }
+