From 6a088afd4be4076a31e8713ed96ac62060bf7278 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Mon, 21 Sep 2009 14:29:43 -0400 Subject: you can add a daemon to getvaliddaemons --- scripts/getvaliddaemons.php | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) (limited to 'scripts') diff --git a/scripts/getvaliddaemons.php b/scripts/getvaliddaemons.php index 8f48e8e6f..92edacfd3 100755 --- a/scripts/getvaliddaemons.php +++ b/scripts/getvaliddaemons.php @@ -35,20 +35,31 @@ ENDOFHELP; require_once INSTALLDIR.'/scripts/commandline.inc'; +$daemons = array(); + if(common_config('xmpp','enabled')) { - echo "xmppdaemon.php jabberqueuehandler.php publicqueuehandler.php "; - echo "xmppconfirmhandler.php "; + $daemons[] = 'xmppdaemon.php'; + $daemons[] = 'jabberqueuehandler.php'; + $daemons[] = 'publicqueuehandler.php'; + $daemons[] = 'xmppconfirmhandler.php'; } if(common_config('twitterbridge','enabled')) { - echo "twitterstatusfetcher.php "; + $daemons[] = 'twitterstatusfetcher.php'; } -echo "ombqueuehandler.php "; +$daemons[] = 'ombqueuehandler.php'; if (common_config('twitter', 'enabled')) { - echo "twitterqueuehandler.php "; - echo "synctwitterfriends.php "; + $daemons[] = 'twitterqueuehandler.php'; + $daemons[] = 'synctwitterfriends.php'; } -echo "facebookqueuehandler.php "; -echo "pingqueuehandler.php "; +$daemons[] = 'facebookqueuehandler.php'; +$daemons[] = 'pingqueuehandler.php'; if (common_config('sms', 'enabled')) { - echo "smsqueuehandler.php "; + $daemons[] = 'smsqueuehandler.php'; +} + +if (Event::handle('GetValidDaemons', array(&$daemons))) { + foreach ($daemons as $daemon) { + print $daemon . ' '; + } + print "\n"; } -- cgit v1.2.3-54-g00ecf From 98924a80d776107a734b44027dda18094b1f093f Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Mon, 21 Sep 2009 14:39:22 -0400 Subject: 'easy' way to handle notices at queue time --- EVENTS.txt | 3 +++ lib/unqueuemanager.php | 3 +++ lib/util.php | 3 ++- scripts/pluginqueuehandler.php | 58 ++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 66 insertions(+), 1 deletion(-) create mode 100755 scripts/pluginqueuehandler.php (limited to 'scripts') diff --git a/EVENTS.txt b/EVENTS.txt index d3b58ffb0..2b16d43c0 100644 --- a/EVENTS.txt +++ b/EVENTS.txt @@ -268,3 +268,6 @@ UnqueueHandleNotice: Handle a notice when no queue manager is available 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 diff --git a/lib/unqueuemanager.php b/lib/unqueuemanager.php index 269ecdeaa..6cfe5bcbd 100644 --- a/lib/unqueuemanager.php +++ b/lib/unqueuemanager.php @@ -72,6 +72,9 @@ class UnQueueManager require_once(INSTALLDIR.'/lib/jabber.php'); jabber_broadcast_notice($notice); break; + case 'plugin': + Event::handle('HandleQueuedNotice', array(&$notice)); + break; default: if (Event::handle('UnqueueHandleNotice', array(&$notice, $queue))) { throw ServerException("UnQueueManager: Unknown queue: $queue"); diff --git a/lib/util.php b/lib/util.php index eb247562d..37744fc5b 100644 --- a/lib/util.php +++ b/lib/util.php @@ -897,7 +897,8 @@ function common_enqueue_notice($notice) 'twitter', 'facebook', 'ping'); - static $allTransports = array('sms'); + + static $allTransports = array('sms', 'plugin'); $transports = $allTransports; diff --git a/scripts/pluginqueuehandler.php b/scripts/pluginqueuehandler.php new file mode 100755 index 000000000..ae807db6a --- /dev/null +++ b/scripts/pluginqueuehandler.php @@ -0,0 +1,58 @@ +#!/usr/bin/env php +. + */ + +define('INSTALLDIR', realpath(dirname(__FILE__) . '/..')); + +$shortoptions = 'i::'; +$longoptions = array('id::'); + +$helptext = <<runOnce(); -- cgit v1.2.3-54-g00ecf From f6c70ea327a83f77acbca14bca32f262e6b3a098 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Mon, 21 Sep 2009 14:42:20 -0400 Subject: have to provide full path for daemons --- scripts/getvaliddaemons.php | 22 +++++++++++----------- scripts/startdaemons.sh | 2 +- 2 files changed, 12 insertions(+), 12 deletions(-) (limited to 'scripts') diff --git a/scripts/getvaliddaemons.php b/scripts/getvaliddaemons.php index 92edacfd3..684799a0e 100755 --- a/scripts/getvaliddaemons.php +++ b/scripts/getvaliddaemons.php @@ -38,23 +38,23 @@ require_once INSTALLDIR.'/scripts/commandline.inc'; $daemons = array(); if(common_config('xmpp','enabled')) { - $daemons[] = 'xmppdaemon.php'; - $daemons[] = 'jabberqueuehandler.php'; - $daemons[] = 'publicqueuehandler.php'; - $daemons[] = 'xmppconfirmhandler.php'; + $daemons[] = INSTALLDIR.'/scripts/xmppdaemon.php'; + $daemons[] = INSTALLDIR.'/scripts/jabberqueuehandler.php'; + $daemons[] = INSTALLDIR.'/scripts/publicqueuehandler.php'; + $daemons[] = INSTALLDIR.'/scripts/xmppconfirmhandler.php'; } if(common_config('twitterbridge','enabled')) { - $daemons[] = 'twitterstatusfetcher.php'; + $daemons[] = INSTALLDIR.'/scripts/twitterstatusfetcher.php'; } -$daemons[] = 'ombqueuehandler.php'; +$daemons[] = INSTALLDIR.'/scripts/ombqueuehandler.php'; if (common_config('twitter', 'enabled')) { - $daemons[] = 'twitterqueuehandler.php'; - $daemons[] = 'synctwitterfriends.php'; + $daemons[] = INSTALLDIR.'/scripts/twitterqueuehandler.php'; + $daemons[] = INSTALLDIR.'/scripts/synctwitterfriends.php'; } -$daemons[] = 'facebookqueuehandler.php'; -$daemons[] = 'pingqueuehandler.php'; +$daemons[] = INSTALLDIR.'/scripts/facebookqueuehandler.php'; +$daemons[] = INSTALLDIR.'/scripts/pingqueuehandler.php'; if (common_config('sms', 'enabled')) { - $daemons[] = 'smsqueuehandler.php'; + $daemons[] = INSTALLDIR.'/scripts/smsqueuehandler.php'; } if (Event::handle('GetValidDaemons', array(&$daemons))) { diff --git a/scripts/startdaemons.sh b/scripts/startdaemons.sh index 298162673..5fb75414d 100755 --- a/scripts/startdaemons.sh +++ b/scripts/startdaemons.sh @@ -40,7 +40,7 @@ DAEMONS=`php $DIR/getvaliddaemons.php $ARGSG` for f in $DAEMONS; do printf "Starting $f..."; - php $DIR/$f $ARGSD + php $f $ARGSD printf "DONE.\n" done -- cgit v1.2.3-54-g00ecf From fe4751de50f2c26953dca79ab51543f8adb12353 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Mon, 21 Sep 2009 14:44:16 -0400 Subject: add the plugin daemon --- scripts/getvaliddaemons.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'scripts') diff --git a/scripts/getvaliddaemons.php b/scripts/getvaliddaemons.php index 684799a0e..6dd019712 100755 --- a/scripts/getvaliddaemons.php +++ b/scripts/getvaliddaemons.php @@ -37,22 +37,27 @@ 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')) { $daemons[] = INSTALLDIR.'/scripts/xmppdaemon.php'; $daemons[] = INSTALLDIR.'/scripts/jabberqueuehandler.php'; $daemons[] = INSTALLDIR.'/scripts/publicqueuehandler.php'; $daemons[] = INSTALLDIR.'/scripts/xmppconfirmhandler.php'; } + if(common_config('twitterbridge','enabled')) { $daemons[] = INSTALLDIR.'/scripts/twitterstatusfetcher.php'; } -$daemons[] = INSTALLDIR.'/scripts/ombqueuehandler.php'; + if (common_config('twitter', 'enabled')) { $daemons[] = INSTALLDIR.'/scripts/twitterqueuehandler.php'; $daemons[] = INSTALLDIR.'/scripts/synctwitterfriends.php'; } -$daemons[] = INSTALLDIR.'/scripts/facebookqueuehandler.php'; -$daemons[] = INSTALLDIR.'/scripts/pingqueuehandler.php'; + if (common_config('sms', 'enabled')) { $daemons[] = INSTALLDIR.'/scripts/smsqueuehandler.php'; } -- cgit v1.2.3-54-g00ecf From bd8a2dbfd68289a4f025964647320f8ef5e857aa Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Mon, 24 Aug 2009 11:23:02 -0400 Subject: test script for schema code --- scripts/showtable.php | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 scripts/showtable.php (limited to 'scripts') diff --git a/scripts/showtable.php b/scripts/showtable.php new file mode 100644 index 000000000..30f0bb5a9 --- /dev/null +++ b/scripts/showtable.php @@ -0,0 +1,41 @@ +#!/usr/bin/env php +. + */ + +define('INSTALLDIR', realpath(dirname(__FILE__) . '/..')); + +$helptext = << +Shows the structure of a table + +END_OF_SHOWTABLE_HELP; + +require_once INSTALLDIR.'/scripts/commandline.inc'; + +if (count($args) != 1) { + show_help(); +} + +$name = $args[0]; + +$schema = Schema::get(); + +$td = $schema->getTableDef($name); + +print_r($td); -- cgit v1.2.3-54-g00ecf From e206324f245145a0e8c9ec0535cba1d62344ebf7 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Wed, 23 Sep 2009 09:20:04 -0400 Subject: statusize schema-related modules --- lib/schema.php | 18 +++++++++--------- scripts/showtable.php | 4 ++-- 2 files changed, 11 insertions(+), 11 deletions(-) (limited to 'scripts') diff --git a/lib/schema.php b/lib/schema.php index 624765eb2..d3b30aeeb 100644 --- a/lib/schema.php +++ b/lib/schema.php @@ -1,6 +1,6 @@ . * * @category Database - * @package Laconica - * @author Evan Prodromou - * @copyright 2009 Control Yourself, Inc. + * @package StatusNet + * @author Evan Prodromou + * @copyright 2009 StatusNet, Inc. * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 - * @link http://laconi.ca/ + * @link http://status.net/ */ -if (!defined('LACONICA')) { +if (!defined('STATUSNET')) { exit(1); } @@ -39,10 +39,10 @@ if (!defined('LACONICA')) { * utilities. * * @category Database - * @package Laconica - * @author Evan Prodromou + * @package StatusNet + * @author Evan Prodromou * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 - * @link http://laconi.ca/ + * @link http://status.net/ */ class Schema diff --git a/scripts/showtable.php b/scripts/showtable.php index 30f0bb5a9..eb18a98e2 100644 --- a/scripts/showtable.php +++ b/scripts/showtable.php @@ -1,8 +1,8 @@ #!/usr/bin/env php Date: Sun, 27 Sep 2009 13:58:48 +0200 Subject: fix for a misnamed variable in subscription function in the "create simulation data" script --- scripts/createsim.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/createsim.php b/scripts/createsim.php index 71ed3bf72..1266a9700 100644 --- a/scripts/createsim.php +++ b/scripts/createsim.php @@ -101,7 +101,7 @@ function newSub($i) $to = User::staticGet('nickname', $tunic); - if (empty($from)) { + if (empty($to)) { throw new Exception("Can't find user '$tunic'."); } -- cgit v1.2.3-54-g00ecf From 89ac81c34464b2fc4f54b643d0d95d12bac765ab Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Tue, 29 Sep 2009 17:25:52 -0400 Subject: remove string-checks from code using Notice::saveNew() --- actions/newnotice.php | 7 ------- actions/twitapistatuses.php | 5 ----- lib/facebookaction.php | 10 +++++----- lib/oauthstore.php | 5 +---- scripts/maildaemon.php | 9 +++++---- scripts/xmppdaemon.php | 11 +++++++---- 6 files changed, 18 insertions(+), 29 deletions(-) (limited to 'scripts') diff --git a/actions/newnotice.php b/actions/newnotice.php index 23ec2a1b5..d5b0332f4 100644 --- a/actions/newnotice.php +++ b/actions/newnotice.php @@ -255,13 +255,6 @@ class NewnoticeAction extends Action $notice = Notice::saveNew($user->id, $content_shortened, 'web', 1, ($replyto == 'false') ? null : $replyto); - if (is_string($notice)) { - if (isset($filename)) { - $this->deleteFile($filename); - } - $this->clientError($notice); - } - if (isset($mimetype)) { $this->attachFile($notice, $fileRecord); } diff --git a/actions/twitapistatuses.php b/actions/twitapistatuses.php index 2f10ff966..87043b182 100644 --- a/actions/twitapistatuses.php +++ b/actions/twitapistatuses.php @@ -297,11 +297,6 @@ class TwitapistatusesAction extends TwitterapiAction html_entity_decode($status, ENT_NOQUOTES, 'UTF-8'), $source, 1, $reply_to); - if (is_string($notice)) { - $this->serverError($notice); - return; - } - common_broadcast_notice($notice); $apidata['api_arg'] = $notice->id; } diff --git a/lib/facebookaction.php b/lib/facebookaction.php index 411f79594..3f3a8d3b0 100644 --- a/lib/facebookaction.php +++ b/lib/facebookaction.php @@ -468,11 +468,11 @@ class FacebookAction extends Action $replyto = $this->trimmed('inreplyto'); - $notice = Notice::saveNew($user->id, $content, - 'web', 1, ($replyto == 'false') ? null : $replyto); - - if (is_string($notice)) { - $this->showPage($notice); + try { + $notice = Notice::saveNew($user->id, $content, + 'web', 1, ($replyto == 'false') ? null : $replyto); + } catch (Exception $e) { + $this->showPage($e->getMessage()); return; } diff --git a/lib/oauthstore.php b/lib/oauthstore.php index e69a00f55..d617a7df7 100644 --- a/lib/oauthstore.php +++ b/lib/oauthstore.php @@ -156,7 +156,6 @@ class StatusNetOAuthDataStore extends OAuthDataStore return $this->new_access_token($consumer); } - /** * Revoke specified OAuth token * @@ -363,9 +362,7 @@ class StatusNetOAuthDataStore extends OAuthDataStore false, null, $omb_notice->getIdentifierURI()); - if (is_string($notice)) { - throw new Exception($notice); - } + common_broadcast_notice($notice, true); } diff --git a/scripts/maildaemon.php b/scripts/maildaemon.php index 5705cfd50..586bef624 100755 --- a/scripts/maildaemon.php +++ b/scripts/maildaemon.php @@ -260,10 +260,11 @@ class MailerDaemon function add_notice($user, $msg, $fileRecords) { - $notice = Notice::saveNew($user->id, $msg, 'mail'); - if (is_string($notice)) { - $this->log(LOG_ERR, $notice); - return $notice; + try { + $notice = Notice::saveNew($user->id, $msg, 'mail'); + } catch (Exception $e) { + $this->log(LOG_ERR, $e->getMessage()); + return $e->getMessage(); } foreach($fileRecords as $fileRecord){ $this->attachFile($notice, $fileRecord); diff --git a/scripts/xmppdaemon.php b/scripts/xmppdaemon.php index 1b1aec3e6..b2efc07c3 100755 --- a/scripts/xmppdaemon.php +++ b/scripts/xmppdaemon.php @@ -323,12 +323,15 @@ class XMPPDaemon extends Daemon mb_strlen($content_shortened))); return; } - $notice = Notice::saveNew($user->id, $content_shortened, 'xmpp'); - if (is_string($notice)) { - $this->log(LOG_ERR, $notice); - $this->from_site($user->jabber, $notice); + + try { + $notice = Notice::saveNew($user->id, $content_shortened, 'xmpp'); + } catch (Exception $e) { + $this->log(LOG_ERR, $e->getMessage()); + $this->from_site($user->jabber, $e->getMessage()); return; } + common_broadcast_notice($notice); $this->log(LOG_INFO, 'Added notice ' . $notice->id . ' from user ' . $user->nickname); -- cgit v1.2.3-54-g00ecf From d103522ff364098ed26305b31d1cb62f87de1318 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Thu, 1 Oct 2009 15:11:12 -0400 Subject: check the schema --- EVENTS.txt | 2 ++ README | 8 ++++++++ lib/common.php | 6 ++++++ lib/default.php | 3 ++- scripts/checkschema.php | 30 ++++++++++++++++++++++++++++++ 5 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 scripts/checkschema.php (limited to 'scripts') diff --git a/EVENTS.txt b/EVENTS.txt index e0d4bbd06..fbb2f36a7 100644 --- a/EVENTS.txt +++ b/EVENTS.txt @@ -283,3 +283,5 @@ StartShowHeadElements: Right after the tag EndShowHeadElements: Right before the tag; put