]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Notice metadata for WebFinger. Not sure if implemented properly.
authorMikael Nordfeldth <mmn@hethane.se>
Fri, 1 Nov 2013 15:54:59 +0000 (16:54 +0100)
committerMikael Nordfeldth <mmn@hethane.se>
Fri, 1 Nov 2013 16:37:18 +0000 (17:37 +0100)
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.

plugins/OStatus/OStatusPlugin.php
plugins/WebFinger/EVENTS.txt
plugins/WebFinger/lib/webfingerresource.php
plugins/WebFinger/lib/webfingerresource/notice.php
plugins/WebFinger/lib/webfingerresource/profile.php

index 24094ebc693dcd2d12a71609954e1aa33dc50342..c6c413873e8d198405b499c703df3e300ac7142f 100644 (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,
index 05e2b2a0f74f2d8614328ea8b5237680ae3bfbc7..d4297fd66963b37a0063ad00d8064ba9ff46c9d2 100644 (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
index c9fe1727e298c45498c9e75025ec47be316975eb..d473d95628f4a73f3ea28068ba3002fc4108e94c 100644 (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);
 }
index 9510a690f75f35dc3e54c5a9447b76ed5d938f21..b967bd9e1c15ff000b516ad80de8635392e185b9 100644 (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));
+        }
     }
 }
index 49353145ed3f242625c9868f4257bc0f0fe5214f..5bfbda0f2961a2005cba2cbb9d1b7b79bc0c1dea 100644 (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',