diff options
author | Sarven Capadisli <csarven@status.net> | 2010-01-26 01:58:58 +0100 |
---|---|---|
committer | Sarven Capadisli <csarven@status.net> | 2010-01-26 01:58:58 +0100 |
commit | 687b1719d1acd782eb9ecf36e406bc03d2d6e299 (patch) | |
tree | 3f921b41fcee1e99c070d26474b0de3faa0673d6 /lib | |
parent | d17b7fa19ba2bfec9aa3d734c0f30e001256ddc0 (diff) | |
parent | 663e4e02a1b3b1c104c2c3db19e524a486c3d981 (diff) |
Merge branch 'testing' of git@gitorious.org:statusnet/mainline into testing
Diffstat (limited to 'lib')
-rw-r--r-- | lib/command.php | 4 | ||||
-rw-r--r-- | lib/distribqueuehandler.php | 84 | ||||
-rw-r--r-- | lib/mailhandler.php | 2 | ||||
-rw-r--r-- | lib/oauthstore.php | 2 | ||||
-rw-r--r-- | lib/queuemanager.php | 2 | ||||
-rw-r--r-- | lib/util.php | 2 | ||||
-rw-r--r-- | lib/xmppmanager.php | 4 |
7 files changed, 92 insertions, 8 deletions
diff --git a/lib/command.php b/lib/command.php index c0a32e1b1..2a51fd687 100644 --- a/lib/command.php +++ b/lib/command.php @@ -422,7 +422,7 @@ class RepeatCommand extends Command $repeat = $notice->repeat($this->user->id, $channel->source); if ($repeat) { - common_broadcast_notice($repeat); + $channel->output($this->user, sprintf(_('Notice from %s repeated'), $recipient->nickname)); } else { $channel->error($this->user, _('Error repeating notice.')); @@ -492,7 +492,7 @@ class ReplyCommand extends Command } else { $channel->error($this->user, _('Error saving notice.')); } - common_broadcast_notice($notice); + } } diff --git a/lib/distribqueuehandler.php b/lib/distribqueuehandler.php new file mode 100644 index 000000000..f458d238d --- /dev/null +++ b/lib/distribqueuehandler.php @@ -0,0 +1,84 @@ +<?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/>. + */ + +if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); } + +/** + * Base class for queue handlers. + * + * As extensions of the Daemon class, each queue handler has the ability + * to launch itself in the background, at which point it'll pass control + * to the configured QueueManager class to poll for updates. + * + * Subclasses must override at least the following methods: + * - transport + * - handle_notice + */ + +class DistribQueueHandler +{ + /** + * Return transport keyword which identifies items this queue handler + * services; must be defined for all subclasses. + * + * Must be 8 characters or less to fit in the queue_item database. + * ex "email", "jabber", "sms", "irc", ... + * + * @return string + */ + + function transport() + { + return 'distrib'; + } + + /** + * Here's the meat of your queue handler -- you're handed a Notice + * object, which you may do as you will with. + * + * If this function indicates failure, a warning will be logged + * and the item is placed back in the queue to be re-run. + * + * @param Notice $notice + * @return boolean true on success, false on failure + */ + function handle($notice) + { + // XXX: do we need to change this for remote users? + + $notice->saveTags(); + + $groups = $notice->saveGroups(); + + $recipients = $notice->saveReplies(); + + $notice->addToInboxes($groups, $recipients); + + $notice->saveUrls(); + + Event::handle('EndNoticeSave', array($notice)); + + // Enqueue for other handlers + + common_enqueue_notice($notice); + + return true; + } +} + diff --git a/lib/mailhandler.php b/lib/mailhandler.php index 85be89f18..890f6d5b4 100644 --- a/lib/mailhandler.php +++ b/lib/mailhandler.php @@ -160,7 +160,7 @@ class MailHandler foreach($mediafiles as $mf){ $mf->attachToNotice($notice); } - common_broadcast_notice($notice); + $this->log(LOG_INFO, 'Added notice ' . $notice->id . ' from user ' . $user->nickname); return true; diff --git a/lib/oauthstore.php b/lib/oauthstore.php index df63cc151..b30fb49d5 100644 --- a/lib/oauthstore.php +++ b/lib/oauthstore.php @@ -362,7 +362,7 @@ class StatusNetOAuthDataStore extends OAuthDataStore array('is_local' => Notice::REMOTE_OMB, 'uri' => $omb_notice->getIdentifierURI())); - common_broadcast_notice($notice, true); + } /** diff --git a/lib/queuemanager.php b/lib/queuemanager.php index 4eb39bfa8..1bc8de1f7 100644 --- a/lib/queuemanager.php +++ b/lib/queuemanager.php @@ -217,6 +217,7 @@ abstract class QueueManager extends IoManager $this->connect('plugin', 'PluginQueueHandler'); $this->connect('omb', 'OmbQueueHandler'); $this->connect('ping', 'PingQueueHandler'); + $this->connect('distrib', 'DistribQueueHandler'); if (common_config('sms', 'enabled')) { $this->connect('sms', 'SmsQueueHandler'); } @@ -224,7 +225,6 @@ abstract class QueueManager extends IoManager // XMPP output handlers... $this->connect('jabber', 'JabberQueueHandler'); $this->connect('public', 'PublicQueueHandler'); - // @fixme this should get an actual queue //$this->connect('confirm', 'XmppConfirmHandler'); diff --git a/lib/util.php b/lib/util.php index fb3b8be87..4312f9876 100644 --- a/lib/util.php +++ b/lib/util.php @@ -987,7 +987,7 @@ function common_redirect($url, $code=307) function common_broadcast_notice($notice, $remote=false) { - return common_enqueue_notice($notice); + // DO NOTHING! } // Stick the notice on the queue diff --git a/lib/xmppmanager.php b/lib/xmppmanager.php index 299175dd7..985e7c32e 100644 --- a/lib/xmppmanager.php +++ b/lib/xmppmanager.php @@ -101,7 +101,7 @@ class XmppManager extends IoManager $this->conn->addEventHandler('reconnect', 'handle_reconnect', $this); $this->conn->setReconnectTimeout(600); - jabber_send_presence("Send me a message to post a notice", 'available', null, 'available', -1); + jabber_send_presence("Send me a message to post a notice", 'available', null, 'available', 100); return !is_null($this->conn); } @@ -233,7 +233,7 @@ class XmppManager extends IoManager common_log(LOG_NOTICE, 'XMPP reconnected'); $this->conn->processUntil('session_start'); - $this->conn->presence(null, 'available', null, 'available', -1); + $this->conn->presence(null, 'available', null, 'available', 100); } |