3 * StatusNet - the distributed open-source microblogging tool
4 * Copyright (C) 2008, 2009, StatusNet, Inc.
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU Affero General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Affero General Public License for more details.
16 * You should have received a copy of the GNU Affero General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); }
23 * Base class for queue handlers.
25 * As extensions of the Daemon class, each queue handler has the ability
26 * to launch itself in the background, at which point it'll pass control
27 * to the configured QueueManager class to poll for updates.
29 * Subclasses must override at least the following methods:
34 class DistribQueueHandler
37 * Return transport keyword which identifies items this queue handler
38 * services; must be defined for all subclasses.
40 * Must be 8 characters or less to fit in the queue_item database.
41 * ex "email", "jabber", "sms", "irc", ...
52 * Here's the meat of your queue handler -- you're handed a Notice
53 * object, which you may do as you will with.
55 * If this function indicates failure, a warning will be logged
56 * and the item is placed back in the queue to be re-run.
58 * @param Notice $notice
59 * @return boolean true on success, false on failure
61 function handle($notice)
63 // XXX: do we need to change this for remote users?
67 $groups = $notice->saveGroups();
69 $recipients = $notice->saveReplies();
71 $notice->addToInboxes($groups, $recipients);
75 Event::handle('EndNoticeSave', array($notice));
77 // Enqueue for other handlers
79 common_enqueue_notice($notice);