aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--perllib/FixMyStreet/App.pm10
-rw-r--r--perllib/FixMyStreet/Cobrand/EmptyHomes.pm14
-rw-r--r--perllib/FixMyStreet/DB/ResultSet/AlertType.pm6
-rw-r--r--perllib/FixMyStreet/DB/ResultSet/Questionnaire.pm1
-rw-r--r--t/app/controller/alert_new.t21
5 files changed, 31 insertions, 21 deletions
diff --git a/perllib/FixMyStreet/App.pm b/perllib/FixMyStreet/App.pm
index 205732caf..cf766348f 100644
--- a/perllib/FixMyStreet/App.pm
+++ b/perllib/FixMyStreet/App.pm
@@ -316,6 +316,8 @@ sub send_email {
$email->header_set( ucfirst($_), $vars->{$_} )
for grep { $vars->{$_} } qw( to from subject);
+ return if $c->is_abuser( $email->header('To') );
+
$email->header_set( 'Message-ID', sprintf('<fms-%s-%s@%s>',
time(), unpack('h*', random_bytes(5, 1)), $c->config->{EMAIL_DOMAIN}
) );
@@ -340,6 +342,8 @@ sub send_email {
sub send_email_cron {
my ( $c, $params, $env_from, $env_to, $nomail ) = @_;
+ return 1 if $c->is_abuser( $env_to );
+
$params->{'Message-ID'} = sprintf('<fms-cron-%s-%s@mysociety.org>', time(),
unpack('h*', random_bytes(5, 1))
);
@@ -482,6 +486,12 @@ sub get_photo_params {
return $photo;
}
+sub is_abuser {
+ my ($c, $email) = @_;
+ my ($domain) = $email =~ m{ @ (.*) \z }x;
+ return $c->model('DB::Abuse')->search( { email => [ $email, $domain ] } )->first;
+}
+
=head1 SEE ALSO
L<FixMyStreet::App::Controller::Root>, L<Catalyst>
diff --git a/perllib/FixMyStreet/Cobrand/EmptyHomes.pm b/perllib/FixMyStreet/Cobrand/EmptyHomes.pm
index 99aec5ac1..47ea023d9 100644
--- a/perllib/FixMyStreet/Cobrand/EmptyHomes.pm
+++ b/perllib/FixMyStreet/Cobrand/EmptyHomes.pm
@@ -62,6 +62,20 @@ to be resized then return 0;
sub default_photo_resize { return '195x'; }
+sub short_name {
+ my $self = shift;
+ my ($area) = @_;
+
+ my $name = $area->{name} || $area->name;
+ $name =~ s/ (Borough|City|District|County) Council$//;
+ $name =~ s/ Council$//;
+ $name =~ s/ & / and /;
+ $name =~ s{/}{_}g;
+ $name = URI::Escape::uri_escape_utf8($name);
+ $name =~ s/%20/-/g;
+ return $name;
+}
+
=item council_rss_alert_options
Generate a set of options for council rss alerts.
diff --git a/perllib/FixMyStreet/DB/ResultSet/AlertType.pm b/perllib/FixMyStreet/DB/ResultSet/AlertType.pm
index f2b86725d..a2784950a 100644
--- a/perllib/FixMyStreet/DB/ResultSet/AlertType.pm
+++ b/perllib/FixMyStreet/DB/ResultSet/AlertType.pm
@@ -156,6 +156,7 @@ sub email_alerts ($) {
while (my $alert = $query->next) {
my $cobrand = FixMyStreet::Cobrand->get_class_for_moniker($alert->cobrand)->new();
next unless $cobrand->email_host;
+ next if $alert->is_from_abuser;
my $longitude = $alert->parameter;
my $latitude = $alert->parameter2;
@@ -212,6 +213,11 @@ sub _send_aggregated_alert_email(%) {
$data{alert_email} = $user->email;
}
+ my ($domain) = $data{alert_email} =~ m{ @ (.*) \z }x;
+ return if FixMyStreet::App->model('DB::Abuse')->search( {
+ email => [ $data{alert_email}, $domain ]
+ } )->first;
+
my $token = FixMyStreet::App->model("DB::Token")->new_result( {
scope => 'alert',
data => {
diff --git a/perllib/FixMyStreet/DB/ResultSet/Questionnaire.pm b/perllib/FixMyStreet/DB/ResultSet/Questionnaire.pm
index 8d811180e..c85ecbf3a 100644
--- a/perllib/FixMyStreet/DB/ResultSet/Questionnaire.pm
+++ b/perllib/FixMyStreet/DB/ResultSet/Questionnaire.pm
@@ -50,6 +50,7 @@ sub send_questionnaires_period {
# Not all cobrands send questionnaires
next unless $cobrand->send_questionnaires;
+ next if $row->is_from_abuser;
# 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/t/app/controller/alert_new.t b/t/app/controller/alert_new.t
index 95a7d51e2..43d90c0ba 100644
--- a/t/app/controller/alert_new.t
+++ b/t/app/controller/alert_new.t
@@ -277,29 +277,8 @@ for my $test (
ok $alert, "Found the alert";
- my $email = $mech->get_email;
- ok $email, "got an email";
- like $email->body, qr/$test->{email_text}/i, "Correct email text";
-
- my ( $url, $url_token ) = $email->body =~ m{(http://\S+/A/)(\S+)};
- ok $url, "extracted confirm url '$url'";
-
- my $token = FixMyStreet::App->model('DB::Token')->find(
- {
- token => $url_token,
- scope => 'alert'
- }
- );
- ok $token, 'Token found in database';
- ok $alert->id == $token->data->{id}, 'token alertid matches alert id';
-
$mech->clear_emails_ok;
- $mech->get_ok("/A/$url_token");
- $mech->content_contains('error confirming');
-
- $alert->discard_changes;
-
ok !$alert->confirmed, 'alert not set to confirmed';
$abuse->delete;