Типа я (zilogic) wrote in changelog,
Типа я
zilogic
changelog

[ljcom] r11111: LJSUP-9894: Create text vars for hardcod...

Committer: amyshkin
LJSUP-9894: Create text vars for hardcoded notifications
U   trunk/bin/upgrading/en_LJ.dat
U   trunk/cgi-bin/LJ/Hooks/ESN.pm
U   trunk/cgi-bin/ljcom.pl
Modified: trunk/bin/upgrading/en_LJ.dat
===================================================================
--- trunk/bin/upgrading/en_LJ.dat	2011-10-20 08:17:37 UTC (rev 11110)
+++ trunk/bin/upgrading/en_LJ.dat	2011-10-20 09:41:00 UTC (rev 11111)
@@ -13637,3 +13637,19 @@
 
 ysearch.findposts|staleness=1
 ysearch.findposts=Posts
+
+esn.your.livejournal.account.frozen.subject=Your LiveJournal Account
+esn.your.livejournal.account.frozen.body<<
+Dear [[user]],
+Your LiveJournal account has been frozen, as there is evidence that someone has obtained your account's password. To protect you, we have frozen the account so the intruder can't abuse it further.
+
+To have your account unfrozen, please log into your LiveJournal account. When you do, you'll be prompted to change your password.
+
+If the intruder has changed your account password before you are able to do so, please see http://www.livejournal.com/support/faqbrowse.bml?faqid=117 for information on how to recover your account.
+
+If you have any questions, please feel free to contact the Abuse team by emailing abuse\@livejournal.com. Please be sure to include your account name.
+
+Regards,
+ LiveJournal Abuse Team
+.
+

Modified: trunk/cgi-bin/LJ/Hooks/ESN.pm
===================================================================
--- trunk/cgi-bin/LJ/Hooks/ESN.pm	2011-10-20 08:17:37 UTC (rev 11110)
+++ trunk/cgi-bin/LJ/Hooks/ESN.pm	2011-10-20 09:41:00 UTC (rev 11111)
@@ -1,22 +1,77 @@
 package LJ::LJcom;
 
 use strict;
-use Class::Autouse qw(LJ::Subscription::Pending LJ::Pay::ShopVGiftSponsored);
+use Class::Autouse qw(
+    LJ::Subscription::Pending
+    LJ::Pay::ShopVGiftSponsored
+);
 
 use Digest::MD5 qw/md5_hex/;
 
