diff options
Diffstat (limited to 'perllib/FixMyStreet')
-rw-r--r-- | perllib/FixMyStreet/App.pm | 10 | ||||
-rw-r--r-- | perllib/FixMyStreet/Cobrand/EmptyHomes.pm | 14 | ||||
-rw-r--r-- | perllib/FixMyStreet/DB/ResultSet/AlertType.pm | 6 | ||||
-rw-r--r-- | perllib/FixMyStreet/DB/ResultSet/Questionnaire.pm | 1 |
4 files changed, 31 insertions, 0 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 |