]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Activity Streams JSON - express to and in-reply-to stuff as person objects
authorZach Copley <zach@status.net>
Fri, 18 Feb 2011 18:02:41 +0000 (10:02 -0800)
committerZach Copley <zach@status.net>
Fri, 18 Feb 2011 18:02:41 +0000 (10:02 -0800)
lib/activity.php
lib/activitycontext.php

index 25d70c982b497eaaef1251b174e8413942a4d1d4..11af98abb545e9cc306b831fc3953edea282aae8 100644 (file)
@@ -364,6 +364,27 @@ class Activity
         if ($this->verb == ActivityVerb::POST && count($this->objects) == 1) {
             $activity['object'] = $this->objects[0]->asArray();
 
+            // Context stuff. For now I'm just sticking most of it
+            // in a property called "context"
+
+            if (!empty($this->context)) {
+
+                if (!empty($this->context->location)) {
+                    $loc = $this->context->location;
+
+                    // GeoJSON
+
+                    $activity['geopoint'] = array(
+                        'type'        => 'Point',
+                        'coordinates' => array($loc->lat, $loc->lon)
+                    );
+
+                }
+
+                $activity['to']      = $this->context->getToArray();
+                $activity['context'] = $this->context->asArray();
+            }
+
             // Instead of adding enclosures as an extension to JSON
             // Activities, it seems like we should be using the
             // attachedObjects property of ActivityObject
@@ -457,28 +478,6 @@ class Activity
             }
         }
 
-
-        // Context stuff. For now I'm just sticking most of it
-        // in a property called "context"
-
-   if (!empty($this->context)) {
-
-            if (!empty($this->context->location)) {
-                $loc = $this->context->location;
-
-                // GeoJSON
-
-                $activity['geopoint'] = array(
-                    'type'        => 'Point',
-                    'coordinates' => array($loc->lat, $loc->lon)
-                );
-
-            }
-
-            $activity['to']      = $this->context->getToArray();
-            $activity['context'] = $this->context->asArray();
-        }
-
         return array_filter($activity);
     }
 
index 3dc53d869d18a29f737ec50be579c3db06e391b5..acbd0e599f5993fbc459d5c2bec7be403126a396 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['replyTo']    =   $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,38 @@ 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;
     }
 
+    /*
+     * Show replyTo
+     */
+
+     function getInReplyToArray()
+     {
+         $replyToObj = array('objectType' => 'note');
+
+         $replyToObj['id'] = $this->replyToID;
+
+         if (!empty($this->replyToUrl)) {
+             $replyToObj['url'] = $this->replyToUrl;
+         }
+
+     }
+
 }
+