+LJ::register_hook('esn_send_email', sub {
+    my ($self, $opts, $ev) = @_;
+    my $u = $self->u;
+
+    my $frame_filename = '"$ENV{LJHOME}/templates/ESN/frame.tmpl"';
+    return unless -e $frame_filename;
+
+    my $plain_body = $ev->as_email_string($u);
+    return undef unless $plain_body;
+
+    my $html_body = $ev->as_email_html($u);
+    return undef $html_body;
+
+    my $email_subject = $ev->as_email_subject($u);
+    return undef unless $email_subject;
+
+# TODO: Yet no spec for AD system
+#    my $ads = LJ::get_ads({
+#        location   => 'email.bottom',
+#        from_email => $LJ::BOGUS_EMAIL,
+#        to_u       => $u,
+#        remote     => $u,
+#    });
+
+    if( $ev->has_frame ) {
+        my $frame_tmpl = LJ::HTML::Template->new(filename => $frame_filename);
+        return unless $frame_tmpl;
+
+        $html_body = $frame_tmpl->output( mesage => $html_body );
+    }
+
+    my %headers = (
+        "X-LJ-Recipient" => $u->user,
+        %{$ev->as_email_headers($u) || {}},
+        %{$opts->{_debug_headers}   || {}}
+    );
+
+    LJ::send_mail({
+        to       => $ev->as_email_to($u),
+        from     => $ev->as_email_from(),
+        fromname => scalar($ev->as_email_from_name($u)),
+        wrap     => 1,
+        charset  => $u->mailencoding || 'utf-8',
+        subject  => $email_subject,
+        headers  => \%headers,
+        body     => $plain_body,
+        html     => $html_body,
+    }) or die "unable to send notification email";
+
+    return 1;
+});
+
 LJ::register_hook('subscriptions_manage_friend_pending_extra', sub {
     my $remote = shift;
     return LJ::Subscription::Pending->new(
-                                          $remote,
-                                          event => 'NewVGift',
-                                          ),
+        $remote,
+        event => 'NewVGift',
+    ),
 });
 
 LJ::register_hook('friend_notification_types', sub {
     return qw (
-               NewVGift
-               );
+        NewVGift
+    );
 });
 
 LJ::register_hook('birthday_notif_extra_plaintext', sub {
@@ -27,14 +82,18 @@
 
     my $sponsor = $LJ::SPONSORED_VGIFTS{'free'}{'name'};
 
-	my $send_virtual_gift = LJ::Lang::get_text($lang, 'esn.bday.send_virtual_gift');
-	my $wake_them = LJ::Lang::get_text($lang, 'esn.bday.wake_them', undef, { 
-		sponsor => "$sponsor", 
-		openlink => "",
-		closelink => "",
-	});
+    my $send_virtual_gift = LJ::Lang::get_text($lang, 'esn.bday.send_virtual_gift');
+    my $wake_them = LJ::Lang::get_text(
+        $lang,
+        'esn.bday.wake_them',
+        undef,
+        {
+            sponsor   => "$sponsor",
+            openlink  => "",
+            closelink => "",
+    });
 
-	my $gift_paid_account = LJ::Lang::get_text($lang, 'esn.bday.gift_paid_account');
+    my $gift_paid_account = LJ::Lang::get_text($lang, 'esn.bday.gift_paid_account');
 
     $ret .= "\n"; # so it aligns properly
     $ret .= "  - $send_virtual_gift\n";
@@ -54,7 +113,7 @@
     my $ret;
 
     my $lang = $u->prop('browselang');
-    
+
     my $sponsor = $LJ::SPONSORED_VGIFTS{'free'}{'name'};
     my $link = $LJ::SPONSORED_VGIFTS{'free'}{'tracking_link_email'};
 

Modified: trunk/cgi-bin/ljcom.pl
===================================================================
--- trunk/cgi-bin/ljcom.pl	2011-10-20 08:17:37 UTC (rev 11110)
+++ trunk/cgi-bin/ljcom.pl	2011-10-20 09:41:00 UTC (rev 11111)
@@ -1470,60 +1470,8 @@
     # a bad password.
     return undef unless $on;
 
-    my $body;
-    $body .= "Dear $u->{'user'},\n";
-    $body .= "Your LiveJournal account has been frozen, as there is evidence that someone has obtained your account's password. To protect you, we have frozen the account so the intruder can't abuse it further.";
-    $body .= "\n\n";
-    $body .= "To have your account unfrozen, please log into your LiveJournal account. When you do, you'll be prompted to change your password.";
-    $body .= "\n\n";
-    $body .= "If the intruder has changed your account password before you are able to do so, please see http://www.livejournal.com/support/faqbrowse.bml?faqid=117 for information on how to recover your account.";
-    $body .= "\n\n";
-    $body .= "If you have any questions, please feel free to contact the Abuse team by emailing abuse\@livejournal.com. Please be sure to include your account name.";
-    $body .= "\n\n";
-    $body .= "Regards,\n LiveJournal Abuse Team";
+    my $ev = LJ::Event::BuiltIn::AccountFrozen->new($u)->fire;
 
-    my $subject = 'Your LiveJournal Account';
-
-    # While we could use a dbr here, we need a dbh later anyway
-    # and we want to make sure this is the latest data anyway
-    my $dbh = LJ::get_db_writer()
-        or return undef;
-
-    # Start with their current email address
-    my $email = $u->email_raw;
-
-    # See if the email address on the account was changed in the past 24 hours
-    # If so, get any old email addresses that were validated
-    my $sth = $dbh->prepare("SELECT oldvalue, UNIX_TIMESTAMP(timechange) " .
-                            "FROM infohistory WHERE userid=? AND UNIX_TIMESTAMP() " .
-                            "- UNIX_TIMESTAMP(timechange) <= 86400 AND other = 'A'");
-    $sth->execute($u->{'userid'})
-        or return undef;
-    my $oldemails = $sth->fetchall_arrayref;
-
-    if ($oldemails) {
-        # Get the earliest email address and use that instead of current
-        foreach (sort { $a->[1] <=> $b->[1] } @$oldemails) {
-            $email = $_->[0];
-            last;
-        }
-    }
-
-    my $res = LJ::send_mail({
-        'to'       => $email,
-        'from'     => 'abuse@livejournal.com',
-        'fromname' => 'LiveJournal Abuse Team',
-        'charset'  => 'utf-8',
-        'subject'  => $subject,
-        'body'     => $body,
-    });
-
-    my $query = "INSERT INTO abuse_mail (mailid, userid, status, timesent, mailto, " .
-        "subject, message, type) " .
-        "VALUES (NULL, ?, ?, NOW(), ?, ?, ?, ?)";
-
-    $dbh->do($query, undef, $remote->{'userid'}, $res ? 'S' : 'F', $email, $subject, $body, 'abuse');
-
     return 1;
 });
 

Tags: amyshkin, dat, ljcom, pl, pm, zilogic
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