Commit df19e883 authored by Zach Copley's avatar Zach Copley

Atom output - Reinstate activity:actor and activity:subject

w/deprecation warnings. Also add statusnet:profile_info back into
author/actor.
parent a0c66980
......@@ -918,6 +918,31 @@ class Profile extends Memcached_DataObject
return $xs->getString();
}
/**
* Extra profile info for atom entries
*
* Clients use some extra profile info in the atom stream.
* This gives it to them.
*
* @param User $cur Current user
*
* @return array representation of <statusnet:profile_info> element
*/
function profileInfo($cur)
{
$profileInfoAttr = array();
if ($cur != null) {
// Whether the current user is a subscribed to this profile
$profileInfoAttr['following'] = $cur->isSubscribed($this) ? 'true' : 'false';
// Whether the current user is has blocked this profile
$profileInfoAttr['blocking'] = $cur->hasBlocked($this) ? 'true' : 'false';
}
return array('statusnet:profile_info', $profileInfoAttr, null);
}
/**
* Returns an XML string fragment with profile information as an
* Activity Streams <activity:actor> element.
......
......@@ -392,6 +392,18 @@ class Activity
if ($author) {
$this->actor->outputTo($xs, 'author');
// XXX: Remove <activity:actor> ASAP! Author information
// has been moved to the author element in the Activity
// Streams spec. We're outputting actor only for backward
// compatibility with clients that can only parse
// activities based on older versions of the spec.
$depMsg = 'Deprecation warning: activity:actor is present '
. 'only for backward compatibility. It will be '
. 'removed in the next version of StatusNet.';
$xs->comment($depMsg);
$this->actor->outputTo($xs, 'activity:actor');
}
if ($this->verb != ActivityVerb::POST || count($this->objects) != 1) {
......
......@@ -91,8 +91,16 @@ class AtomGroupNoticeFeed extends AtomNoticeFeed
$ao = ActivityObject::fromGroup($group);
$this->addAuthorRaw($ao->asString('author').
$ao->asString('activity:subject'));
$this->addAuthorRaw($ao->asString('author'));
$depMsg = 'Deprecation warning: activity:subject is present '
. 'only for backward compatibility. It will be '
. 'removed in the next version of StatusNet.';
$this->addAuthorRaw(
"<!--$depMsg-->\n"
. $ao->asString('activity:subject')
);
$this->addLink($group->homeUrl());
}
......
......@@ -59,9 +59,29 @@ class AtomUserNoticeFeed extends AtomNoticeFeed
parent::__construct($cur, $indent);
$this->user = $user;
if (!empty($user)) {
$profile = $user->getProfile();
$ao = ActivityObject::fromProfile($profile);
$ao->extra[] = $profile->profileInfo($cur);
// XXX: For users, we generate an author _AND_ an <activity:subject>
// This is for backward compatibility with clients (especially
// StatusNet's clients) that assume the Atom will conform to an
// older version of the Activity Streams API. Subject should be
// removed in future versions of StatusNet.
$this->addAuthorRaw($ao->asString('author'));
$depMsg = 'Deprecation warning: activity:subject is present '
. 'only for backward compatibility. It will be '
. 'removed in the next version of StatusNet.';
$this->addAuthorRaw(
"<!--$depMsg-->\n"
. $ao->asString('activity:subject')
);
}
// TRANS: Title in atom user notice feed. %s is a user name.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment