]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Performing & allowing host-meta discovery by http url (in addition to webfinger acct)
authorJames Walker <walkah@walkah.net>
Sat, 13 Mar 2010 23:35:00 +0000 (18:35 -0500)
committerJames Walker <walkah@walkah.net>
Sat, 13 Mar 2010 23:35:00 +0000 (18:35 -0500)
plugins/OStatus/actions/userxrd.php
plugins/OStatus/lib/discovery.php

index 414de9364b705c766e7faba58f4d499f42ac020b..eb80a5ad46930d801be6e82735a04fb2a9866010 100644 (file)
@@ -32,12 +32,15 @@ class UserxrdAction extends XrdAction
         parent::prepare($args);
 
         $this->uri = $this->trimmed('uri');
-        $acct = Discovery::normalize($this->uri);
-
-        list($nick, $domain) = explode('@', substr(urldecode($acct), 5));
-        $nick = common_canonical_nickname($nick);
-
-        $this->user = User::staticGet('nickname', $nick);
+        $this->uri = Discovery::normalize($this->uri);
+        
+        if (Discovery::isWebfinger($this->uri)) {
+            list($nick, $domain) = explode('@', substr(urldecode($this->uri), 5));
+            $nick = common_canonical_nickname($nick);
+            $this->user = User::staticGet('nickname', $nick);
+        } else {
+            $this->user = User::staticGet('uri', $this->uri);
+        }
         if (!$this->user) {
             $this->clientError(_('No such user.'), 404);
             return false;
index f8449b309ec11bda481710af91b803118921f89c..df2fea64f62e1b7802706b654cf4b843b0dafd70 100644 (file)
@@ -157,12 +157,13 @@ class Discovery_LRDD_Host_Meta implements Discovery_LRDD
 {
     public function discover($uri)
     {
-        if (!Discovery::isWebfinger($uri)) {
-            return false;
+        if (Discovery::isWebfinger($uri)) {
+            // We have a webfinger acct: - start with host-meta
+            list($name, $domain) = explode('@', $uri);
+        } else {
+            $domain = parse_url($uri, PHP_URL_HOST);
         }
-
-        // We have a webfinger acct: - start with host-meta
-        list($name, $domain) = explode('@', $uri);
+        
         $url = 'http://'. $domain .'/.well-known/host-meta';
 
         $xrd = Discovery::fetchXrd($url);