X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=lib%2Funqueuemanager.php;h=785de7c8ce25b629a7665fbb1ab3df22e19ab997;hb=746e658f3e398948fe8c3f047e2b35ef6aa7ebd5;hp=920313c0c0c25479c766271039f8e43a3532f19b;hpb=a809c200a64e4bb6d6ca3f21c63fe7ce962c5ae1;p=quix0rs-gnu-social.git diff --git a/lib/unqueuemanager.php b/lib/unqueuemanager.php index 920313c0c0..785de7c8ce 100644 --- a/lib/unqueuemanager.php +++ b/lib/unqueuemanager.php @@ -1,6 +1,6 @@ . * * @category QueueManager - * @package Laconica - * @author Evan Prodromou - * @author Sarven Capadisli - * @copyright 2009 Control Yourself, Inc. + * @package StatusNet + * @author Evan Prodromou + * @author Sarven Capadisli + * @author Brion Vibber + * @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/ */ -class UnQueueManager +class UnQueueManager extends QueueManager { + + /** + * Dummy queue storage manager: instead of saving events for later, + * we just process them immediately. This is only suitable for events + * that can be processed quickly and don't need polling or long-running + * connections to another server such as XMPP. + * + * @param Notice $object + * @param string $queue + */ function enqueue($object, $queue) { $notice = $object; - - switch ($queue) - { - case 'omb': - if ($this->_isLocal($notice)) { - require_once(INSTALLDIR.'/lib/omb.php'); - omb_broadcast_notice($notice); - } - break; - case 'public': - if ($this->_isLocal($notice)) { - require_once(INSTALLDIR.'/lib/jabber.php'); - jabber_public_notice($notice); - } - break; - case 'twitter': - if ($this->_isLocal($notice)) { - broadcast_twitter($notice); - } - break; - case 'facebook': - if ($this->_isLocal($notice)) { - require_once INSTALLDIR . '/lib/facebookutil.php'; - return facebookBroadcastNotice($notice); + + $handler = $this->getHandler($queue); + if ($handler) { + $handler->handle($notice); + } else { + if (Event::handle('UnqueueHandleNotice', array(&$notice, $queue))) { + throw new ServerException("UnQueueManager: Unknown queue: $queue"); } - break; - case 'ping': - if ($this->_isLocal($notice)) { - require_once INSTALLDIR . '/lib/ping.php'; - return ping_broadcast_notice($notice); - } - case 'sms': - require_once(INSTALLDIR.'/lib/mail.php'); - mail_broadcast_notice_sms($notice); - break; - case 'jabber': - require_once(INSTALLDIR.'/lib/jabber.php'); - jabber_broadcast_notice($notice); - break; - default: - throw ServerException("UnQueueManager: Unknown queue: $type"); } } - - function _isLocal($notice) - { - return ($notice->is_local == Notice::LOCAL_PUBLIC || - $notice->is_local == Notice::LOCAL_NONPUBLIC); - } -} \ No newline at end of file +}