aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/SendReport
diff options
context:
space:
mode:
Diffstat (limited to 'perllib/FixMyStreet/SendReport')
-rw-r--r--perllib/FixMyStreet/SendReport/EastHants.pm4
-rw-r--r--perllib/FixMyStreet/SendReport/Email.pm24
-rw-r--r--perllib/FixMyStreet/SendReport/EmptyHomes.pm10
-rw-r--r--perllib/FixMyStreet/SendReport/Noop.pm2
-rw-r--r--perllib/FixMyStreet/SendReport/Open311.pm6
-rw-r--r--perllib/FixMyStreet/SendReport/Refused.pm2
-rw-r--r--perllib/FixMyStreet/SendReport/Zurich.pm8
7 files changed, 26 insertions, 30 deletions
diff --git a/perllib/FixMyStreet/SendReport/EastHants.pm b/perllib/FixMyStreet/SendReport/EastHants.pm
index 44bc084b1..3eb8ffcfa 100644
--- a/perllib/FixMyStreet/SendReport/EastHants.pm
+++ b/perllib/FixMyStreet/SendReport/EastHants.pm
@@ -1,6 +1,6 @@
package FixMyStreet::SendReport::EastHants;
-use Moose;
+use Moo;
BEGIN { extends 'FixMyStreet::SendReport'; }
@@ -28,7 +28,7 @@ EOF
}
sub send {
- return if mySociety::Config::get('STAGING_SITE');
+ return if FixMyStreet->config('STAGING_SITE');
my ( $self, $row, $h ) = @_;
diff --git a/perllib/FixMyStreet/SendReport/Email.pm b/perllib/FixMyStreet/SendReport/Email.pm
index bac408510..7e5c10469 100644
--- a/perllib/FixMyStreet/SendReport/Email.pm
+++ b/perllib/FixMyStreet/SendReport/Email.pm
@@ -1,6 +1,6 @@
package FixMyStreet::SendReport::Email;
-use Moose;
+use Moo;
use FixMyStreet::Email;
BEGIN { extends 'FixMyStreet::SendReport'; }
@@ -11,7 +11,7 @@ sub build_recipient_list {
my $all_confirmed = 1;
foreach my $body ( @{ $self->bodies } ) {
- my $contact = FixMyStreet::App->model("DB::Contact")->find( {
+ my $contact = $row->result_source->schema->resultset("Contact")->find( {
deleted => 0,
body_id => $body->id,
category => $row->category
@@ -75,7 +75,7 @@ sub send {
my $recips = $self->build_recipient_list( $row, $h );
# 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) {
+ if (FixMyStreet->config('STAGING_SITE') && !FixMyStreet->config('SEND_REPORTS_ON_STAGING') && !FixMyStreet->test_mode) {
$recips = 1;
@{$self->to} = [ $row->user->email, $self->to->[0][1] || $row->name ];
}
@@ -94,23 +94,21 @@ sub send {
From => $self->send_from( $row ),
};
- my $app = FixMyStreet::App->new( cobrand => $cobrand );
-
- $cobrand->munge_sendreport_params($app, $row, $h, $params) if $cobrand->can('munge_sendreport_params');
+ $cobrand->munge_sendreport_params($row, $h, $params) if $cobrand->can('munge_sendreport_params');
$params->{Bcc} = $self->bcc if @{$self->bcc};
+ my $sender = sprintf('<fms-%s@%s>',
+ FixMyStreet::Email::generate_verp_token('report', $row->id),
+ FixMyStreet->config('EMAIL_DOMAIN')
+ );
+
if (FixMyStreet::Email::test_dmarc($params->{From}[0])) {
$params->{'Reply-To'} = [ $params->{From} ];
- $params->{From} = [ mySociety::Config::get('CONTACT_EMAIL'), $params->{From}[1] ];
+ $params->{From} = [ $sender, $params->{From}[1] ];
}
- my $result = $app->send_email_cron(
- $params,
- mySociety::Config::get('CONTACT_EMAIL'),
- $nomail,
- $cobrand
- );
+ my $result = FixMyStreet::Email::send_cron($row->result_source->schema, $params, $sender, $nomail, $cobrand);
unless ($result) {
$self->success(1);
diff --git a/perllib/FixMyStreet/SendReport/EmptyHomes.pm b/perllib/FixMyStreet/SendReport/EmptyHomes.pm
index ce69aaac3..b5faf8ddc 100644
--- a/perllib/FixMyStreet/SendReport/EmptyHomes.pm
+++ b/perllib/FixMyStreet/SendReport/EmptyHomes.pm
@@ -1,6 +1,6 @@
package FixMyStreet::SendReport::EmptyHomes;
-use Moose;
+use Moo;
use namespace::autoclean;
use mySociety::MaPit;
@@ -12,7 +12,7 @@ sub build_recipient_list {
my $all_confirmed = 1;
foreach my $body ( @{ $self->bodies } ) {
- my $contact = FixMyStreet::App->model("DB::Contact")->find( {
+ my $contact = $row->result_source->schema->resultset("Contact")->find( {
deleted => 0,
body_id => $body->id,
category => 'Empty property',
@@ -34,11 +34,11 @@ sub build_recipient_list {
my $area_info = mySociety::MaPit::call('area', $body->body_areas->first->area_id);
my $country = $area_info->{country};
if ($country eq 'W') {
- push @{$self->bcc}, 'wales@' . mySociety::Config::get('EMAIL_DOMAIN');
+ push @{$self->bcc}, 'wales@' . FixMyStreet->config('EMAIL_DOMAIN');
} elsif ($country eq 'S') {
- push @{$self->bcc}, 'scotland@' . mySociety::Config::get('EMAIL_DOMAIN');
+ push @{$self->bcc}, 'scotland@' . FixMyStreet->config('EMAIL_DOMAIN');
} else {
- push @{$self->bcc}, 'eha@' . mySociety::Config::get('EMAIL_DOMAIN');
+ push @{$self->bcc}, 'eha@' . FixMyStreet->config('EMAIL_DOMAIN');
}
}
diff --git a/perllib/FixMyStreet/SendReport/Noop.pm b/perllib/FixMyStreet/SendReport/Noop.pm
index f2e0a3bdb..60edda373 100644
--- a/perllib/FixMyStreet/SendReport/Noop.pm
+++ b/perllib/FixMyStreet/SendReport/Noop.pm
@@ -1,6 +1,6 @@
package FixMyStreet::SendReport::Noop;
-use Moose;
+use Moo;
BEGIN { extends 'FixMyStreet::SendReport'; }
diff --git a/perllib/FixMyStreet/SendReport/Open311.pm b/perllib/FixMyStreet/SendReport/Open311.pm
index fa216466e..4844aa2e9 100644
--- a/perllib/FixMyStreet/SendReport/Open311.pm
+++ b/perllib/FixMyStreet/SendReport/Open311.pm
@@ -1,12 +1,10 @@
package FixMyStreet::SendReport::Open311;
-use Moose;
+use Moo;
use namespace::autoclean;
BEGIN { extends 'FixMyStreet::SendReport'; }
-use FixMyStreet::App;
-use mySociety::Config;
use DateTime::Format::W3CDTF;
use Open311;
use Readonly;
@@ -85,7 +83,7 @@ sub send {
}
# FIXME: we've already looked this up before
- my $contact = FixMyStreet::App->model("DB::Contact")->find( {
+ my $contact = $row->result_source->schema->resultset("Contact")->find( {
deleted => 0,
body_id => $body->id,
category => $row->category
diff --git a/perllib/FixMyStreet/SendReport/Refused.pm b/perllib/FixMyStreet/SendReport/Refused.pm
index d71fc5c2c..c6c1a660d 100644
--- a/perllib/FixMyStreet/SendReport/Refused.pm
+++ b/perllib/FixMyStreet/SendReport/Refused.pm
@@ -1,6 +1,6 @@
package FixMyStreet::SendReport::Refused;
-use Moose;
+use Moo;
BEGIN { extends 'FixMyStreet::SendReport::Noop'; }
diff --git a/perllib/FixMyStreet/SendReport/Zurich.pm b/perllib/FixMyStreet/SendReport/Zurich.pm
index 2838440cb..a8730bbe4 100644
--- a/perllib/FixMyStreet/SendReport/Zurich.pm
+++ b/perllib/FixMyStreet/SendReport/Zurich.pm
@@ -1,6 +1,6 @@
package FixMyStreet::SendReport::Zurich;
-use Moose;
+use Moo;
BEGIN { extends 'FixMyStreet::SendReport::Email'; }
@@ -14,7 +14,7 @@ sub build_recipient_list {
# Wunsch set, but external_message hasn't yet been filled in. TODO should
# we instead be holding off sending?)
if ( $row->external_body ) {
- $body = FixMyStreet::App->model("DB::Body")->find( { id => $row->external_body } );
+ $body = $row->result_source->schema->resultset("Body")->find( { id => $row->external_body } );
$h->{bodies_name} = $body->name;
$h->{external_message} = $row->get_extra_metadata('external_message') || '';
}
@@ -29,7 +29,7 @@ sub build_recipient_list {
my $parent = $body->parent;
if ($parent && !$parent->parent) {
# Division, might have an individual contact email address
- my $contact = FixMyStreet::App->model("DB::Contact")->find( {
+ my $contact = $row->result_source->schema->resultset("Contact")->find( {
body_id => $body->id,
category => $row->category
} );
@@ -72,7 +72,7 @@ sub send_from {
if ( $row->external_body ) {
my $body = @{ $self->bodies }[0];
my $body_email = $body->endpoint;
- my $contact = FixMyStreet::App->model("DB::Contact")->find( {
+ my $contact = $body->result_source->schema->resultset("Contact")->find( {
body_id => $body->id,
category => $row->category
} );