summaryrefslogtreecommitdiff
path: root/plugins/TwitterBridge/TwitterBridgePlugin.php
diff options
context:
space:
mode:
authorZach Copley <zach@status.net>2009-10-20 06:05:35 +0000
committerZach Copley <zach@status.net>2009-10-20 06:05:35 +0000
commit7539e26951ba9e1529d9a24a7a634861b7d080fe (patch)
tree0a29693316b05d2bddc5fdde6443a1b5b00a6742 /plugins/TwitterBridge/TwitterBridgePlugin.php
parent109a54c4f08177cce82ef0f4a4ec8cd41ed2ecec (diff)
- Make Twitter bridge work with unqueuemanager
- Add README
Diffstat (limited to 'plugins/TwitterBridge/TwitterBridgePlugin.php')
-rw-r--r--plugins/TwitterBridge/TwitterBridgePlugin.php42
1 files changed, 37 insertions, 5 deletions
diff --git a/plugins/TwitterBridge/TwitterBridgePlugin.php b/plugins/TwitterBridge/TwitterBridgePlugin.php
index 1a27c30cd..e69567fc7 100644
--- a/plugins/TwitterBridge/TwitterBridgePlugin.php
+++ b/plugins/TwitterBridge/TwitterBridgePlugin.php
@@ -29,6 +29,8 @@ if (!defined('STATUSNET')) {
exit(1);
}
+require_once INSTALLDIR . '/plugins/TwitterBridge/twitter.php';
+
/**
* Plugin for sending and importing Twitter statuses
*
@@ -104,11 +106,11 @@ class TwitterBridgePlugin extends Plugin
switch ($cls) {
case 'TwittersettingsAction':
case 'TwitterauthorizationAction':
- include_once INSTALLDIR.'/plugins/TwitterBridge/' .
+ include_once INSTALLDIR . '/plugins/TwitterBridge/' .
strtolower(mb_substr($cls, 0, -6)) . '.php';
return false;
case 'TwitterOAuthClient':
- include_once INSTALLDIR.'/plugins/TwitterBridge/twitteroauthclient.php';
+ include_once INSTALLDIR . '/plugins/TwitterBridge/twitteroauthclient.php';
return false;
default:
return true;
@@ -118,18 +120,48 @@ class TwitterBridgePlugin extends Plugin
/**
* Add a Twitter queue item for each notice
*
- * @param Notice $notice the notice
- * @param array $transports the list of transports (queues)
+ * @param Notice $notice the notice
+ * @param array &$transports the list of transports (queues)
*
* @return boolean hook return
*/
- function onStartEnqueueNotice($notice, $transports)
+ function onStartEnqueueNotice($notice, &$transports)
{
array_push($transports, 'twitter');
return true;
}
/**
+ * broadcast the message when not using queuehandler
+ *
+ * @param Notice &$notice the notice
+ * @param array $queue destination queue
+ *
+ * @return boolean hook return
+ */
+ function onUnqueueHandleNotice(&$notice, $queue)
+ {
+ if (($queue == 'twitter') && ($this->_isLocal($notice))) {
+ broadcast_twitter($notice);
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Determine whether the notice was locally created
+ *
+ * @param Notice $notice
+ *
+ * @return boolean locality
+ */
+ function _isLocal($notice)
+ {
+ return ($notice->is_local == Notice::LOCAL_PUBLIC ||
+ $notice->is_local == Notice::LOCAL_NONPUBLIC);
+ }
+
+ /**
* Add Twitter bridge daemons to the list of daemons to start
*
* @param array $daemons the list fo daemons to run