Reinstate profile_info in author/actor

This commit is contained in:
Zach Copley 2011-02-17 19:02:57 -08:00
parent a199192ebf
commit 29ce5dd19a
5 changed files with 14 additions and 12 deletions

View File

@ -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);
}

View File

@ -932,12 +932,12 @@ class Profile extends Memcached_DataObject
*
* @param User $cur Current user
*
* @return array representation of <statusnet:profile_info> element
* @return array representation of <statusnet:profile_info> 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

View File

@ -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);
}

View File

@ -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());

View File

@ -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 <activity:subject>
// This is for backward compatibility with clients (especially