From d994b4583a57afa9e0be4facb06e58166641cdf1 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Thu, 24 Mar 2011 18:41:25 -0700 Subject: [PATCH 1/5] TwitterBridge: discard outgoing queue items instead of retrying when Twitter API returns HTTP 400 or 404 error codes We get HTTP 400 for various cases of invalid data, where retrying doesn't help at all -- previously those would loop forever, or until something died at least. :) 400 is also used for rate limiting, but retrying *immediately* will just hit the rate limit again, so better to discard if we're going over for now. --- plugins/TwitterBridge/twitter.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/plugins/TwitterBridge/twitter.php b/plugins/TwitterBridge/twitter.php index f5a0b62588..2c68f89f16 100644 --- a/plugins/TwitterBridge/twitter.php +++ b/plugins/TwitterBridge/twitter.php @@ -320,7 +320,20 @@ function process_error($e, $flink, $notice) common_log(LOG_WARNING, $logmsg); + // http://dev.twitter.com/pages/responses_errors switch($code) { + case 400: + // Probably invalid data (bad Unicode chars or coords) that + // cannot be resolved by just sending again. + // + // It could also be rate limiting, but retrying immediately + // won't help much with that, so we'll discard for now. + // If a facility for retrying things later comes up in future, + // we can detect the rate-limiting headers and use that. + // + // Discard the message permanently. + return true; + break; case 401: // Probably a revoked or otherwise bad access token - nuke! remove_twitter_link($flink); @@ -330,6 +343,13 @@ function process_error($e, $flink, $notice) // User has exceeder her rate limit -- toss the notice return true; break; + case 404: + // Resource not found. Shouldn't happen much on posting, + // but just in case! + // + // Consider it a matter for tossing the notice. + return true; + break; default: // For every other case, it's probably some flakiness so try From 41e919f3cae981ebda69758b26f1f4e1ae9c0b28 Mon Sep 17 00:00:00 2001 From: Siebrand Mazeland Date: Fri, 25 Mar 2011 09:55:33 +0100 Subject: [PATCH 2/5] L10n update. Translator documentation added. Superfluous whitespace removed. --- plugins/TwitterBridge/twitter.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/plugins/TwitterBridge/twitter.php b/plugins/TwitterBridge/twitter.php index 2c68f89f16..396de22b09 100644 --- a/plugins/TwitterBridge/twitter.php +++ b/plugins/TwitterBridge/twitter.php @@ -83,7 +83,6 @@ function save_twitter_user($twitter_id, $screen_name) $screen_name, $oldname)); } - } else { // Kill any old, invalid records for this screen name $fuser = Foreign_user::getByNickname($screen_name, TWITTER_SERVICE); @@ -279,7 +278,6 @@ function broadcast_oauth($notice, $flink) { } if (empty($status)) { - // This could represent a failure posting, // or the Twitter API might just be behaving flakey. $errmsg = sprintf('Twitter bridge - No data returned by Twitter API when ' . @@ -426,10 +424,14 @@ function mail_twitter_bridge_removed($user) common_switch_locale($user->language); - $subject = sprintf(_m('Your Twitter bridge has been disabled.')); + // TRANS: Mail subject after forwarding notices to Twitter has stopped working. + $subject = sprintf(_m('Your Twitter bridge has been disabled')); $site_name = common_config('site', 'name'); + // TRANS: Mail body after forwarding notices to Twitter has stopped working. + // TRANS: %1$ is the name of the user the mail is sent to, %2$s is a URL to the + // TRANS: Twitter settings, %3$s is the StatusNet sitename. $body = sprintf(_m('Hi, %1$s. We\'re sorry to inform you that your ' . 'link to Twitter has been disabled. We no longer seem to have ' . 'permission to update your Twitter status. Did you maybe revoke ' . From 3cc7dda4784064cca1363e24a91e379de5159287 Mon Sep 17 00:00:00 2001 From: Siebrand Mazeland Date: Fri, 25 Mar 2011 10:02:02 +0100 Subject: [PATCH 3/5] * PHP short tags " Date: Fri, 25 Mar 2011 10:13:26 +0100 Subject: [PATCH 4/5] Fix use of incorrect method causing i18n issue. --- lib/cancelgroupform.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/cancelgroupform.php b/lib/cancelgroupform.php index c328f358c8..f4a44b5b5b 100644 --- a/lib/cancelgroupform.php +++ b/lib/cancelgroupform.php @@ -112,6 +112,6 @@ class CancelGroupForm extends Form function formActions() { // TRANS: Submit button text on form to cancel group join request. - $this->out->submit('submit', _('BUTTON','Cancel join request')); + $this->out->submit('submit', _m('BUTTON','Cancel join request')); } } From 074be0d51ebfeff1d0cc3ec0d572e8eb2442a355 Mon Sep 17 00:00:00 2001 From: Siebrand Mazeland Date: Fri, 25 Mar 2011 17:12:53 +0100 Subject: [PATCH 5/5] i18n fixes. Translator documentation updates. --- actions/approvegroup.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/actions/approvegroup.php b/actions/approvegroup.php index 690c76360f..5039cfae6b 100644 --- a/actions/approvegroup.php +++ b/actions/approvegroup.php @@ -169,15 +169,18 @@ class ApprovegroupAction extends Action $this->startHTML('text/xml;charset=utf-8'); $this->elementStart('head'); // TRANS: Title for leave group page after group join request is approved/disapproved. + // TRANS: %1$s is the user nickname, %2$s is the group nickname. $this->element('title', null, sprintf(_m('TITLE','%1$s\'s request for %2$s'), $this->profile->nickname, $this->group->nickname)); $this->elementEnd('head'); $this->elementStart('body'); if ($this->approve) { - $this->element('p', 'success', _m('Join request approved.')); + // TRANS: Message on page for group admin after approving a join request. + $this->element('p', 'success', _('Join request approved.')); } elseif ($this->cancel) { - $this->element('p', 'success', _m('Join request canceled.')); + // TRANS: Message on page for group admin after rejecting a join request. + $this->element('p', 'success', _('Join request canceled.')); } $this->elementEnd('body'); $this->elementEnd('html');