X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=scripts%2Fombqueuehandler.php;h=1587192b6fb5b9c1532e6af18411fa76dbc44ba4;hb=db4ffca5350a11835c2c990f8d77d7cabb365a43;hp=28c76db9a6fa4ab11e760f23d63c2ac9e91ae176;hpb=cde3bc585fd7763a4840fc865f1cc4164c22293e;p=quix0rs-gnu-social.git diff --git a/scripts/ombqueuehandler.php b/scripts/ombqueuehandler.php index 28c76db9a6..1587192b6f 100755 --- a/scripts/ombqueuehandler.php +++ b/scripts/ombqueuehandler.php @@ -2,7 +2,7 @@ . */ -# 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(); -} - define('INSTALLDIR', realpath(dirname(__FILE__) . '/..')); -define('LACONICA', true); -require_once(INSTALLDIR . '/lib/common.php'); -require_once(INSTALLDIR . '/lib/omb.php'); -require_once(INSTALLDIR . '/lib/queuehandler.php'); +$shortoptions = 'i::'; +$longoptions = array('id::'); + +$helptext = <<is_remote($notice)) { - # It's fine, we're done with it. - return true; - } else { - return omb_broadcast_remote_subscribers($notice); - } - } - - function finish() { - } - - function is_remote($notice) { - $user = User::staticGet($notice->profile_id); - return !$user; - } -} +class OmbQueueHandler extends QueueHandler +{ -mb_internal_encoding('UTF-8'); + function transport() + { + return 'omb'; + } -$id = ($argc > 1) ? $argv[1] : NULL; + function start() + { + $this->log(LOG_INFO, "INITIALIZE"); + return true; + } -$handler = new OmbQueueHandler($id); + function handle_notice($notice) + { + if ($this->is_remote($notice)) { + $this->log(LOG_DEBUG, 'Ignoring remote notice ' . $notice->id); + return true; + } else { + return omb_broadcast_remote_subscribers($notice); + } + } -if ($handler->start()) { - $handler->handle_queue(); + function finish() + { + } + + function is_remote($notice) + { + $user = User::staticGet($notice->profile_id); + return is_null($user); + } } -$handler->finish(); +if (have_option('i')) { + $id = get_option_value('i'); +} else if (have_option('--id')) { + $id = get_option_value('--id'); +} else if (count($args) > 0) { + $id = $args[0]; +} else { + $id = null; +} + +$handler = new OmbQueueHandler($id); + +$handler->runOnce();