]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Add avatars and notice info
authorZach Copley <zach@status.net>
Thu, 17 Feb 2011 02:55:13 +0000 (18:55 -0800)
committerZach Copley <zach@status.net>
Thu, 17 Feb 2011 02:55:13 +0000 (18:55 -0800)
lib/activity.php
lib/activityobject.php
lib/activitystreamjsondocument.php

index 6b3b121087ac502afd9783c53db78d22c2391b19..b9bd8c31fe7427cb4475e7fd1d51970840e4b16a 100644 (file)
@@ -437,10 +437,14 @@ class Activity
 
         /* Purely extensions hereafter */
 
-        if ($this->verb == ActivityVerb::POST) {
-            $activity['noticeInfo'] = $this->noticeInfo;
-        }
+        // XXX: a bit of a hack... Since JSON isn't namespaced we probably
+        // shouldn't be using 'statusnet:notice_info', but this will work
+        // for the moment.
 
+        foreach ($this->extra as $e) {
+            list($objectName, $props, $txt) = $e;
+            $activity[$objectName] = $props;
+        }
 
         return array_filter($activity);
     }
index d6356ed6fbf31727a79c9426e6aade34897731ed..0df99994545b57a27cf45466dad1af5e3b3a0971 100644 (file)
@@ -663,24 +663,33 @@ class ActivityObject
             || $this->type == ActivityObject::GROUP) {
 
             // XXX: Not sure what the best avatar is to use for the
-            // author's "image". For now, I'm using the stream size
-            // one, but possibly it should be large
-            $avatarLink = null;
+            // author's "image". For now, I'm using the large size.
+
+            $avatarLarge      = null;
+            $avatarMediaLinks = array();
 
             foreach ($this->avatarLinks as $a) {
-                if ($a->height == AVATAR_STREAM_SIZE) {
-                    $avatarLink = $a;
-                    break;
+
+                // Make a MediaLink for every other Avatar
+                $avatar = new ActivityStreamsMediaLink(
+                    $a->url,
+                    $a->width,
+                    $a->height,
+                    $a->type,
+                    'avatar'
+                );
+
+                // Find the big avatar to use as the "image"
+                if ($a->height == AVATAR_PROFILE_SIZE) {
+                    $imgLink = $avatar;
                 }
+
+                $avatarMediaLinks[] = $avatar->asArray();
             }
 
-            $imgLink = new ActivityStreamsMediaLink(
-                $avatarLink->url,
-                $avatarLink->width,
-                $avatarLink->height,
-                $avatarLink->type
-            );
+            $object['avatars'] = $avatarMediaLinks; // extension
 
+            // image
             $object['image']  = $imgLink->asArray();
         }
 
@@ -698,7 +707,12 @@ class ActivityObject
         // url (XXX: need to put the right thing here...)
         $object['url'] = $this->id;
 
-        // TODO: extensions (OStatus stuff, etc.)
+        /* Extensions */
+
+        foreach ($this->extra as $e) {
+            list($objectName, $props, $txt) = $e;
+            $object[$objectName] = $props;
+        }
 
         return array_filter($object);
     }
index 00029f85f913618355fa704f10a84eced027f8cb..7e06652a45f989918c5a709d74a2aa55ccaeef9a 100644 (file)
@@ -77,6 +77,7 @@ class ActivityStreamJSONDocument
      *
      * @param String $title the title
      */
+
     function setTitle($title)
     {
         $this->doc['title'] = $title;
@@ -205,10 +206,10 @@ class ActivityStreamsLink
         }
 
         $this->linkDict = array(
-            'url'        => $url,
-            'rel'        => $rel,      // extension
-            'mediaType'  => $mediaType // extension
-       );
+            'url'   => $url,
+            'rel'   => $rel,      // extension
+            'type'  => $mediaType // extension
+        );
     }
 
     function asArray()