aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/Script
diff options
context:
space:
mode:
Diffstat (limited to 'perllib/FixMyStreet/Script')
-rw-r--r--perllib/FixMyStreet/Script/Alerts.pm20
-rw-r--r--perllib/FixMyStreet/Script/Questionnaires.pm6
-rw-r--r--perllib/FixMyStreet/Script/Reports.pm4
3 files changed, 20 insertions, 10 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,
diff --git a/perllib/FixMyStreet/Script/Questionnaires.pm b/perllib/FixMyStreet/Script/Questionnaires.pm
index ec6139d2d..5fc01512d 100644
--- a/perllib/FixMyStreet/Script/Questionnaires.pm
+++ b/perllib/FixMyStreet/Script/Questionnaires.pm
@@ -49,7 +49,11 @@ sub send_questionnaires_period {
# Not all cobrands send questionnaires
next unless $cobrand->send_questionnaires;
- next if $row->is_from_abuser;
+
+ if ($row->is_from_abuser || !$row->user->email_verified) {
+ $row->update( { send_questionnaire => 0 } );
+ next;
+ }
# Cobranded and non-cobranded messages can share a database. In this case, the conf file
# should specify a vhost to send the reports for each cobrand, so that they don't get sent
diff --git a/perllib/FixMyStreet/Script/Reports.pm b/perllib/FixMyStreet/Script/Reports.pm
index 1e5fd55bb..1ea98342c 100644
--- a/perllib/FixMyStreet/Script/Reports.pm
+++ b/perllib/FixMyStreet/Script/Reports.pm
@@ -84,7 +84,6 @@ sub send(;$) {
$h{query} = $row->postcode;
$h{url} = $email_base_url . $row->url;
$h{admin_url} = $row->admin_url($cobrand);
- $h{phone_line} = $h{phone} ? _('Phone:') . " $h{phone}\n\n" : '';
if ($row->photo) {
$h{has_photo} = _("This web page also contains a photo of the problem, provided by the user.") . "\n\n";
$h{image_url} = $email_base_url . $row->photos->[0]->{url_full};
@@ -299,6 +298,9 @@ sub _send_report_sent_email {
my $nomail = shift;
my $cobrand = shift;
+ # Don't send 'report sent' text
+ return unless $row->user->email_verified;
+
FixMyStreet::Email::send_cron(
$row->result_source->schema,
'confirm_report_sent.txt',