]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - lib/activityobject.php
Add functions to avoid direct variable access
[quix0rs-gnu-social.git] / lib / activityobject.php
index a4fa62fb96a21979a314fc63ea5949ab9a97e67c..5a20ab2c18d35965d9d307f1b21ce2d3137b79a3 100644 (file)
@@ -438,6 +438,12 @@ class ActivityObject
             $object->type    = (empty($notice->object_type)) ? ActivityObject::NOTE : $notice->object_type;
 
             $object->id      = $notice->uri;
+            $object->title = 'New ' . ActivityObject::canonicalType($object->type) . ' by ';
+            try {
+                $object->title .= $notice->getProfile()->getAcctUri();
+            } catch (ProfileNoAcctUriException $e) {
+                $object->title .= $e->profile->nickname;
+            }
             $object->content = $notice->rendered;
             $object->link    = $notice->bestUrl();
 
@@ -460,9 +466,9 @@ class ActivityObject
             $object->link   = $profile->profileurl;
 
             try {
-                $orig = Avatar::getUploaded($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
             }
 
@@ -475,9 +481,9 @@ class ActivityObject
             foreach ($sizes as $size) {
                 $alink  = null;
                 try {
-                    $avatar = $profile->getAvatar($size);
+                    $avatar = Avatar::byProfile($profile, $size);
                     $alink = AvatarLink::fromAvatar($avatar);
-                } catch (Exception $e) {
+                } catch (NoAvatarException $e) {
                     $alink = new AvatarLink();
                     $alink->type   = 'image/png';
                     $alink->height = $size;
@@ -505,7 +511,7 @@ class ActivityObject
         return $object;
     }
 
-    static function fromGroup($group)
+    static function fromGroup(User_group $group)
     {
         $object = new ActivityObject();
 
@@ -791,12 +797,6 @@ class ActivityObject
 
             // content (Add rendered version of the notice?)
 
-            // displayName
-
-            if ($this->title) {
-                $object['displayName'] = $this->title;
-            }
-
             // downstreamDuplicates
 
             // id
@@ -810,6 +810,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.
 
@@ -857,7 +860,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.)