]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - lib/activitycontext.php
L10n/i18n updated.
[quix0rs-gnu-social.git] / lib / activitycontext.php
index 3dc53d869d18a29f737ec50be579c3db06e391b5..2eff3fb15fb1605513681efd16f32d25ed75786c 100644 (file)
@@ -137,19 +137,16 @@ class ActivityContext
      *
      * @return array the context
      */
+
     function asArray()
     {
         $context = array();
 
-        $context['replyToId']    = $this->replyToID;
-        $context['replyToUrl']   = $this->replyToUrl;
+        $context['inReplyTo']    = $this->getInReplyToArray();
         $context['conversation'] = $this->conversation;
         $context['forwardId']    = $this->forwardID;
         $context['forwardUrl']   = $this->forwardUrl;
 
-        // XXX: We might want to have the attention to stuff
-        //      in here like we do with Atom
-
         return array_filter($context);
     }
 
@@ -164,16 +161,49 @@ class ActivityContext
      *
      * @return array the array of recipients
      */
+
     function getToArray()
     {
         $tos = array();
 
         foreach ($this->attention as $attnUrl) {
-            $to = array('id' => $attnUrl, 'url' => $attnUrl);
+            $to = array(
+                'objectType' => 'person',
+                'id'         => $attnUrl,
+                'url'        => $attnUrl
+            );
             $tos[] = $to;
         }
 
         return $tos;
     }
 
+    /**
+     * Return an array for the notices this notice is a reply to 
+     * suitable for serializing as JSON note objects.
+     *
+     * @return array the array of notes
+     */
+
+     function getInReplyToArray()
+     {
+         if (empty($this->replyToID) && empty($this->replyToUrl)) {
+             return null;
+         }
+
+         $replyToObj = array('objectType' => 'note');
+
+         // XXX: Possibly shorten this to just the numeric ID?
+         //      Currently, it's the full URI of the notice.
+         if (!empty($this->replyToID)) {
+             $replyToObj['id'] = $this->replyToID;
+         }
+         if (!empty($this->replyToUrl)) {
+             $replyToObj['url'] = $this->replyToUrl;
+         }
+
+         return $replyToObj;
+     }
+
 }
+