diff --git a/plugins/OStatus/OStatusPlugin.php b/plugins/OStatus/OStatusPlugin.php index 24094ebc69..c6c413873e 100644 --- a/plugins/OStatus/OStatusPlugin.php +++ b/plugins/OStatus/OStatusPlugin.php @@ -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, diff --git a/plugins/WebFinger/EVENTS.txt b/plugins/WebFinger/EVENTS.txt index 05e2b2a0f7..d4297fd669 100644 --- a/plugins/WebFinger/EVENTS.txt +++ b/plugins/WebFinger/EVENTS.txt @@ -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 diff --git a/plugins/WebFinger/lib/webfingerresource.php b/plugins/WebFinger/lib/webfingerresource.php index c9fe1727e2..d473d95628 100644 --- a/plugins/WebFinger/lib/webfingerresource.php +++ b/plugins/WebFinger/lib/webfingerresource.php @@ -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); } diff --git a/plugins/WebFinger/lib/webfingerresource/notice.php b/plugins/WebFinger/lib/webfingerresource/notice.php index 9510a690f7..b967bd9e1c 100644 --- a/plugins/WebFinger/lib/webfingerresource/notice.php +++ b/plugins/WebFinger/lib/webfingerresource/notice.php @@ -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)); + } } } diff --git a/plugins/WebFinger/lib/webfingerresource/profile.php b/plugins/WebFinger/lib/webfingerresource/profile.php index 49353145ed..5bfbda0f29 100644 --- a/plugins/WebFinger/lib/webfingerresource/profile.php +++ b/plugins/WebFinger/lib/webfingerresource/profile.php @@ -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',