X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=inline;f=lib%2Factivityobject.php;h=5a20ab2c18d35965d9d307f1b21ce2d3137b79a3;hb=779ce40ac354afdb37495c9a9bc50343a3af1d1f;hp=e4b22dd23b364b1030045f50a98705709cfc452b;hpb=4015a58d1cfaa257fcf2b01aa6b1c9daa268c997;p=quix0rs-gnu-social.git diff --git a/lib/activityobject.php b/lib/activityobject.php index e4b22dd23b..5a20ab2c18 100644 --- a/lib/activityobject.php +++ b/lib/activityobject.php @@ -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(); @@ -459,10 +465,11 @@ class ActivityObject $object->title = $profile->getBestName(); $object->link = $profile->profileurl; - $orig = $profile->getOriginalAvatar(); - - if (!empty($orig)) { - $object->avatarLinks[] = AvatarLink::fromAvatar($orig); + try { + $avatar = Avatar::getUploaded($profile); + $object->avatarLinks[] = AvatarLink::fromAvatar($avatar); + } catch (NoAvatarException $e) { + // Could not find an original avatar to link } $sizes = array( @@ -473,27 +480,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; @@ -516,7 +511,7 @@ class ActivityObject return $object; } - static function fromGroup($group) + static function fromGroup(User_group $group) { $object = new ActivityObject(); @@ -733,17 +728,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); } } @@ -803,12 +797,6 @@ class ActivityObject // content (Add rendered version of the notice?) - // displayName - - if ($this->title) { - $object['displayName'] = $this->title; - } - // downstreamDuplicates // id @@ -822,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. @@ -869,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.) @@ -888,7 +879,7 @@ class ActivityObject // @fixme text content from XML extensions will be lost foreach ($this->extra as $e) { - list($objectName, $props, $txt) = $e; + list($objectName, $props, $txt) = array_pad($e, 3, null); if (!empty($objectName)) { $parts = explode(":", $objectName); if (count($parts) == 2 && $parts[0] == "statusnet") {