X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=lib%2Funqueuemanager.php;h=0540b767d218300c03c58bbfb603bd7b7dfc36f1;hb=a7df79ac073d3d6dad13cc0fa3cd1224c9bde933;hp=c5dc29d38640dd102602b0bd1ae56f7f3fca08ae;hpb=9d87313eaebe8240393ac300a435f3b1332c8849;p=quix0rs-gnu-social.git diff --git a/lib/unqueuemanager.php b/lib/unqueuemanager.php index c5dc29d386..0540b767d2 100644 --- a/lib/unqueuemanager.php +++ b/lib/unqueuemanager.php @@ -23,63 +23,33 @@ * @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://status.net/ */ -class UnQueueManager +class UnQueueManager extends QueueManager { - 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); - } - break; - case 'ping': - if ($this->_isLocal($notice)) { - require_once INSTALLDIR . '/lib/ping.php'; - return ping_broadcast_notice($notice); + /** + * 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 this specific manager just handles Notice objects anyway + * @param string $queue + */ + function enqueue($object, $transport) + { + try { + $handler = $this->getHandler($transport); + $handler->handle($object); + } catch (NoQueueHandlerException $e) { + if (Event::handle('UnqueueHandleNotice', array(&$object, $transport))) { + throw new ServerException("UnQueueManager: Unknown queue transport: $transport"); } - 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 +}