]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - lib/activityobject.php
Apparently only one atom:content is allowed
[quix0rs-gnu-social.git] / lib / activityobject.php
index 0b29888083d03b04d7d5bdf47748d0faf873c7a7..7af8a821950fece1516c7562f15e63650a44861f 100644 (file)
@@ -438,6 +438,7 @@ class ActivityObject
             $object->type    = (empty($notice->object_type)) ? ActivityObject::NOTE : $notice->object_type;
 
             $object->id      = $notice->uri;
+            $object->title   = 'New ' . ActivityObject::canonicalType($notice->object_type);
             $object->content = $notice->rendered;
             $object->link    = $notice->bestUrl();
 
@@ -460,9 +461,9 @@ class ActivityObject
             $object->link   = $profile->profileurl;
 
             try {
-                $orig = Avatar::getOriginal($profile);
-                $object->avatarLinks[] = AvatarLink::fromAvatar($orig);
-            } catch (Exception $e) {
+                $avatar = Avatar::getUploaded($profile);
+                $object->avatarLinks[] = AvatarLink::fromAvatar($avatar);
+            } catch (NoAvatarException $e) {
                 // Could not find an original avatar to link
             }
 
@@ -474,27 +475,15 @@ class ActivityObject
 
             foreach ($sizes as $size) {
                 $alink  = null;
-                $avatar = $profile->getAvatar($size);
-
-                if (!empty($avatar)) {
+                try {
+                    $avatar = Avatar::byProfile($profile, $size);
                     $alink = AvatarLink::fromAvatar($avatar);
-                } else {
+                } catch (NoAvatarException $e) {
                     $alink = new AvatarLink();
                     $alink->type   = 'image/png';
                     $alink->height = $size;
                     $alink->width  = $size;
                     $alink->url    = Avatar::defaultImage($size);
-
-                    if ($size == AVATAR_PROFILE_SIZE) {
-                        // Hack for Twitter import: we don't have a 96x96 image,
-                        // but we do have a 73x73 image. For now, fake it with that.
-                        $avatar = $profile->getAvatar(73);
-                        if ($avatar) {
-                            $alink = AvatarLink::fromAvatar($avatar);
-                            $alink->height= $size;
-                            $alink->width = $size;
-                        }
-                    }
                 }
 
                 $object->avatarLinks[] = $alink;
@@ -517,7 +506,7 @@ class ActivityObject
         return $object;
     }
 
-    static function fromGroup($group)
+    static function fromGroup(User_group $group)
     {
         $object = new ActivityObject();
 
@@ -734,17 +723,16 @@ class ActivityObject
             if ($this->type == ActivityObject::PERSON
                 || $this->type == ActivityObject::GROUP) {
 
-                foreach ($this->avatarLinks as $avatar) {
-                    $xo->element(
-                        'link', array(
-                            'rel'  => 'avatar',
-                            'type'         => $avatar->type,
-                            'media:width'  => $avatar->width,
-                            'media:height' => $avatar->height,
-                            'href' => $avatar->url
-                        ),
-                        null
-                    );
+                foreach ($this->avatarLinks as $alink) {
+                    $xo->element('link',
+                            array(
+                                'rel'          => 'avatar',
+                                'type'         => $alink->type,
+                                'media:width'  => $alink->width,
+                                'media:height' => $alink->height,
+                                'href'         => $alink->url,
+                                ),
+                            null);
                 }
             }
 
@@ -804,12 +792,6 @@ class ActivityObject
 
             // content (Add rendered version of the notice?)
 
-            // displayName
-
-            if ($this->title) {
-                $object['displayName'] = $this->title;
-            }
-
             // downstreamDuplicates
 
             // id
@@ -823,6 +805,9 @@ class ActivityObject
             if ($this->type == ActivityObject::PERSON
                 || $this->type == ActivityObject::GROUP) {
 
+                // displayName
+                $object['displayName'] = $this->title;
+
                 // XXX: Not sure what the best avatar is to use for the
                 // author's "image". For now, I'm using the large size.
 
@@ -870,7 +855,7 @@ class ActivityObject
             // summary
             $object['summary'] = $this->summary;
 
-            // content
+            // content, usually rendered HTML
             $object['content'] = $this->content;
 
             // published (probably don't need. Might be useful for repeats.)