aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/DB/ResultSet
diff options
context:
space:
mode:
Diffstat (limited to 'perllib/FixMyStreet/DB/ResultSet')
-rw-r--r--perllib/FixMyStreet/DB/ResultSet/AlertType.pm5
-rw-r--r--perllib/FixMyStreet/DB/ResultSet/Problem.pm27
-rw-r--r--perllib/FixMyStreet/DB/ResultSet/Questionnaire.pm3
3 files changed, 29 insertions, 6 deletions
diff --git a/perllib/FixMyStreet/DB/ResultSet/AlertType.pm b/perllib/FixMyStreet/DB/ResultSet/AlertType.pm
index 468df2654..d903f8eb2 100644
--- a/perllib/FixMyStreet/DB/ResultSet/AlertType.pm
+++ b/perllib/FixMyStreet/DB/ResultSet/AlertType.pm
@@ -230,13 +230,12 @@ sub _send_aggregated_alert_email(%) {
unless -e $template;
$template = Utils::read_file($template);
- my $sender = $cobrand->contact_email;
- (my $from = $sender) =~ s/team/fms-DO-NOT-REPLY/; # XXX
+ my $sender = FixMyStreet->config('DO_NOT_REPLY_EMAIL');
my $result = FixMyStreet::App->send_email_cron(
{
_template_ => $template,
_parameters_ => \%data,
- From => [ $from, _($cobrand->contact_name) ],
+ From => [ $sender, _($cobrand->contact_name) ],
To => $data{alert_email},
},
$sender,
diff --git a/perllib/FixMyStreet/DB/ResultSet/Problem.pm b/perllib/FixMyStreet/DB/ResultSet/Problem.pm
index 0d40220b2..faed3b8ac 100644
--- a/perllib/FixMyStreet/DB/ResultSet/Problem.pm
+++ b/perllib/FixMyStreet/DB/ResultSet/Problem.pm
@@ -377,8 +377,33 @@ sub send_reports {
if (mySociety::Config::get('STAGING_SITE')) {
# on a staging server send emails to ourselves rather than the councils
+ # however, we can configure a list of councils that we use non email
+ # delivery, e.g. Open311, for testing purposes. For those we want to
+ # send using the non email method and for everyone else we want to use
+ # email
my @testing_councils = split( '\|', mySociety::Config::get('TESTING_COUNCILS') );
- unless ( grep { $row->council eq $_ } @testing_councils ) {
+
+ # we only care about non missing councils so we get the missing ones
+ # and then essentially throw them away as we're not going to have
+ # configured them to do anything.
+ my %councils = map { $_ => 1 } @{ $row->councils };
+
+ # We now take the councils that we have contact details for and if any of them
+ # are in the list of testing councils we look a bit harder otherwise we throw
+ # away all the non email delivery methods
+ if ( grep { $councils{ $_ } } @testing_councils ) {
+ my %tc = map { $_ => 1 } @testing_councils;
+ my @non_matching = grep { !$tc{$_} } keys %councils;
+ for my $sender ( keys %reporters ) {
+ next if $sender =~ /FixMyStreet::SendReport::(Email|NI)/;
+ for my $council ( @non_matching ) {
+ $reporters{$sender}->delete_council( $council );
+ }
+ }
+ if ( @non_matching ) {
+ $reporters{'FixMyStreet::SendReport::Email'} = FixMyStreet::SendReport::Email->new();
+ }
+ } else {
%reporters = map { $_ => $reporters{$_} } grep { /FixMyStreet::SendReport::(Email|NI)/ } keys %reporters;
unless (%reporters) {
%reporters = ( 'FixMyStreet::SendReport::Email' => FixMyStreet::SendReport::Email->new() );
diff --git a/perllib/FixMyStreet/DB/ResultSet/Questionnaire.pm b/perllib/FixMyStreet/DB/ResultSet/Questionnaire.pm
index d6b3eb5cb..1b9521a9f 100644
--- a/perllib/FixMyStreet/DB/ResultSet/Questionnaire.pm
+++ b/perllib/FixMyStreet/DB/ResultSet/Questionnaire.pm
@@ -89,9 +89,8 @@ sub send_questionnaires_period {
} );
$h{url} = $cobrand->base_url($row->cobrand_data) . '/Q/' . $token->token;
- my $sender = $cobrand->contact_email;
+ my $sender = FixMyStreet->config('DO_NOT_REPLY_EMAIL');
my $sender_name = _($cobrand->contact_name);
- $sender =~ s/team/fms-DO-NOT-REPLY/;
print "Sending questionnaire " . $questionnaire->id . ", problem "
. $row->id . ", token " . $token->token . " to "