]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - scripts/publicqueuehandler.php
Changing opacity to 1 only on the hovered notice item
[quix0rs-gnu-social.git] / scripts / publicqueuehandler.php
index 081ce1e38b624c09b88aac8c39b5e7b0e84b8df2..b0fa22d438e6a66c0c3931e33965a739e4afe087 100755 (executable)
@@ -20,8 +20,8 @@
 
 # Abort if called from a web server
 if (isset($_SERVER) && array_key_exists('REQUEST_METHOD', $_SERVER)) {
-       print "This script must be run from the command line\n";
-       exit();
+    print "This script must be run from the command line\n";
+    exit();
 }
 
 define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
@@ -29,38 +29,43 @@ define('LACONICA', true);
 
 require_once(INSTALLDIR . '/lib/common.php');
 require_once(INSTALLDIR . '/lib/jabber.php');
-require_once(INSTALLDIR . '/lib/queuehandler.php');
+require_once(INSTALLDIR . '/lib/xmppqueuehandler.php');
 
 set_error_handler('common_error_handler');
 
-class PublicQueueHandler extends QueueHandler {
-       
-       function transport() {
-               return 'public';
-       }
-       
-       function start() {
-               # Low priority; we don't want to receive messages
-               $this->conn = jabber_connect($this->_id, NULL, -1);
-               return !is_null($this->conn);
-       }
+class PublicQueueHandler extends XmppQueueHandler
+{
+    
+    function transport()
+    {
+        return 'public';
+    }
+    
+    function handle_notice($notice)
+    {
+        try {
+            return jabber_public_notice($notice);
+        } catch (XMPPHP_Exception $e) {
+            $this->log(LOG_ERR, "Got an XMPPHP_Exception: " . $e->getMessage());
+            die($e->getMessage());
+        }
+    }
+}
 
-       function handle_notice($notice) {
-               return jabber_public_notice($notice);
-       }
-       
-       function finish() {
-       }
+// Abort immediately if xmpp is not enabled, otherwise the daemon chews up
+// lots of CPU trying to connect to unconfigured servers
+if (common_config('xmpp','enabled')==false) {
+    print "Aborting daemon - xmpp is disabled\n";
+    exit();
 }
 
+ini_set("max_execution_time", "0");
+ini_set("max_input_time", "0");
+set_time_limit(0);
 mb_internal_encoding('UTF-8');
 
 $resource = ($argc > 1) ? $argv[1] : (common_config('xmpp','resource') . '-public');
 
 $handler = new PublicQueueHandler($resource);
 
-if ($handler->start()) {
-       $handler->handle_queue();
-}
-
-$handler->finish();
+$handler->runOnce();