Performing & allowing host-meta discovery by http url (in addition to webfinger acct)

This commit is contained in:
James Walker 2010-03-13 18:35:00 -05:00
parent 99ca84e68e
commit 85cf90cf0f
2 changed files with 15 additions and 11 deletions

View File

@ -32,12 +32,15 @@ class UserxrdAction extends XrdAction
parent::prepare($args); parent::prepare($args);
$this->uri = $this->trimmed('uri'); $this->uri = $this->trimmed('uri');
$acct = Discovery::normalize($this->uri); $this->uri = Discovery::normalize($this->uri);
list($nick, $domain) = explode('@', substr(urldecode($acct), 5)); if (Discovery::isWebfinger($this->uri)) {
$nick = common_canonical_nickname($nick); list($nick, $domain) = explode('@', substr(urldecode($this->uri), 5));
$nick = common_canonical_nickname($nick);
$this->user = User::staticGet('nickname', $nick); $this->user = User::staticGet('nickname', $nick);
} else {
$this->user = User::staticGet('uri', $this->uri);
}
if (!$this->user) { if (!$this->user) {
$this->clientError(_('No such user.'), 404); $this->clientError(_('No such user.'), 404);
return false; return false;

View File

@ -157,12 +157,13 @@ class Discovery_LRDD_Host_Meta implements Discovery_LRDD
{ {
public function discover($uri) public function discover($uri)
{ {
if (!Discovery::isWebfinger($uri)) { if (Discovery::isWebfinger($uri)) {
return false; // 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'; $url = 'http://'. $domain .'/.well-known/host-meta';
$xrd = Discovery::fetchXrd($url); $xrd = Discovery::fetchXrd($url);