* @return Activity activity object representing this Notice.
*/
- function asActivity()
+ function asActivity($cur)
{
$act = self::cacheGet(Cache::codeKey('notice:as-activity:'.$this->id));
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?
$author=true,
$cur=null)
{
- $act = $this->asActivity();
+ $act = $this->asActivity($cur);
$act->extra[] = $this->noticeInfo($cur);
return $act->asString($namespace, $author, $source);
}
*
* @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
foreach ($this->extra as $e) {
list($objectName, $props, $txt) = $e;
- $activity[$objectName] = $props;
+ if (!empty($objectName)) {
+ $activity[$objectName] = $props;
+ }
}
-
return array_filter($activity);
}
function addItemsFromNotices($notices)
{
- common_debug("addItemsFromNotices");
if (is_array($notices)) {
foreach ($notices as $notice) {
$this->addItemFromNotice($notice);
{
$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());
$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