X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=plugins%2FTwitterBridge%2FTwitterBridgePlugin.php;h=29192cf53b05c8853ac87b8135153a5c5990e422;hb=894ef352591fe581909c01c46047bf530e59a984;hp=f5c3612506c6627410dc4b48842bdd20b915cb89;hpb=65eeb7cba530e45b8d8a25644505619e8af63971;p=quix0rs-gnu-social.git diff --git a/plugins/TwitterBridge/TwitterBridgePlugin.php b/plugins/TwitterBridge/TwitterBridgePlugin.php index f5c3612506..29192cf53b 100644 --- a/plugins/TwitterBridge/TwitterBridgePlugin.php +++ b/plugins/TwitterBridge/TwitterBridgePlugin.php @@ -111,7 +111,7 @@ class TwitterBridgePlugin extends Plugin */ function onRouterInitialized($m) { - $m->connect('admin/twitter', array('action' => 'twitteradminpanel')); + $m->connect('panel/twitter', array('action' => 'twitteradminpanel')); if (self::hasKeys()) { $m->connect( @@ -137,11 +137,11 @@ class TwitterBridgePlugin extends Plugin /* * Add a login tab for 'Sign in with Twitter' * - * @param Action &action the current action + * @param Action $action the current action * * @return void */ - function onEndLoginGroupNav(&$action) + function onEndLoginGroupNav($action) { $action_name = $action->trimmed('action'); @@ -160,11 +160,11 @@ class TwitterBridgePlugin extends Plugin /** * Add the Twitter Settings page to the Connect Settings menu * - * @param Action &$action The calling page + * @param Action $action The calling page * * @return boolean hook return */ - function onEndConnectSettingsNav(&$action) + function onEndConnectSettingsNav($action) { if (self::hasKeys()) { $action_name = $action->trimmed('action'); @@ -228,7 +228,7 @@ class TwitterBridgePlugin extends Plugin */ function onStartEnqueueNotice($notice, &$transports) { - if (self::hasKeys() && $notice->isLocal()) { + if (self::hasKeys() && $notice->isLocal() && $notice->inScope(null)) { // Avoid a possible loop if ($notice->source != 'twitter') { array_push($transports, 'twitter'); @@ -438,10 +438,14 @@ class TwitterBridgePlugin extends Plugin return true; } - $token = TwitterOAuthClient::unpackToken($flink->credentials); - $client = new TwitterOAuthClient($token->key, $token->secret); + try { + $token = TwitterOAuthClient::unpackToken($flink->credentials); + $client = new TwitterOAuthClient($token->key, $token->secret); - $client->statusesDestroy($n2s->status_id); + $client->statusesDestroy($n2s->status_id); + } catch (Exception $e) { + common_log(LOG_ERR, "Error attempting to delete bridged notice from Twitter: " . $e->getMessage()); + } $n2s->delete(); } @@ -475,10 +479,14 @@ class TwitterBridgePlugin extends Plugin return true; } - $token = TwitterOAuthClient::unpackToken($flink->credentials); - $client = new TwitterOAuthClient($token->key, $token->secret); + try { + $token = TwitterOAuthClient::unpackToken($flink->credentials); + $client = new TwitterOAuthClient($token->key, $token->secret); - $client->favoritesCreate($status_id); + $client->favoritesCreate($status_id); + } catch (Exception $e) { + common_log(LOG_ERR, "Error attempting to favorite bridged notice on Twitter: " . $e->getMessage()); + } return true; } @@ -511,11 +519,24 @@ class TwitterBridgePlugin extends Plugin return true; } - $token = TwitterOAuthClient::unpackToken($flink->credentials); - $client = new TwitterOAuthClient($token->key, $token->secret); + try { + $token = TwitterOAuthClient::unpackToken($flink->credentials); + $client = new TwitterOAuthClient($token->key, $token->secret); - $client->favoritesDestroy($status_id); + $client->favoritesDestroy($status_id); + } catch (Exception $e) { + common_log(LOG_ERR, "Error attempting to unfavorite bridged notice on Twitter: " . $e->getMessage()); + } + + return true; + } + function onStartGetProfileUri($profile, &$uri) + { + if (preg_match('!^https?://twitter.com/!', $profile->profileurl)) { + $uri = $profile->profileurl; + return false; + } return true; } }