correctly return oprofile from Ostatus_profile::ensureProfileURI()

This commit is contained in:
Evan Prodromou 2010-09-01 17:05:11 -04:00
parent 974ac48771
commit ab88123373

View File

@ -1770,22 +1770,31 @@ class Ostatus_profile extends Memcached_DataObject
{ {
$oprofile = null; $oprofile = null;
if (preg_match("/^(\w+)\:(.*)/", $uri, $match)) { // First, try to query it
$protocol = $match[1];
switch ($protocol) { $oprofile = Ostatus_profile::staticGet('uri', $uri);
case 'http':
case 'https': // If unfound, do discovery stuff
$oprofile = Ostatus_profile::ensureProfileURL($uri);
break; if (empty($oprofile)) {
case 'acct': if (preg_match("/^(\w+)\:(.*)/", $uri, $match)) {
case 'mailto': $protocol = $match[1];
$rest = $match[2]; switch ($protocol) {
$oprofile = Ostatus_profile::ensureWebfinger($rest); case 'http':
default: case 'https':
common_log("Unrecognized URI protocol for profile: $protocol ($uri)"); $oprofile = Ostatus_profile::ensureProfileURL($uri);
break; break;
case 'acct':
case 'mailto':
$rest = $match[2];
$oprofile = Ostatus_profile::ensureWebfinger($rest);
default:
common_log("Unrecognized URI protocol for profile: $protocol ($uri)");
break;
}
} }
} }
return $oprofile;
} }
} }