Merge branch '0.9.x' of git://gitorious.org/statusnet/mainline into 0.9.x

This commit is contained in:
Brion Vibber 2009-09-24 12:09:01 -07:00
commit 987f7ead94
7 changed files with 131 additions and 25 deletions

View File

@ -254,3 +254,20 @@ StartApiRss: after the rss <channel> element is started
StartApiAtom: after the <feed> element is started StartApiAtom: after the <feed> element is started
- $action: action object being shown - $action: action object being shown
StartEnqueueNotice: about to add a notice to the queues (good place to add a new transport)
- $notice: the notice being added
- &$transports: modifiable list of transports (as strings) to queue for
EndEnqueueNotice: after adding a notice to the queues
- $notice: the notice being added
- $transports: modifiable list of transports to use
UnqueueHandleNotice: Handle a notice when no queue manager is available
- $notice: the notice to handle
- $queue: the "queue" that is being executed
GetValidDaemons: Just before determining which daemons to run
- &$daemons: modifiable list of daemon scripts to run, filenames relative to scripts/
HandleQueuedNotice: Handle a queued notice at queue time (or immediately if no queue)
- &$notice: notice to handle

View File

@ -72,8 +72,13 @@ class UnQueueManager
require_once(INSTALLDIR.'/lib/jabber.php'); require_once(INSTALLDIR.'/lib/jabber.php');
jabber_broadcast_notice($notice); jabber_broadcast_notice($notice);
break; break;
case 'plugin':
Event::handle('HandleQueuedNotice', array(&$notice));
break;
default: default:
throw ServerException("UnQueueManager: Unknown queue: $type"); if (Event::handle('UnqueueHandleNotice', array(&$notice, $queue))) {
throw ServerException("UnQueueManager: Unknown queue: $queue");
}
} }
} }

View File

@ -391,10 +391,10 @@ function common_render_content($text, $notice)
{ {
$r = common_render_text($text); $r = common_render_text($text);
$id = $notice->profile_id; $id = $notice->profile_id;
$r = preg_replace('/(^|\s+)@([A-Za-z0-9]{1,64})/e', "'\\1@'.common_at_link($id, '\\2')", $r); $r = preg_replace('/(^|[\s\.\,\:\;]+)@([A-Za-z0-9]{1,64})/e', "'\\1@'.common_at_link($id, '\\2')", $r);
$r = preg_replace('/^T ([A-Z0-9]{1,64}) /e', "'T '.common_at_link($id, '\\1').' '", $r); $r = preg_replace('/^T ([A-Z0-9]{1,64}) /e', "'T '.common_at_link($id, '\\1').' '", $r);
$r = preg_replace('/(^|\s+)@#([A-Za-z0-9]{1,64})/e', "'\\1@#'.common_at_hash_link($id, '\\2')", $r); $r = preg_replace('/(^|[\s\.\,\:\;]+)@#([A-Za-z0-9]{1,64})/e', "'\\1@#'.common_at_hash_link($id, '\\2')", $r);
$r = preg_replace('/(^|\s)!([A-Za-z0-9]{1,64})/e', "'\\1!'.common_group_link($id, '\\2')", $r); $r = preg_replace('/(^|[\s\.\,\:\;]+)!([A-Za-z0-9]{1,64})/e', "'\\1!'.common_group_link($id, '\\2')", $r);
return $r; return $r;
} }
@ -493,7 +493,7 @@ function callback_helper($matches, $callback, $notice_id) {
}while($original_url!=$url); }while($original_url!=$url);
if(empty($notice_id)){ if(empty($notice_id)){
$result = call_user_func_array($callback,$url); $result = call_user_func_array($callback, array($url));
}else{ }else{
$result = call_user_func_array($callback, array(array($url,$notice_id)) ); $result = call_user_func_array($callback, array(array($url,$notice_id)) );
} }
@ -536,7 +536,7 @@ function common_linkify($url) {
throw new ServerException("Can't linkify url '$url'"); throw new ServerException("Can't linkify url '$url'");
} }
$attrs = array('href' => $canon, 'rel' => 'external'); $attrs = array('href' => $canon, 'title' => $longurl, 'rel' => 'external');
$is_attachment = false; $is_attachment = false;
$attachment_id = null; $attachment_id = null;
@ -897,7 +897,8 @@ function common_enqueue_notice($notice)
'twitter', 'twitter',
'facebook', 'facebook',
'ping'); 'ping');
static $allTransports = array('sms');
static $allTransports = array('sms', 'plugin');
$transports = $allTransports; $transports = $allTransports;
@ -915,11 +916,16 @@ function common_enqueue_notice($notice)
} }
} }
$qm = QueueManager::get(); if (Event::handle('StartEnqueueNotice', array($notice, &$transports))) {
foreach ($transports as $transport) $qm = QueueManager::get();
{
$qm->enqueue($notice, $transport); foreach ($transports as $transport)
{
$qm->enqueue($notice, $transport);
}
Event::handle('EndEnqueueNotice', array($notice, $transports));
} }
return true; return true;
@ -1374,10 +1380,14 @@ function common_shorten_url($long_url)
$svc = $user->urlshorteningservice; $svc = $user->urlshorteningservice;
} }
global $_shorteners; global $_shorteners;
if(! $_shorteners[$svc]){ if (!isset($_shorteners[$svc])) {
//the user selected service doesn't exist, so default to ur1.ca //the user selected service doesn't exist, so default to ur1.ca
$svc = 'ur1.ca'; $svc = 'ur1.ca';
} }
if (!isset($_shorteners[$svc])) {
// no shortener plugins installed.
return $long_url;
}
$reflectionObj = new ReflectionClass($_shorteners[$svc]['callInfo'][0]); $reflectionObj = new ReflectionClass($_shorteners[$svc]['callInfo'][0]);
$short_url_service = $reflectionObj->newInstanceArgs($_shorteners[$svc]['callInfo'][1]); $short_url_service = $reflectionObj->newInstanceArgs($_shorteners[$svc]['callInfo'][1]);

