summaryrefslogtreecommitdiff
path: root/plugins/Facebook
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/Facebook')
-rw-r--r--plugins/Facebook/FacebookPlugin.php46
-rw-r--r--[-rwxr-xr-x]plugins/Facebook/facebookqueuehandler.php52
2 files changed, 22 insertions, 76 deletions
diff --git a/plugins/Facebook/FacebookPlugin.php b/plugins/Facebook/FacebookPlugin.php
index de91bf24a..4266b886d 100644
--- a/plugins/Facebook/FacebookPlugin.php
+++ b/plugins/Facebook/FacebookPlugin.php
@@ -114,6 +114,9 @@ class FacebookPlugin extends Plugin
case 'FBCSettingsNav':
include_once INSTALLDIR . '/plugins/Facebook/FBCSettingsNav.php';
return false;
+ case 'FacebookQueueHandler':
+ include_once INSTALLDIR . '/plugins/Facebook/facebookqueuehandler.php';
+ return false;
default:
return true;
}
@@ -508,50 +511,15 @@ class FacebookPlugin extends Plugin
}
/**
- * broadcast the message when not using queuehandler
+ * Register Facebook notice queue handler
*
- * @param Notice &$notice the notice
- * @param array $queue destination queue
+ * @param QueueManager $manager
*
* @return boolean hook return
*/
-
- function onUnqueueHandleNotice(&$notice, $queue)
- {
- if (($queue == 'facebook') && ($this->_isLocal($notice))) {
- facebookBroadcastNotice($notice);
- return false;
- }
- return true;
- }
-
- /**
- * Determine whether the notice was locally created
- *
- * @param Notice $notice the notice
- *
- * @return boolean locality
- */
-
- function _isLocal($notice)
- {
- return ($notice->is_local == Notice::LOCAL_PUBLIC ||
- $notice->is_local == Notice::LOCAL_NONPUBLIC);
- }
-
- /**
- * Add Facebook queuehandler to the list of daemons to start
- *
- * @param array $daemons the list fo daemons to run
- *
- * @return boolean hook return
- *
- */
-
- function onGetValidDaemons($daemons)
+ function onEndInitializeQueueManager($manager)
{
- array_push($daemons, INSTALLDIR .
- '/plugins/Facebook/facebookqueuehandler.php');
+ $manager->connect('facebook', 'FacebookQueueHandler');
return true;
}
diff --git a/plugins/Facebook/facebookqueuehandler.php b/plugins/Facebook/facebookqueuehandler.php
index e4ae7d4ee..1778690e5 100755..100644
--- a/plugins/Facebook/facebookqueuehandler.php
+++ b/plugins/Facebook/facebookqueuehandler.php
@@ -1,4 +1,3 @@
-#!/usr/bin/env php
<?php
/*
* StatusNet - the distributed open-source microblogging tool
@@ -18,21 +17,9 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-define('INSTALLDIR', realpath(dirname(__FILE__) . '/../..'));
+if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); }
-$shortoptions = 'i::';
-$longoptions = array('id::');
-
-$helptext = <<<END_OF_FACEBOOK_HELP
-Daemon script for pushing new notices to Facebook.
-
- -i --id Identity (default none)
-
-END_OF_FACEBOOK_HELP;
-
-require_once INSTALLDIR . '/scripts/commandline.inc';
require_once INSTALLDIR . '/plugins/Facebook/facebookutil.php';
-require_once INSTALLDIR . '/lib/queuehandler.php';
class FacebookQueueHandler extends QueueHandler
{
@@ -41,33 +28,24 @@ class FacebookQueueHandler extends QueueHandler
return 'facebook';
}
- function start()
- {
- $this->log(LOG_INFO, "INITIALIZE");
- return true;
- }
-
function handle_notice($notice)
{
- return facebookBroadcastNotice($notice);
+ if ($this->_isLocal($notice)) {
+ return facebookBroadcastNotice($notice);
+ }
+ return true;
}
- function finish()
+ /**
+ * Determine whether the notice was locally created
+ *
+ * @param Notice $notice the notice
+ *
+ * @return boolean locality
+ */
+ function _isLocal($notice)
{
+ return ($notice->is_local == Notice::LOCAL_PUBLIC ||
+ $notice->is_local == Notice::LOCAL_NONPUBLIC);
}
-
}
-
-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 FacebookQueueHandler($id);
-
-$handler->runOnce();