summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rw-r--r--scripts/checkschema.php30
-rw-r--r--scripts/createsim.php2
-rwxr-xr-xscripts/getvaliddaemons.php34
-rwxr-xr-xscripts/maildaemon.php31
-rwxr-xr-xscripts/ombqueuehandler.php2
-rwxr-xr-xscripts/pluginqueuehandler.php58
-rw-r--r--scripts/showtable.php41
-rwxr-xr-xscripts/startdaemons.sh2
-rwxr-xr-xscripts/xmppdaemon.php17
9 files changed, 185 insertions, 32 deletions
diff --git a/scripts/checkschema.php b/scripts/checkschema.php
new file mode 100644
index 000000000..bf52abe15
--- /dev/null
+++ b/scripts/checkschema.php
@@ -0,0 +1,30 @@
+#!/usr/bin/env php
+<?php
+/*
+ * StatusNet - a 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__) . '/..'));
+
+$helptext = <<<END_OF_CHECKSCHEMA_HELP
+Gives plugins a chance to update the database schema.
+
+END_OF_CHECKSCHEMA_HELP;
+
+require_once INSTALLDIR.'/scripts/commandline.inc';
+
+Event::handle('CheckSchema');
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'.");
}
diff --git a/scripts/getvaliddaemons.php b/scripts/getvaliddaemons.php
index 8f48e8e6f..6dd019712 100755
--- a/scripts/getvaliddaemons.php
+++ b/scripts/getvaliddaemons.php
@@ -35,20 +35,36 @@ ENDOFHELP;
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')) {
- echo "xmppdaemon.php jabberqueuehandler.php publicqueuehandler.php ";
- echo "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')) {
- echo "twitterstatusfetcher.php ";
+ $daemons[] = INSTALLDIR.'/scripts/twitterstatusfetcher.php';
}
-echo "ombqueuehandler.php ";
+
if (common_config('twitter', 'enabled')) {
- echo "twitterqueuehandler.php ";
- echo "synctwitterfriends.php ";
+ $daemons[] = INSTALLDIR.'/scripts/twitterqueuehandler.php';
+ $daemons[] = INSTALLDIR.'/scripts/synctwitterfriends.php';
}
-echo "facebookqueuehandler.php ";
-echo "pingqueuehandler.php ";
+
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";
}
diff --git a/scripts/maildaemon.php b/scripts/maildaemon.php
index 11911dcbd..586bef624 100755
--- a/scripts/maildaemon.php
+++ b/scripts/maildaemon.php
@@ -66,9 +66,10 @@ class MailerDaemon
}
$msg = $this->cleanup_msg($msg);
$msg = common_shorten_links($msg);
- if (mb_strlen($msg) > 140) {
- $this->error($from,_('That\'s too long. '.
- 'Max notice size is 140 chars.'));
+ if (Notice::contentTooLong($msg)) {
+ $this->error($from, sprintf(_('That\'s too long. '.
+ 'Max notice size is %d chars.'),
+ Notice::maxContent()));
}
$fileRecords = array();
foreach($attachments as $attachment){
@@ -78,9 +79,9 @@ class MailerDaemon
die('error() should trigger an exception before reaching here.');
}
$filename = $this->saveFile($user, $attachment,$mimetype);
-
+
fclose($attachment);
-
+
if (empty($filename)) {
$this->error($from,_('Couldn\'t save file.'));
}
@@ -96,9 +97,10 @@ class MailerDaemon
$short_fileurl = common_shorten_url($fileurl);
$msg .= ' ' . $short_fileurl;
- if (mb_strlen($msg) > 140) {
+ if (Notice::contentTooLong($msg)) {
$this->deleteFile($filename);
- $this->error($from,_('Max notice size is 140 chars, including attachment URL.'));
+ $this->error($from, sprintf(_('Max notice size is %d chars, including attachment URL.'),
+ Notice::maxContent()));
}
// Also, not sure this is necessary -- Zach
@@ -123,7 +125,7 @@ class MailerDaemon
$stream = stream_get_meta_data($attachment);
if (copy($stream['uri'], $filepath) && chmod($filepath,0664)) {
return $filename;
- } else {
+ } else {
$this->error(null,_('File could not be moved to destination directory.' . $stream['uri'] . ' ' . $filepath));
}
}
@@ -152,7 +154,7 @@ class MailerDaemon
}
function maybeAddRedir($file_id, $url)
- {
+ {
$file_redir = File_redirection::staticGet('url', $url);
if (empty($file_redir)) {
@@ -258,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);
@@ -273,7 +276,7 @@ class MailerDaemon
}
function attachFile($notice, $filerec)
- {
+ {
File_to_post::processNew($filerec->id, $notice->id);
$this->maybeAddRedir($filerec->id,
diff --git a/scripts/ombqueuehandler.php b/scripts/ombqueuehandler.php
index 8e685f1c8..be33b9821 100755
--- a/scripts/ombqueuehandler.php
+++ b/scripts/ombqueuehandler.php
@@ -57,7 +57,7 @@ class OmbQueueHandler extends QueueHandler
$this->log(LOG_DEBUG, 'Ignoring remote notice ' . $notice->id);
return true;
} else {
- return omb_broadcast_remote_subscribers($notice);
+ return omb_broadcast_notice($notice);
}
}
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
+<?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();
diff --git a/scripts/showtable.php b/scripts/showtable.php
new file mode 100644
index 000000000..eb18a98e2
--- /dev/null
+++ b/scripts/showtable.php
@@ -0,0 +1,41 @@
+#!/usr/bin/env php
+<?php
+/*
+ * StatusNet - a 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__) . '/..'));
+
+$helptext = <<<END_OF_SHOWTABLE_HELP
+showtable.php <tablename>
+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);
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
diff --git a/scripts/xmppdaemon.php b/scripts/xmppdaemon.php
index 9e621e725..b2efc07c3 100755
--- a/scripts/xmppdaemon.php
+++ b/scripts/xmppdaemon.php
@@ -316,17 +316,22 @@ class XMPPDaemon extends Daemon
{
$body = trim($pl['body']);
$content_shortened = common_shorten_links($body);
- if (mb_strlen($content_shortened) > 140) {
+ if (Notice::contentTooLong($content_shortened)) {
$from = jabber_normalize_jid($pl['from']);
- $this->from_site($from, "Message too long - maximum is 140 characters, you sent ".mb_strlen($content_shortened));
+ $this->from_site($from, sprintf(_("Message too long - maximum is %d characters, you sent %d"),
+ Notice::maxContent(),
+ 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);