Add xmlns:statusnet and statusnet:notice_info element to Atom entries for notices

This commit is contained in:
Zach Copley 2010-05-05 22:35:16 -07:00
parent 14a76926a2
commit d9fddff539
2 changed files with 23 additions and 3 deletions

View File

@ -1171,7 +1171,7 @@ class Notice extends Memcached_DataObject
return $groups; return $groups;
} }
function asAtomEntry($namespace=false, $source=false, $author=true) function asAtomEntry($namespace=false, $source=false, $author=true, $cur=null)
{ {
$profile = $this->getProfile(); $profile = $this->getProfile();
@ -1184,7 +1184,8 @@ class Notice extends Memcached_DataObject
'xmlns:activity' => 'http://activitystrea.ms/spec/1.0/', 'xmlns:activity' => 'http://activitystrea.ms/spec/1.0/',
'xmlns:media' => 'http://purl.org/syndication/atommedia', 'xmlns:media' => 'http://purl.org/syndication/atommedia',
'xmlns:poco' => 'http://portablecontacts.net/spec/1.0', 'xmlns:poco' => 'http://portablecontacts.net/spec/1.0',
'xmlns:ostatus' => 'http://ostatus.org/schema/1.0'); 'xmlns:ostatus' => 'http://ostatus.org/schema/1.0',
'xmlns:statusnet' => 'http://status.net/ont/');
} else { } else {
$attrs = array(); $attrs = array();
} }
@ -1210,6 +1211,18 @@ class Notice extends Memcached_DataObject
$xs->element('icon', null, $profile->avatarUrl(AVATAR_PROFILE_SIZE)); $xs->element('icon', null, $profile->avatarUrl(AVATAR_PROFILE_SIZE));
$xs->element('updated', null, common_date_w3dtf($this->created)); $xs->element('updated', null, common_date_w3dtf($this->created));
$noticeInfoAttr = array(
'local_id' => $this->id, // local notice ID (useful to clients for ordering)
'source' => $this->source // the client name (source attribution)
// @todo source source_link
);
if (!empty($cur)) {
$noticeInfoAttr['favorited'] = ($cur->hasFave($this)) ? 'true' : 'false';
}
$xs->element('statusnet:notice_info', $noticeInfoAttr, null);
} }
if ($source) { if ($source) {

View File

@ -79,6 +79,11 @@ class AtomNoticeFeed extends Atom10Feed
'ostatus', 'ostatus',
'http://ostatus.org/schema/1.0' 'http://ostatus.org/schema/1.0'
); );
$this->addNamespace(
'statusnet',
'http://status.net/ont/'
);
} }
/** /**
@ -110,7 +115,9 @@ class AtomNoticeFeed extends Atom10Feed
$source = $this->showSource(); $source = $this->showSource();
$author = $this->showAuthor(); $author = $this->showAuthor();
$this->addEntryRaw($notice->asAtomEntry(false, $source, $author)); $cur = common_current_user();
$this->addEntryRaw($notice->asAtomEntry(false, $source, $author, $cur));
} }
function showSource() function showSource()