changelog_bot (changelog_bot) wrote in changelog,
changelog_bot
changelog_bot
changelog

[ljcom] r11697: LJSV-1266: Twitter digest doesn't work f...

Committer: nnikulochkina
LJSV-1266: Twitter digest doesn't work for some users
Minor improvement.
U   trunk/cgi-bin/LJ/Client/Twitter.pm
U   trunk/cgi-bin/LJ/TwitterDigest.pm
Modified: trunk/cgi-bin/LJ/Client/Twitter.pm
===================================================================
--- trunk/cgi-bin/LJ/Client/Twitter.pm	2012-04-11 15:36:29 UTC (rev 11696)
+++ trunk/cgi-bin/LJ/Client/Twitter.pm	2012-04-12 07:53:35 UTC (rev 11697)
@@ -290,6 +290,9 @@
     if ($res->is_success) {
         return LJ::JSON->from_json($res->content);
     } else {
+	
+	${$opts{'http_code'}} = $res->code if ( ref($opts{'http_code'}) );
+
         if ($res->code eq '401' && $u) {
             $u->log_event ("twitter_failed", { text => '401 Unauthorized' } )
                 if $opts{'call_from_digest'};
@@ -312,11 +315,6 @@
                 body     => LJ::Lang::get_text($lang, 'twitter.disconnect_letter.body', undef, { user => $u->username }),
             } ) or warn "Unable to send_mail";
 	    die "twitter error: 401 Unauthorized\n";
-        } elsif ( $res->code >= 500 && $res->code < 600 ) {
-            # 50x codes (which indicate a server error) only get
-	    $u->log_event ("twitter_failed", { text => $res->status_line } )
-		if $opts{'call_from_digest'};
-	    die "twitter connectivity error: " . $res->status_line;
         } else {
             $u->log_event ("twitter_failed", { text => $res->status_line } )
                 if $opts{'call_from_digest'};
@@ -459,6 +457,8 @@
     my $res;
     my $retry_number = $LJ::TWITTER_API_USER_TIMELINE_RETRY || 1;
 
+    my $http_code;
+
   RETRY:
     foreach my $retry_count ( 1..$retry_number ) {
 	eval {
@@ -469,10 +469,11 @@
 	        'params' => { 'count'       => $LJ::TWITTER_RECENT_FEED_DEPTH,
 		              'include_rts' => 1, }, # with retweets
                 %$opts,
+		http_code => \$http_code,
 	    );
         };
 
-	if( $@ && $@ =~ /twitter connectivity error: 502/ && $retry_count < $retry_number ) {
+	if( $@ && $http_code eq '502' && $retry_count < $retry_number ) {
 	    # we recieved 502 error
 	    # wait and try again
 	    sleep 1;

Modified: trunk/cgi-bin/LJ/TwitterDigest.pm
===================================================================
--- trunk/cgi-bin/LJ/TwitterDigest.pm	2012-04-11 15:36:29 UTC (rev 11696)
+++ trunk/cgi-bin/LJ/TwitterDigest.pm	2012-04-12 07:53:35 UTC (rev 11697)
@@ -216,12 +216,12 @@
     
     unless ( $twu ) {
 	unless ( LJ::Client::Twitter->get_user_access_token($u) ) {
+	    
+	    # we don't have twitter access tokens
+	    # set TwitterDigest disabled for this user
+	    LJ::TwitterDigest->disable_for_user($u);
+	    die "Can't get twitter access tokens for user. Set digest disabled.";
 
-	# we don't have twitter access tokens
-	# set TwitterDigest disabled for this user
-	LJ::TwitterDigest->disable_for_user($u);
-	die "Can't get twitter access tokens for user. Set digest disabled."
-
 	} else {
 	    die "Unexpected empty userinfo";
 	}

Tags: changelog_bot, ljcom, nnikulochkina, pm
Subscribe
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 0 comments