Support email settings for donors.

This change, which is not properly documented nor tests present, adds
support for making sure those who don't want emails from us do not
receive them.

I believe I've caught most of the places we want this change supported.
This commit is contained in:
Bradley M. Kuhn 2017-01-02 11:54:25 -08:00
parent 7d39d40e61
commit 1a6cb14254
3 changed files with 39 additions and 0 deletions

View file

@ -1468,6 +1468,42 @@ sub findDonor($$) {
}
return(@donorIds);
}
######################################################################
# FIXME: docs
sub emailOk($$) {
my($self, $donorId) = @_;
confess "lastGave: donorId, \"$donorId\" not found in supporter database"
unless $self->_verifyId($donorId);
my $contactSetting;
my $req = $self->getRequest({donorId => $donorId,
requestType => 'contact-settings'});
$contactSetting =$req->{requestConfiguration}
if defined $req and defined $req->{requestConfiguration};
return ((not defined $contactSetting) or
($contactSetting eq 'no-paper-but-email-ok'));
}
sub paperMailOk($$) {
my($self, $donorId) = @_;
confess "lastGave: donorId, \"$donorId\" not found in supporter database"
unless $self->_verifyId($donorId);
my $contactSetting;
my $req = $self->getRequest({donorId => $donorId,
requestType => 'contact-settings'});
$contactSetting =$req->{requestConfiguration}
if defined $req and defined $req->{requestConfiguration};
return ((not defined $contactSetting) or
($contactSetting eq 'no-email-but-paper-ok'));
}
######################################################################
=begin donorLastGave

View file

@ -120,6 +120,7 @@ foreach my $supporterId (sort @supporterIds) {
my $displayName = $sp->getDisplayName($supporterId);
if ($isPaper) {
next unless $sp->paperMailOk($donorId);
my $latexDisplayName = latex_encode($displayName);
$latexDisplayName =~ s/\\unmatched\{0141\}/\L{}/g;
$latexDisplayName =~ s/\\unmatched\{0142\}/\l{}/g;
@ -158,6 +159,7 @@ foreach my $supporterId (sort @supporterIds) {
close LETTER;
close MESSAGE;
} else {
next unless $sp->emailOk($donorId);
open(MESSAGE, "<", $EMAIL_TEMPLATE);
my @message;
while (my $line = <MESSAGE> ) {

View file

@ -66,6 +66,7 @@ foreach my $id (sort keys %idsSent) {
$sp->fulfillRequest({ donorId => $id, requestType => $request->{requestType},
who => $WHO, how => $HOW});
next unless $sp->emailOk($donorId);
my $emailTo = $sp->getPreferredEmailAddress($id);
if (not defined $emailTo) {
my(@addr) = $sp->getEmailAddresses($id);