Permalink
Browse files

Merge pull request #319 from afuna/transferpoints-email-bug2851

(Bug 2851) Email you when you transfer points to somebody else
  • Loading branch information...
2 parents fa61d5f + 0278fcd commit d17027b06f32f6d0d4082b177dd472e7d03464bd @afuna afuna committed Mar 20, 2013
Showing with 71 additions and 19 deletions.
  1. +24 −0 bin/upgrading/en.dat
  2. +47 −19 cgi-bin/DW/Controller/Shop.pm
View
@@ -1516,6 +1516,30 @@ If you did not change your username, it means that your community's security was
This letter was sent out automatically to help you keep your account secure. You cannot opt-out of receiving these letters.
.
+esn.sentpoints.body.noreason<<
+
+Hi [[from]],
+
+You have just sent [[points]] [[?points|point|points]] to [[to]].
+
+Regards,
+ The [[sitename]] Team
+.
+
+esn.sentpoints.body.reason<<
+
+Hi [[from]],
+
+You have just sent [[points]] [[?points|point|points]] to [[to]], with the following message:
+
+ [[reason]]
+
+Regards,
+ The [[sitename]] Team
+.
+
+esn.sentpoints.subject=[[sitename]] Points sent to [[to]]
+
esn.shop_for_gift=[[openlink]]Buy a gift from our shop[[closelink]]
esn.supofficialpost.html=There is <a href="[[url]]">a new announcement</a> in [[username]]
@@ -7,7 +7,7 @@
# Authors:
# Mark Smith <mark@dreamwidth.org>
#
-# Copyright (c) 2010 by Dreamwidth Studios, LLC.
+# Copyright (c) 2010-2013 by Dreamwidth Studios, LLC.
#
# This program is free software; you may redistribute it and/or modify it under
# the same terms as Perl itself. For a copy of the license, please reference
@@ -139,26 +139,54 @@ sub shop_transfer_points_handler {
my $get_text = sub { LJ::Lang::get_text( $u->prop( 'browselang' ), $_[0], undef, $_[1] ) };
- # send notification ...
- my $e = $rv->{anon} ? 'anon' : 'user';
- my $reason = ( $rv->{reason} && $rv->{can_have_reason} ) ? $get_text->( "esn.receivedpoints.reason", { reason => $rv->{reason} } ) : '';
- my $body = $get_text->( "esn.receivedpoints.$e.body", {
- user => $u->display_username,
- points => $points,
- from => $remote->display_username,
- sitename => $LJ::SITENAMESHORT,
- store => "$LJ::SITEROOT/shop/",
- reason => $reason,
+ # send notification to person transferring the points...
+ {
+ my $reason = $rv->{reason};
+ my $vars = {
+ from => $remote->display_username,
+ points => $points,
+ to => $u->display_username,
+ reason => $reason,
+ sitename => $LJ::SITENAMESHORT,
+ reason => $reason,
+ };
+ my $body = $reason ? $get_text->( 'esn.sentpoints.body.reason', $vars )
+ : $get_text->( 'esn.sentpoints.body.noreason', $vars );
+
+ LJ::send_mail( {
+ to => $remote->email_raw,
+ from => $LJ::ACCOUNTS_EMAIL,
+ fromname => $LJ::SITENAME,
+ subject => $get_text->( 'esn.sentpoints.subject', {
+ sitename => $LJ::SITENAMESHORT,
+ to => $u->display_username,
+ } ),
+ body => $body,
} );
+ }
- # FIXME: esnify the notification
- LJ::send_mail( {
- to => $u->email_raw,
- from => $LJ::ACCOUNTS_EMAIL,
- fromname => $LJ::SITENAME,
- subject => $get_text->( 'esn.receivedpoints.subject', { sitename => $LJ::SITENAMESHORT } ),
- body => $body,
- } );
+ # send notification to person receiving the points...
+ {
+ my $e = $rv->{anon} ? 'anon' : 'user';
+ my $reason = ( $rv->{reason} && $rv->{can_have_reason} ) ? $get_text->( "esn.receivedpoints.reason", { reason => $rv->{reason} } ) : '';
+ my $body = $get_text->( "esn.receivedpoints.$e.body", {
+ user => $u->display_username,
+ points => $points,
+ from => $remote->display_username,
+ sitename => $LJ::SITENAMESHORT,
+ store => "$LJ::SITEROOT/shop/",
+ reason => $reason,
+ } );
+
+ # FIXME: esnify the notification
+ LJ::send_mail( {
+ to => $u->email_raw,
+ from => $LJ::ACCOUNTS_EMAIL,
+ fromname => $LJ::SITENAME,
+ subject => $get_text->( 'esn.receivedpoints.subject', { sitename => $LJ::SITENAMESHORT } ),
+ body => $body,
+ } );
+ }
# happy times ...
$rv->{transferred} = 1;

0 comments on commit d17027b

Please sign in to comment.