aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/Script/Alerts.pm
diff options
context:
space:
mode:
authorMatthew Somerville <matthew-github@dracos.co.uk>2017-09-30 22:14:48 +0100
committerMatthew Somerville <matthew-github@dracos.co.uk>2017-09-30 22:14:48 +0100
commit8e9cd7cdb0a0f0fe591c2ecc25ae480fa0a5f799 (patch)
treede46361b23538b6ba9644898a9f5a55b4aeed9e4 /perllib/FixMyStreet/Script/Alerts.pm
parenta369e1c1a178697d0f92cf82c5bdb23c1883925e (diff)
parent83825ebf47cfd40ac649853347c8352944a3d32a (diff)
Merge branch 'phone-number-work'
Diffstat (limited to 'perllib/FixMyStreet/Script/Alerts.pm')
-rw-r--r--perllib/FixMyStreet/Script/Alerts.pm20
1 files changed, 12 insertions, 8 deletions
diff --git a/perllib/FixMyStreet/Script/Alerts.pm b/perllib/FixMyStreet/Script/Alerts.pm
index c001cc311..86f11c7b5 100644
--- a/perllib/FixMyStreet/Script/Alerts.pm
+++ b/perllib/FixMyStreet/Script/Alerts.pm
@@ -109,7 +109,7 @@ sub send() {
my $user = $schema->resultset('User')->find( {
id => $row->{alert_user_id}
} );
- $data{alert_email} = $user->email;
+ $data{alert_user} = $user;
my $token_obj = $schema->resultset('Token')->create( {
scope => 'alert_to_reporter',
data => {
@@ -209,7 +209,7 @@ sub send() {
template => $template,
data => [],
alert_id => $alert->id,
- alert_email => $alert->user->email,
+ alert_user => $alert->user,
lang => $alert->lang,
cobrand => $cobrand,
cobrand_data => $alert->cobrand_data,
@@ -258,16 +258,20 @@ sub _send_aggregated_alert_email(%) {
$cobrand->set_lang_and_domain( $data{lang}, 1, FixMyStreet->path_to('locale')->stringify );
FixMyStreet::Map::set_map_class($cobrand->map_type);
- if (!$data{alert_email}) {
+ if (!$data{alert_user}) {
my $user = $data{schema}->resultset('User')->find( {
id => $data{alert_user_id}
} );
- $data{alert_email} = $user->email;
+ $data{alert_user} = $user;
}
- my ($domain) = $data{alert_email} =~ m{ @ (.*) \z }x;
+ # Ignore phone-only users
+ return unless $data{alert_user}->email_verified;
+
+ my $email = $data{alert_user}->email;
+ my ($domain) = $email =~ m{ @ (.*) \z }x;
return if $data{schema}->resultset('Abuse')->search( {
- email => [ $data{alert_email}, $domain ]
+ email => [ $email, $domain ]
} )->first;
my $token = $data{schema}->resultset("Token")->new_result( {
@@ -275,7 +279,7 @@ sub _send_aggregated_alert_email(%) {
data => {
id => $data{alert_id},
type => 'unsubscribe',
- email => $data{alert_email},
+ email => $email,
}
} );
$data{unsubscribe_url} = $cobrand->base_url( $data{cobrand_data} ) . '/A/' . $token->token;
@@ -286,7 +290,7 @@ sub _send_aggregated_alert_email(%) {
"$data{template}.txt",
\%data,
{
- To => $data{alert_email},
+ To => $email,
},
$sender,
0,