View File

@ -31,7 +31,7 @@ if (!defined('STATUSNET')) {
exit(1); exit(1);
} }
define('DEFAULT_HUB','http://2pubsubhubbub.appspot.com'); define('DEFAULT_HUB','http://pubsubhubbub.appspot.com');
require_once(INSTALLDIR.'/plugins/PubSubHubBub/publisher.php'); require_once(INSTALLDIR.'/plugins/PubSubHubBub/publisher.php');
@ -59,7 +59,7 @@ class PubSubHubBubPlugin extends Plugin
$action->element('atom:link',array('rel'=>'hub','href'=>$this->hub),null); $action->element('atom:link',array('rel'=>'hub','href'=>$this->hub),null);
} }
function onEndNoticeSave($notice){ function onHandleQueuedNotice($notice){
$publisher = new Publisher($this->hub); $publisher = new Publisher($this->hub);
$feeds = array(); $feeds = array();

View File

@ -35,20 +35,36 @@ ENDOFHELP;
require_once INSTALLDIR.'/scripts/commandline.inc'; require_once INSTALLDIR.'/scripts/commandline.inc';
$daemons = array();
$daemons[] = INSTALLDIR.'/scripts/pluginqueuehandler.php';
$daemons[] = INSTALLDIR.'/scripts/ombqueuehandler.php';
$daemons[] = INSTALLDIR.'/scripts/facebookqueuehandler.php';
$daemons[] = INSTALLDIR.'/scripts/pingqueuehandler.php';
if(common_config('xmpp','enabled')) { if(common_config('xmpp','enabled')) {
echo "xmppdaemon.php jabberqueuehandler.php publicqueuehandler.php "; $daemons[] = INSTALLDIR.'/scripts/xmppdaemon.php';
echo "xmppconfirmhandler.php "; $daemons[] = INSTALLDIR.'/scripts/jabberqueuehandler.php';
$daemons[] = INSTALLDIR.'/scripts/publicqueuehandler.php';
$daemons[] = INSTALLDIR.'/scripts/xmppconfirmhandler.php';
} }
if(common_config('twitterbridge','enabled')) { if(common_config('twitterbridge','enabled')) {
echo "twitterstatusfetcher.php "; $daemons[] = INSTALLDIR.'/scripts/twitterstatusfetcher.php';
} }
echo "ombqueuehandler.php ";
if (common_config('twitter', 'enabled')) { if (common_config('twitter', 'enabled')) {
echo "twitterqueuehandler.php "; $daemons[] = INSTALLDIR.'/scripts/twitterqueuehandler.php';
echo "synctwitterfriends.php "; $daemons[] = INSTALLDIR.'/scripts/synctwitterfriends.php';
} }
echo "facebookqueuehandler.php ";
echo "pingqueuehandler.php ";
if (common_config('sms', 'enabled')) { if (common_config('sms', 'enabled')) {
echo "smsqueuehandler.php "; $daemons[] = INSTALLDIR.'/scripts/smsqueuehandler.php';
}
if (Event::handle('GetValidDaemons', array(&$daemons))) {
foreach ($daemons as $daemon) {
print $daemon . ' ';
}
print "\n";
} }

58
scripts/pluginqueuehandler.php Executable file
View File

@ -0,0 +1,58 @@
#!/usr/bin/env php
<?php
/*
* StatusNet - the distributed open-source microblogging tool
* Copyright (C) 2008, 2009, StatusNet, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
$shortoptions = 'i::';
$longoptions = array('id::');
$helptext = <<<END_OF_OMB_HELP
Daemon script for letting plugins handle stuff at queue time
-i --id Identity (default none)
END_OF_OMB_HELP;
require_once INSTALLDIR.'/scripts/commandline.inc';
require_once INSTALLDIR . '/lib/queuehandler.php';
class PluginQueueHandler extends QueueHandler
{
function transport()
{
return 'plugin';
}
function handle_notice($notice)
{
Event::handle('HandleQueuedNotice', array(&$notice));
return true;
}
}
if (have_option('i', 'id')) {
$id = get_option_value('i', 'id');
} else {
$id = null;
}
$handler = new PluginQueueHandler($id);
$handler->runOnce();

View File

@ -40,7 +40,7 @@ DAEMONS=`php $DIR/getvaliddaemons.php $ARGSG`
for f in $DAEMONS; do for f in $DAEMONS; do
printf "Starting $f..."; printf "Starting $f...";
php $DIR/$f $ARGSD php $f $ARGSD
printf "DONE.\n" printf "DONE.\n"
done done