changelog_bot (changelog_bot) wrote in changelog,
changelog_bot
changelog_bot
changelog

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

Committer: nnikulochkina
LJSV-1266: Twitter digest doesn't work for some users
1. Log event if user has "protected" flag in twitter account.
2. Really disabled TwitterDigest after unlink Twitter and LJ accounts.
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 10:12:11 UTC (rev 11691)
+++ trunk/cgi-bin/LJ/Client/Twitter.pm	2012-04-11 10:56:30 UTC (rev 11692)
@@ -291,7 +291,6 @@
         return LJ::JSON->from_json($res->content);
     } else {
         if ($res->code eq '401' && $u) {
-            warn "twitter error: 401 Unauthorized\n";
             $u->log_event ("twitter_failed", { text => '401 Unauthorized' } )
                 if $opts{'call_from_digest'};
 
@@ -312,13 +311,12 @@
                 subject  => LJ::Lang::get_text($lang, 'twitter.disconnect_letter.subject', undef),
                 body     => LJ::Lang::get_text($lang, 'twitter.disconnect_letter.body', undef, { user => $u->username }),
             } ) or warn "Unable to send_mail";
-            return;
+	    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;
-            return;
         } else {
             $u->log_event ("twitter_failed", { text => $res->status_line } )
                 if $opts{'call_from_digest'};

Modified: trunk/cgi-bin/LJ/TwitterDigest.pm
===================================================================
--- trunk/cgi-bin/LJ/TwitterDigest.pm	2012-04-11 10:12:11 UTC (rev 11691)
+++ trunk/cgi-bin/LJ/TwitterDigest.pm	2012-04-11 10:56:30 UTC (rev 11692)
@@ -213,9 +213,25 @@
     my ($class, $u) = @_;
 
     my $twu = LJ::Client::Twitter->get_userinfo( 'user' => $u, 'call_from_digest' => 1 );
+    
+    unless ( $twu ) {
+	unless ( LJ::Client::Twitter->get_user_access_token($u) ) {
 
-    return if ! $twu || $twu->protected;
+	# 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";
+	}
+    }
+    
+    if( $twu->protected ) {
+	$u->log_event ("twitter_skipped", { text => "Twitter account is protected" });
+	return;
+    }
+
     if (my $u_system = LJ::load_user('system')) {
         unless ($u_system->rate_log('twitter_digest', 1)) {
             $u->log_event ("twitter_skipped", { text => "twitter digest rate limit reached" });

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