From: Zach Copley Date: Thu, 10 Feb 2011 07:18:14 +0000 (-0800) Subject: Atom output - Reinstate activity:actor and activity:subject X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=df19e8832376c70193562694c09c48fbec30305d;p=quix0rs-gnu-social.git Atom output - Reinstate activity:actor and activity:subject w/deprecation warnings. Also add statusnet:profile_info back into author/actor. --- diff --git a/classes/Profile.php b/classes/Profile.php index adad0c6157..03f9300962 100644 --- a/classes/Profile.php +++ b/classes/Profile.php @@ -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 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 element. diff --git a/lib/activity.php b/lib/activity.php index 585a25de2e..6c21c0bcc9 100644 --- a/lib/activity.php +++ b/lib/activity.php @@ -392,6 +392,18 @@ class Activity if ($author) { $this->actor->outputTo($xs, 'author'); + + // XXX: Remove 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) { diff --git a/lib/atomgroupnoticefeed.php b/lib/atomgroupnoticefeed.php index 4e7f992662..817191b64a 100644 --- a/lib/atomgroupnoticefeed.php +++ b/lib/atomgroupnoticefeed.php @@ -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( + "\n" + . $ao->asString('activity:subject') + ); $this->addLink($group->homeUrl()); } diff --git a/lib/atomusernoticefeed.php b/lib/atomusernoticefeed.php index 5ca089b859..3398cc8b4d 100644 --- a/lib/atomusernoticefeed.php +++ b/lib/atomusernoticefeed.php @@ -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 + // 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( + "\n" + . $ao->asString('activity:subject') + ); } // TRANS: Title in atom user notice feed. %s is a user name.