aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/SendReport/Email.pm
diff options
context:
space:
mode:
Diffstat (limited to 'perllib/FixMyStreet/SendReport/Email.pm')
-rw-r--r--perllib/FixMyStreet/SendReport/Email.pm37
1 files changed, 21 insertions, 16 deletions
diff --git a/perllib/FixMyStreet/SendReport/Email.pm b/perllib/FixMyStreet/SendReport/Email.pm
index f26116bc4..1ff476da3 100644
--- a/perllib/FixMyStreet/SendReport/Email.pm
+++ b/perllib/FixMyStreet/SendReport/Email.pm
@@ -11,36 +11,36 @@ sub build_recipient_list {
my %recips;
my $all_confirmed = 1;
- foreach my $council ( keys %{ $self->councils } ) {
+ foreach my $body ( @{ $self->bodies } ) {
my $contact = FixMyStreet::App->model("DB::Contact")->find( {
deleted => 0,
- area_id => $council,
+ body_id => $body->id,
category => $row->category
} );
- my ($council_email, $confirmed, $note) = ( $contact->email, $contact->confirmed, $contact->note );
+ my ($body_email, $confirmed, $note) = ( $contact->email, $contact->confirmed, $contact->note );
- $council_email = essex_contact($row->latitude, $row->longitude) if $council == 2225;
- $council_email = oxfordshire_contact($row->latitude, $row->longitude) if $council == 2237 && $council_email eq 'SPECIAL';
+ $body_email = essex_contact($row->latitude, $row->longitude) if $body->areas->{2225};
+ $body_email = oxfordshire_contact($row->latitude, $row->longitude) if $body->areas->{2237} && $body_email eq 'SPECIAL';
unless ($confirmed) {
$all_confirmed = 0;
- $note = 'Council ' . $row->council . ' deleted'
+ $note = 'Body ' . $row->bodies_str . ' deleted'
unless $note;
- $council_email = 'N/A' unless $council_email;
- $self->unconfirmed_counts->{$council_email}{$row->category}++;
- $self->unconfirmed_notes->{$council_email}{$row->category} = $note;
+ $body_email = 'N/A' unless $body_email;
+ $self->unconfirmed_counts->{$body_email}{$row->category}++;
+ $self->unconfirmed_notes->{$body_email}{$row->category} = $note;
}
# see something uses council areas but doesn't send to councils so just use a
# generic name here to minimise confusion
if ( $row->cobrand eq 'seesomething' ) {
- push @{ $self->to }, [ $council_email, 'See Something, Say Something' ];
+ push @{ $self->to }, [ $body_email, 'See Something, Say Something' ];
} else {
- push @{ $self->to }, [ $council_email, $self->councils->{ $council }->{info}->{name} ];
+ push @{ $self->to }, [ $body_email, $body->name ];
}
- $recips{$council_email} = 1;
+ $recips{$body_email} = 1;
}
return () unless $all_confirmed;
@@ -51,7 +51,7 @@ sub get_template {
my ( $self, $row ) = @_;
my $template = 'submit.txt';
- $template = 'submit-brent.txt' if $row->council eq 2488 || $row->council eq 2237;
+ $template = 'submit-brent.txt' if $row->bodies_str eq 2488 || $row->bodies_str eq 2237;
my $template_path = FixMyStreet->path_to( "templates", "email", $row->cobrand, $row->lang, $template )->stringify;
$template_path = FixMyStreet->path_to( "templates", "email", $row->cobrand, $template )->stringify
unless -e $template_path;
@@ -61,14 +61,19 @@ sub get_template {
return $template;
}
+sub send_from {
+ my ( $self, $row ) = @_;
+ return [ $row->user->email, $row->name ];
+}
+
sub send {
my $self = shift;
my ( $row, $h ) = @_;
my @recips = $self->build_recipient_list( $row, $h );
- # on a staging server send emails to ourselves rather than the councils
- if (mySociety::Config::get('STAGING_SITE') && !FixMyStreet->test_mode) {
+ # on a staging server send emails to ourselves rather than the bodies
+ if (mySociety::Config::get('STAGING_SITE') && !mySociety::Config::get('SEND_REPORTS_ON_STAGING') && !FixMyStreet->test_mode) {
@recips = ( mySociety::Config::get('CONTACT_EMAIL') );
}
@@ -83,7 +88,7 @@ sub send {
_template_ => $self->get_template( $row ),
_parameters_ => $h,
To => $self->to,
- From => [ $row->user->email, $row->name ],
+ From => $self->send_from( $row ),
},
mySociety::Config::get('CONTACT_EMAIL'),
\@recips,