Merge branch 'testing' of git@gitorious.org:statusnet/mainline into testing
This commit is contained in:
commit
385fb94723
54
lib/util.php
54
lib/util.php
@ -1007,7 +1007,6 @@ function common_enqueue_notice($notice)
|
|||||||
if (Event::hasHandler('HandleQueuedNotice')) {
|
if (Event::hasHandler('HandleQueuedNotice')) {
|
||||||
$transports[] = 'plugin';
|
$transports[] = 'plugin';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$xmpp = common_config('xmpp', 'enabled');
|
$xmpp = common_config('xmpp', 'enabled');
|
||||||
|
|
||||||
@ -1574,3 +1573,56 @@ function common_client_ip()
|
|||||||
|
|
||||||
return array($proxy, $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);
|
||||||
|
}
|
||||||
|
@ -218,6 +218,9 @@ class OStatusPlugin extends Plugin
|
|||||||
$count = preg_match_all('/(\w+\.)*\w+@(\w+\.)*\w+(\w+\-\w+)*\.\w+/', $notice->content, $matches);
|
$count = preg_match_all('/(\w+\.)*\w+@(\w+\.)*\w+(\w+\-\w+)*\.\w+/', $notice->content, $matches);
|
||||||
if ($count) {
|
if ($count) {
|
||||||
foreach ($matches[0] as $webfinger) {
|
foreach ($matches[0] as $webfinger) {
|
||||||
|
|
||||||
|
// FIXME: look up locally first
|
||||||
|
|
||||||
// Check to see if we've got an actual webfinger
|
// Check to see if we've got an actual webfinger
|
||||||
$w = new Webfinger;
|
$w = new Webfinger;
|
||||||
|
|
||||||
@ -238,6 +241,8 @@ class OStatusPlugin extends Plugin
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FIXME: this needs to go out in a queue handler
|
||||||
|
|
||||||
$xml = '<?xml version="1.0" encoding="UTF-8" ?>';
|
$xml = '<?xml version="1.0" encoding="UTF-8" ?>';
|
||||||
$xml .= $notice->asAtomEntry();
|
$xml .= $notice->asAtomEntry();
|
||||||
|
|
||||||
|
@ -29,15 +29,15 @@ PuSH subscription flow:
|
|||||||
generate random verification token
|
generate random verification token
|
||||||
save to verify_token
|
save to verify_token
|
||||||
sends a sub request to the hub...
|
sends a sub request to the hub...
|
||||||
|
|
||||||
main/push/callback
|
main/push/callback
|
||||||
hub sends confirmation back to us via GET
|
hub sends confirmation back to us via GET
|
||||||
We verify the request, then echo back the challenge.
|
We verify the request, then echo back the challenge.
|
||||||
On our end, we save the time we subscribed and the lease expiration
|
On our end, we save the time we subscribed and the lease expiration
|
||||||
|
|
||||||
main/push/callback
|
main/push/callback
|
||||||
hub sends us updates via POST
|
hub sends us updates via POST
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class FeedDBException extends FeedSubException
|
class FeedDBException extends FeedSubException
|
||||||
@ -75,7 +75,6 @@ class Ostatus_profile extends Memcached_DataObject
|
|||||||
public $created;
|
public $created;
|
||||||
public $lastupdate;
|
public $lastupdate;
|
||||||
|
|
||||||
|
|
||||||
public /*static*/ function staticGet($k, $v=null)
|
public /*static*/ function staticGet($k, $v=null)
|
||||||
{
|
{
|
||||||
return parent::staticGet(__CLASS__, $k, $v);
|
return parent::staticGet(__CLASS__, $k, $v);
|
||||||
@ -107,7 +106,7 @@ class Ostatus_profile extends Memcached_DataObject
|
|||||||
'created' => DB_DATAOBJECT_STR + DB_DATAOBJECT_DATE + DB_DATAOBJECT_TIME + DB_DATAOBJECT_NOTNULL,
|
'created' => DB_DATAOBJECT_STR + DB_DATAOBJECT_DATE + DB_DATAOBJECT_TIME + DB_DATAOBJECT_NOTNULL,
|
||||||
'lastupdate' => DB_DATAOBJECT_STR + DB_DATAOBJECT_DATE + DB_DATAOBJECT_TIME + DB_DATAOBJECT_NOTNULL);
|
'lastupdate' => DB_DATAOBJECT_STR + DB_DATAOBJECT_DATE + DB_DATAOBJECT_TIME + DB_DATAOBJECT_NOTNULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static function schemaDef()
|
static function schemaDef()
|
||||||
{
|
{
|
||||||
return array(new ColumnDef('id', 'integer',
|
return array(new ColumnDef('id', 'integer',
|
||||||
@ -486,7 +485,7 @@ class Ostatus_profile extends Memcached_DataObject
|
|||||||
}
|
}
|
||||||
if ($this->salmonuri) {
|
if ($this->salmonuri) {
|
||||||
$text = 'update'; // @fixme
|
$text = 'update'; // @fixme
|
||||||
$id = 'tag:' . common_config('site', 'server') .
|
$id = 'tag:' . common_config('site', 'server') .
|
||||||
':' . $verb .
|
':' . $verb .
|
||||||
':' . $actor->id .
|
':' . $actor->id .
|
||||||
':' . time(); // @fixme
|
':' . time(); // @fixme
|
||||||
@ -589,7 +588,7 @@ class Ostatus_profile extends Memcached_DataObject
|
|||||||
require_once "XML/Feed/Parser.php";
|
require_once "XML/Feed/Parser.php";
|
||||||
$feed = new XML_Feed_Parser($xml, false, false, true);
|
$feed = new XML_Feed_Parser($xml, false, false, true);
|
||||||
$munger = new FeedMunger($feed);
|
$munger = new FeedMunger($feed);
|
||||||
|
|
||||||
$hits = 0;
|
$hits = 0;
|
||||||
foreach ($feed as $index => $entry) {
|
foreach ($feed as $index => $entry) {
|
||||||
// @fixme this might sort in wrong order if we get multiple updates
|
// @fixme this might sort in wrong order if we get multiple updates
|
||||||
@ -598,9 +597,10 @@ class Ostatus_profile extends Memcached_DataObject
|
|||||||
|
|
||||||
// Double-check for oldies
|
// Double-check for oldies
|
||||||
// @fixme this could explode horribly for multiple feeds on a blog. sigh
|
// @fixme this could explode horribly for multiple feeds on a blog. sigh
|
||||||
$dupe = new Notice();
|
|
||||||
$dupe->uri = $notice->uri;
|
$dupe = Notice::staticGet('uri', $notice->uri);
|
||||||
if ($dupe->find(true)) {
|
|
||||||
|
if (!empty($dupe)) {
|
||||||
common_log(LOG_WARNING, __METHOD__ . ": tried to save dupe notice for entry {$notice->uri} of feed {$this->feeduri}");
|
common_log(LOG_WARNING, __METHOD__ . ": tried to save dupe notice for entry {$notice->uri} of feed {$this->feeduri}");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -438,49 +438,7 @@ class FinishopenidloginAction extends Action
|
|||||||
|
|
||||||
function urlToNickname($openid)
|
function urlToNickname($openid)
|
||||||
{
|
{
|
||||||
static $bad = array('query', 'user', 'password', 'port', 'fragment');
|
return common_url_to_nickname($openid);
|
||||||
|
|
||||||
$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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function xriToNickname($xri)
|
function xriToNickname($xri)
|
||||||
@ -510,7 +468,6 @@ class FinishopenidloginAction extends Action
|
|||||||
|
|
||||||
function nicknamize($str)
|
function nicknamize($str)
|
||||||
{
|
{
|
||||||
$str = preg_replace('/\W/', '', $str);
|
return common_nicknamize($str);
|
||||||
return strtolower($str);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user