madeon (madeon) wrote in changelog,
madeon
madeon
changelog

[ljcom] r12379: LJSV-1827: Facebook disconnect

Committer: sbelyaev
LJSV-1827: Facebook disconnect
U   trunk/bin/upgrading/en_LJ.dat
U   trunk/cgi-bin/LJ/Worker/Repost/EntryToFacebook.pm
Modified: trunk/bin/upgrading/en_LJ.dat
===================================================================
--- trunk/bin/upgrading/en_LJ.dat	2012-07-31 09:51:21 UTC (rev 12378)
+++ trunk/bin/upgrading/en_LJ.dat	2012-07-31 12:08:30 UTC (rev 12379)
@@ -2924,6 +2924,10 @@
 
 extra_privacy_options.my_guests_opt_out.note=You won't be able to see My Guests statistics and other users will not see you. in their statistics
 
+facebook.email.too_many.subject=You can not crosspost to Facebook
+
+facebook.email.too_many.body=You can't post more than 50 times today. Try again later.
+
 facebook.email.error_disconnect.body=Your Facebook account has been disconnected due to the following error: [[errortext]]
 
 facebook.email.error_disconnect.subject=You have been disconnected from Facebook.

Modified: trunk/cgi-bin/LJ/Worker/Repost/EntryToFacebook.pm
===================================================================
--- trunk/cgi-bin/LJ/Worker/Repost/EntryToFacebook.pm	2012-07-31 09:51:21 UTC (rev 12378)
+++ trunk/cgi-bin/LJ/Worker/Repost/EntryToFacebook.pm	2012-07-31 12:08:30 UTC (rev 12379)
@@ -137,10 +137,16 @@
     if ( $error ) {
         my $type       = $error->{'type'};
         my $error_text = $error->{'message'};
+        my $code       = int($error->{'code'}) || 0;
 
         __log_statushistory( $poster, $error_text );
-        __send_error( $poster, $error_text );
-        __destroy_link($poster);
+         if ($code != 341) {
+            __send_error( $poster, $error_text );
+            __destroy_link($poster) if $code != 341;
+        } else {
+            __send_warning( $poster, $error_text );
+        }
+
         $entry->set_prop('crosspost_fb' => "error($type): $error_text" );
     } else {
         my ($uid, $postid) = split(/_/, $decoded->{'id'} );
@@ -159,6 +165,36 @@
     return;
 }
 
+sub __send_warning {
+    my ( $poster, $fb_error ) = @_;
+    my $email = $poster->email_raw;
+
+    my $subject =  LJ::Lang::get_text($poster->prop('browselang'),
+                                      'facebook.email.too_many.subject');
+
+    my $error =  LJ::Lang::get_text($poster->prop('browselang'),
+                                    'facebook.email.too_many.body',
+                                    undef,
+                                    {
+                                        sitename       => $LJ::SITENAME,
+                                        siteroot       => $LJ::SITEROOT,
+                                        errortext      => $fb_error,
+                                        username       => $poster->user,
+                                        facebook_link  => $poster->prop('facebook_link'),
+                                    });
+
+    LJ::send_mail({
+        'to' => $email,
+        'from' => $LJ::DONOTREPLY_EMAIL,
+        'fromname' => $LJ::SITENAME,
+        'charset' => 'utf-8',
+        'subject' => $subject,
+        'body' => $error,
+        { subject => $subject, reason => $error },
+    });
+    return;
+}
+
 sub __send_error {
     my ( $poster, $fb_error ) = @_;
     my $email = $poster->email_raw;

Tags: dat, ljcom, madeon, pm, sbelyaev
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