Merge branch 'testing' of git@gitorious.org:statusnet/mainline into testing

This commit is contained in:
Sarven Capadisli 2010-02-16 17:10:24 +01:00
commit 385fb94723
4 changed files with 70 additions and 56 deletions

View File

@ -1008,7 +1008,6 @@ function common_enqueue_notice($notice)
$transports[] = 'plugin';
}
$xmpp = common_config('xmpp', 'enabled');
if ($xmpp) {
@ -1574,3 +1573,56 @@ function common_client_ip()
return array($proxy, $ip);
}
function common_url_to_nickname($url)
{
static $bad = array('query', 'user', 'password', 'port', 'fragment');
$parts = parse_url($url);
# If any of these parts exist, this won't work
foreach ($bad as $badpart) {
if (array_key_exists($badpart, $parts)) {
return null;
}
}
# We just have host and/or path
# If it's just a host...
if (array_key_exists('host', $parts) &&
(!array_key_exists('path', $parts) || strcmp($parts['path'], '/') == 0))
{
$hostparts = explode('.', $parts['host']);
# Try to catch common idiom of nickname.service.tld
if ((count($hostparts) > 2) &&
(strlen($hostparts[count($hostparts) - 2]) > 3) && # try to skip .co.uk, .com.au
(strcmp($hostparts[0], 'www') != 0))
{
return common_nicknamize($hostparts[0]);
} else {
# Do the whole hostname
return common_nicknamize($parts['host']);
}
} else {
if (array_key_exists('path', $parts)) {
# Strip starting, ending slashes
$path = preg_replace('@/$@', '', $parts['path']);
$path = preg_replace('@^/@', '', $path);
if (strpos($path, '/') === false) {
return common_nicknamize($path);
}
}
}
return null;
}
function common_nicknamize($str)
{
$str = preg_replace('/\W/', '', $str);
return strtolower($str);
}

View File

@ -218,6 +218,9 @@ class OStatusPlugin extends Plugin
$count = preg_match_all('/(\w+\.)*\w+@(\w+\.)*\w+(\w+\-\w+)*\.\w+/', $notice->content, $matches);
if ($count) {
foreach ($matches[0] as $webfinger) {
// FIXME: look up locally first
// Check to see if we've got an actual webfinger
$w = new Webfinger;
@ -238,6 +241,8 @@ class OStatusPlugin extends Plugin
continue;
}
// FIXME: this needs to go out in a queue handler
$xml = '<?xml version="1.0" encoding="UTF-8" ?>';
$xml .= $notice->asAtomEntry();

View File

@ -75,7 +75,6 @@ class Ostatus_profile extends Memcached_DataObject
public $created;
public $lastupdate;
public /*static*/ function staticGet($k, $v=null)
{
return parent::staticGet(__CLASS__, $k, $v);
@ -598,9 +597,10 @@ class Ostatus_profile extends Memcached_DataObject
// Double-check for oldies
// @fixme this could explode horribly for multiple feeds on a blog. sigh
$dupe = new Notice();
$dupe->uri = $notice->uri;
if ($dupe->find(true)) {
$dupe = Notice::staticGet('uri', $notice->uri);
if (!empty($dupe)) {
common_log(LOG_WARNING, __METHOD__ . ": tried to save dupe notice for entry {$notice->uri} of feed {$this->feeduri}");
continue;
}

View File

@ -438,49 +438,7 @@ class FinishopenidloginAction extends Action
function urlToNickname($openid)
{
static $bad = array('query', 'user', 'password', 'port', 'fragment');
$parts = parse_url($openid);
# If any of these parts exist, this won't work
foreach ($bad as $badpart) {
if (array_key_exists($badpart, $parts)) {
return null;
}
}
# We just have host and/or path
# If it's just a host...
if (array_key_exists('host', $parts) &&
(!array_key_exists('path', $parts) || strcmp($parts['path'], '/') == 0))
{
$hostparts = explode('.', $parts['host']);
# Try to catch common idiom of nickname.service.tld
if ((count($hostparts) > 2) &&
(strlen($hostparts[count($hostparts) - 2]) > 3) && # try to skip .co.uk, .com.au
(strcmp($hostparts[0], 'www') != 0))
{
return $this->nicknamize($hostparts[0]);
} else {
# Do the whole hostname
return $this->nicknamize($parts['host']);
}
} else {
if (array_key_exists('path', $parts)) {
# Strip starting, ending slashes
$path = preg_replace('@/$@', '', $parts['path']);
$path = preg_replace('@^/@', '', $path);
if (strpos($path, '/') === false) {
return $this->nicknamize($path);
}
}
}
return null;
return common_url_to_nickname($openid);
}
function xriToNickname($xri)
@ -510,7 +468,6 @@ class FinishopenidloginAction extends Action
function nicknamize($str)
{
$str = preg_replace('/\W/', '', $str);
return strtolower($str);
return common_nicknamize($str);
}
}