summaryrefslogtreecommitdiff
path: root/plugins/TwitterBridge/TwitterBridgePlugin.php
diff options
context:
space:
mode:
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