]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - classes/Conversation.php
More Favorite pluginification (favecount, cache, menus(favecount, cache, menus))
[quix0rs-gnu-social.git] / classes / Conversation.php
index 033b99384b0470f10c7e46d72bd37331eab79b5a..3acc283d62a2eb4ddce6c77206aaed4ff246c933 100755 (executable)
@@ -56,7 +56,10 @@ class Conversation extends Managed_DataObject
     }
 
     /**
-     * Factory method for creating a new conversation
+     * Factory method for creating a new conversation.
+     *
+     * Use this for locally initiated conversations. Remote notices should
+     * preferrably supply their own conversation URIs in the OStatus feed.
      *
      * @return Conversation the new conversation DO
      */
@@ -68,7 +71,10 @@ class Conversation extends Managed_DataObject
         $conv = new Conversation();
         $conv->created = common_sql_now();
         $conv->id = $notice->id;
-        $conv->uri = common_local_url('conversation', array('id' => $notice->id), null, null, false);
+        $conv->uri = sprintf('%s%s=%d:%s=%s',
+                             TagURI::mint(),
+                             'noticeId', $notice->id,
+                             'objectType', 'thread');
         $result = $conv->insert();
 
         if ($result === false) {
@@ -115,4 +121,15 @@ class Conversation extends Managed_DataObject
         return common_local_url('conversation', array('id' => $this->id)) .
                 ($noticeId===null ? '' : "#notice-{$noticeId}");
     }
+
+    // FIXME: ...will 500 ever be too low? Taken from ConversationAction::MAX_NOTICES
+    public function getNotices($offset=0, $limit=500, Profile $scoped=null)
+    {
+        if ($scoped === null) {
+            $scoped = Profile::current();
+        }
+        $stream = new ConversationNoticeStream($this->id, $scoped);
+        $notices = $stream->getNotices($offset, $limit);
+        return $notices;
+    }
 }