Committer: gprochaev
LJSV-2037: (Logging twitter digest activity)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-02-07 09:05:02 UTC (rev 11422) +++ trunk/cgi-bin/LJ/Client/Twitter.pm 2012-02-07 12:21:44 UTC (rev 11423) @@ -287,11 +287,13 @@ $res = $ua->post( $request_url, $post_params ); } + my $system = LJ::load_user ('system'); if ($res->is_success) { return LJ::JSON->from_json($res->content); } else { if ($res->code eq '401' && $u) { warn "twitter error: 401 Unauthorized\n"; + LJ::statushistory_add($u, $system, 'twitter_failed', '401 Unauthorized'); $u->clear_prop($_) foreach qw( @@ -315,10 +317,12 @@ # 50x codes (which indicate a server error) only get # printed if we have an environment flag on if ( $ENV{'LJ_DEBUG_TWITTER_CONNECTIVITY'} ) { + LJ::statushistory_add($u, $system, 'twitter_failed', $res->status_line); die "twitter connectivity error: " . $res->status_line; } return; } else { + LJ::statushistory_add($u, $system, 'twitter_failed', $res->status_line); die "twitter connectivity error: " . $res->status_line; } return undef; Modified: trunk/cgi-bin/LJ/TwitterDigest.pm =================================================================== --- trunk/cgi-bin/LJ/TwitterDigest.pm 2012-02-07 09:05:02 UTC (rev 11422) +++ trunk/cgi-bin/LJ/TwitterDigest.pm 2012-02-07 12:21:44 UTC (rev 11423) @@ -233,13 +233,22 @@ LJ::set_remote($u); my $tweets = LJ::Client::Twitter->user_last_tweets($u); - return unless @$tweets; + unless (@$tweets) { + my $system = LJ::load_user ('system'); + LJ::statushistory_add($u, $system, 'twitter_skipped', "No tweets to import"); + return; + } my @tweets_filtered = sort { $a->post_time <=> $b->post_time } grep { $_->post_time > time - 86400 } @$tweets; - return unless @tweets_filtered; + + unless (@tweets_filtered) { + my $system = LJ::load_user ('system'); + LJ::statushistory_add($u, $system, 'twitter_skipped', "No filtered tweets to import"); + return; + } my @tweets_display; foreach my $tw (@tweets_filtered) { @@ -307,6 +316,11 @@ }, \$errs, { 'noauth' => 1 }); + unless ($errs) { + my $system = LJ::load_user ('system'); + LJ::statushistory_add($u, $system, 'twitter_success', $res->{'url'}); + } + warn $errs if $errs; return $res;