summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorEvan Prodromou <evan@status.net>2010-01-25 18:13:09 -0500
committerEvan Prodromou <evan@status.net>2010-01-25 18:13:09 -0500
commit663e4e02a1b3b1c104c2c3db19e524a486c3d981 (patch)
tree048e2f67c10f74e3b510646f7b955d45baa49253 /lib
parent1ab24832960eef698731cf0d3e72fccfa336392d (diff)
parente26a843caf9f6bb0d11a7128884db235ededcce0 (diff)
Merge branch 'master' into testing
Conflicts: lib/queuemanager.php
Diffstat (limited to 'lib')
-rw-r--r--lib/command.php4
-rw-r--r--lib/distribqueuehandler.php84
-rw-r--r--lib/mailhandler.php2
-rw-r--r--lib/oauthstore.php2
-rw-r--r--lib/queuemanager.php2
-rw-r--r--lib/util.php2
6 files changed, 90 insertions, 6 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