+ $notice = new Notice();
+ $notice->conversation = $id;
+ $notice->whereAddIn('verb', array(ActivityVerb::POST, ActivityUtils::resolveUri(ActivityVerb::POST, true)), $notice->columnType('verb'));
+ $cnt = $notice->count();
+
+ self::cacheSet($keypart, $cnt);
+
+ return $cnt;
+ }
+
+ static public function getUrlFromNotice(Notice $notice, $anchor=true)
+ {
+ $conv = Conversation::getByID($notice->conversation);
+ return $conv->getUrl($anchor ? $notice->getID() : null);
+ }
+
+ public function getUri()
+ {
+ return $this->uri;
+ }
+
+ public function getUrl($noticeId=null)
+ {
+ // FIXME: the URL router should take notice-id as an argument...
+ return common_local_url('conversation', array('id' => $this->getID())) .
+ ($noticeId===null ? '' : "#notice-{$noticeId}");
+ }
+
+ // FIXME: ...will 500 ever be too low? Taken from ConversationAction::MAX_NOTICES
+ public function getNotices(Profile $scoped=null, $offset=0, $limit=500)
+ {
+ $stream = new ConversationNoticeStream($this->getID(), $scoped);
+ $notices = $stream->getNotices($offset, $limit);
+ return $notices;
+ }
+
+ public function insert()
+ {
+ $result = parent::insert();
+ if ($result === false) {
+ common_log_db_error($this, 'INSERT', __FILE__);
+ throw new ServerException(_('Failed to insert Conversation into database'));
+ }
+ return $result;