Notice metadata for WebFinger. Not sure if implemented properly.

This is more of a proof of concept and will likely not stay in exactly
this form. We should reasonably deliver the entire notice upon webfinger
querying.
This commit is contained in:
Mikael Nordfeldth 2013-11-01 16:54:59 +01:00
parent 7ddd561837
commit 6ef1967cec
5 changed files with 36 additions and 12 deletions

View File

@ -1311,6 +1311,14 @@ class OStatusPlugin extends Plugin
}
}
function onEndWebFingerNoticeLinks(XML_XRD $xrd, Notice $target)
{
$author = $target->getProfile();
$salmon_url = common_local_url('usersalmon', array('id' => $author->id));
$xrd->links[] = new XML_XRD_Element_Link(Salmon::REL_SALMON, $salmon_url);
return true;
}
function onEndWebFingerProfileLinks(XML_XRD $xrd, Profile $target)
{
$xrd->links[] = new XML_XRD_Element_Link(Discovery::UPDATESFROM,

View File

@ -22,10 +22,18 @@ EndWebFingerReconstruction: Last attempts to generate an acct: uri from a Profil
- $profile: Profile object for which we want a WebFinger ID
- &$acct: String reference where reconstructed ID is stored
StartWebFingerProfileLinks: About to set links for the resource descriptor of a profile
StartWebFingerNoticeLinks: About to set links for the resource descriptor of a Notice
- $xrd: XML_XRD object being shown
- $target: Notice being shown
EndWebFingerNoticeLinks: Done with links for the resource descriptor of a Notice
- $xrd: XML_XRD object being shown
- $target: Notice being shown
StartWebFingerProfileLinks: About to set links for the resource descriptor of a Profile
- $xrd: XML_XRD object being shown
- $target: Profile being shown
EndWebFingerProfileLinks: Done with links for the resource descriptor of a profile
EndWebFingerProfileLinks: Done with links for the resource descriptor of a Profile
- $xrd: XML_XRD object being shown
- $target: Profile being shown

View File

@ -11,8 +11,6 @@
abstract class WebFingerResource
{
const PROFILEPAGE = 'http://webfinger.net/rel/profile-page';
protected $identities = array();
protected $object = null;
@ -47,8 +45,5 @@ abstract class WebFingerResource
return $aliases;
}
public function updateXRD(XML_XRD $xrd) {
$xrd->links[] = new XML_XRD_Element_Link(WebFingerResource::PROFILEPAGE,
$this->object->getUrl(), 'text/html');
}
abstract public function updateXRD(XML_XRD $xrd);
}

View File

@ -19,9 +19,19 @@ class WebFingerResource_Notice extends WebFingerResource
public function updateXRD(XML_XRD $xrd)
{
parent::updateXRD($xrd);
if (Event::handle('StartWebFingerNoticeLinks', array($xrd, $this->object))) {
$xrd->links[] = new XML_XRD_Element_Link('alternate',
common_local_url('ApiStatusesShow',
array('id'=>$this->object->id,
'format'=>'atom')),
'application/atom+xml');
// TODO: Add atom and json representation links here
// TODO: Add Salmon/callback links and stuff here
$xrd->links[] = new XML_XRD_Element_Link('alternate',
common_local_url('ApiStatusesShow',
array('id'=>$this->object->id,
'format'=>'json')),
'application/json');
Event::handle('EndWebFingerNoticeLinks', array($xrd, $this->object));
}
}
}

View File

@ -11,6 +11,8 @@
class WebFingerResource_Profile extends WebFingerResource
{
const PROFILEPAGE = 'http://webfinger.net/rel/profile-page';
public function __construct(Profile $object)
{
// The type argument above verifies that it's our class
@ -53,7 +55,8 @@ class WebFingerResource_Profile extends WebFingerResource
{
if (Event::handle('StartWebFingerProfileLinks', array($xrd, $this->object))) {
parent::updateXRD($xrd);
$xrd->links[] = new XML_XRD_Element_Link(self::PROFILEPAGE,
$this->object->getUrl(), 'text/html');
// XFN
$xrd->links[] = new XML_XRD_Element_Link('http://gmpg.org/xfn/11',