From 29ce5dd19a5f3d395aeddddaab0350f8818199b5 Mon Sep 17 00:00:00 2001 From: Zach Copley Date: Thu, 17 Feb 2011 19:02:57 -0800 Subject: [PATCH] Reinstate profile_info in author/actor --- classes/Notice.php | 12 +++++++----- classes/Profile.php | 4 ++-- lib/activity.php | 5 +++-- lib/activitystreamjsondocument.php | 3 +-- lib/atomusernoticefeed.php | 2 +- 5 files changed, 14 insertions(+), 12 deletions(-) diff --git a/classes/Notice.php b/classes/Notice.php index 007eb55f85..95b3d5b480 100644 --- a/classes/Notice.php +++ b/classes/Notice.php @@ -1250,7 +1250,7 @@ class Notice extends Memcached_DataObject * @return Activity activity object representing this Notice. */ - function asActivity() + function asActivity($cur) { $act = self::cacheGet(Cache::codeKey('notice:as-activity:'.$this->id)); @@ -1262,9 +1262,11 @@ class Notice extends Memcached_DataObject if (Event::handle('StartNoticeAsActivity', array($this, &$act))) { $profile = $this->getProfile(); - $act->actor = ActivityObject::fromProfile($profile); - $act->verb = ActivityVerb::POST; - $act->objects[] = ActivityObject::fromNotice($this); + + $act->actor = ActivityObject::fromProfile($profile); + $act->actor->extra[] = $profile->profileInfo($cur); + $act->verb = ActivityVerb::POST; + $act->objects[] = ActivityObject::fromNotice($this); // XXX: should this be handled by default processing for object entry? @@ -1402,7 +1404,7 @@ class Notice extends Memcached_DataObject $author=true, $cur=null) { - $act = $this->asActivity(); + $act = $this->asActivity($cur); $act->extra[] = $this->noticeInfo($cur); return $act->asString($namespace, $author, $source); } diff --git a/classes/Profile.php b/classes/Profile.php index bdac3ba453..ad01581d5f 100644 --- a/classes/Profile.php +++ b/classes/Profile.php @@ -932,12 +932,12 @@ class Profile extends Memcached_DataObject * * @param User $cur Current user * - * @return array representation of element + * @return array representation of element or null */ function profileInfo($cur) { - $profileInfoAttr = array(); + $profileInfoAttr = array('local_id' => $this->id); if ($cur != null) { // Whether the current user is a subscribed to this profile diff --git a/lib/activity.php b/lib/activity.php index b9bd8c31fe..a8e6d25af9 100644 --- a/lib/activity.php +++ b/lib/activity.php @@ -443,9 +443,10 @@ class Activity foreach ($this->extra as $e) { list($objectName, $props, $txt) = $e; - $activity[$objectName] = $props; + if (!empty($objectName)) { + $activity[$objectName] = $props; + } } - return array_filter($activity); } diff --git a/lib/activitystreamjsondocument.php b/lib/activitystreamjsondocument.php index 7e06652a45..f74bb6d2e6 100644 --- a/lib/activitystreamjsondocument.php +++ b/lib/activitystreamjsondocument.php @@ -92,7 +92,6 @@ class ActivityStreamJSONDocument function addItemsFromNotices($notices) { - common_debug("addItemsFromNotices"); if (is_array($notices)) { foreach ($notices as $notice) { $this->addItemFromNotice($notice); @@ -114,7 +113,7 @@ class ActivityStreamJSONDocument { $cur = empty($this->cur) ? common_current_user() : $this->cur; - $act = $notice->asActivity(); + $act = $notice->asActivity($cur); $act->extra[] = $notice->noticeInfo($cur); array_push($this->doc['items'], $act->asArray()); diff --git a/lib/atomusernoticefeed.php b/lib/atomusernoticefeed.php index 3398cc8b4d..fb0ac5f831 100644 --- a/lib/atomusernoticefeed.php +++ b/lib/atomusernoticefeed.php @@ -64,7 +64,7 @@ class AtomUserNoticeFeed extends AtomNoticeFeed $ao = ActivityObject::fromProfile($profile); - $ao->extra[] = $profile->profileInfo($cur); + array_push($ao->extra, $profile->profileInfo($cur)); // XXX: For users, we generate an author _AND_ an // This is for backward compatibility with clients (especially -- 2.39.5