diff options
-rw-r--r-- | perllib/FixMyStreet/SendReport.pm | 17 | ||||
-rw-r--r-- | perllib/FixMyStreet/SendReport/EastHants.pm | 23 | ||||
-rw-r--r-- | perllib/FixMyStreet/SendReport/Email.pm | 21 | ||||
-rw-r--r-- | perllib/FixMyStreet/SendReport/London.pm | 19 | ||||
-rw-r--r-- | perllib/FixMyStreet/SendReport/Open311.pm | 25 |
5 files changed, 40 insertions, 65 deletions
diff --git a/perllib/FixMyStreet/SendReport.pm b/perllib/FixMyStreet/SendReport.pm index 3a79bd82a..f2ebdd3d7 100644 --- a/perllib/FixMyStreet/SendReport.pm +++ b/perllib/FixMyStreet/SendReport.pm @@ -2,6 +2,23 @@ package FixMyStreet::SendReport; use Moose; +has 'councils' => (is => 'rw', isa => 'HashRef', default => sub { {} } ); +has 'to' => (is => 'rw', isa => 'ArrayRef', default => sub { [] } ); + +sub reset { + my $self = shift; + + $self->councils( {} ); + $self->to( [] ); +} + +sub add_council { + my $self = shift; + my $council = shift; + my $name = shift; + + $self->councils->{ $council } = $name; +} 1; diff --git a/perllib/FixMyStreet/SendReport/EastHants.pm b/perllib/FixMyStreet/SendReport/EastHants.pm index 0e9944b18..aa290742e 100644 --- a/perllib/FixMyStreet/SendReport/EastHants.pm +++ b/perllib/FixMyStreet/SendReport/EastHants.pm @@ -1,25 +1,15 @@ package FixMyStreet::SendReport::Email; +use Moose; +use namespace::autoclean; + +BEGIN { extends 'FixMyStreet::SendReport'; } + use Error qw(:try); use Encode; use mySociety::Web qw(ent); use EastHantsWSDL; -my %councils = (); -my @to; - -sub reset { - %councils = (); - @to = (); -} - -sub add_council { - my $council = shift; - my $name = shift; - - $councils{ $council } = $name; -} - sub construct_message { my %h = @_; my $message = ''; @@ -44,6 +34,9 @@ sub send { my ( $row, $h, $to, $template, $recips, $nomail ) = @_; + # FIXME: should not recreate this each time + my $eh_service; + $h->{category} = 'Customer Services' if $h->{category} eq 'Other'; $h->{message} = construct_message( %$h ); my $return = 1; diff --git a/perllib/FixMyStreet/SendReport/Email.pm b/perllib/FixMyStreet/SendReport/Email.pm index ab9d7edcc..c231a6b61 100644 --- a/perllib/FixMyStreet/SendReport/Email.pm +++ b/perllib/FixMyStreet/SendReport/Email.pm @@ -5,27 +5,6 @@ use namespace::autoclean; BEGIN { extends 'FixMyStreet::SendReport'; } -has 'councils' => (is => 'rw', isa => 'HashRef', default => sub { {} } ); -has 'to' => (is => 'rw', isa => 'ArrayRef', default => sub { [] } ); - -my %councils = (); -my @to; - -sub reset { - my $self = shift; - - $self->councils( {} ); - $self->to( [] ); -} - -sub add_council { - my $self = shift; - my $council = shift; - my $name = shift; - - $self->councils->{ $council } = $name; -} - sub build_recipient_list { my $self = shift; my $row = shift; diff --git a/perllib/FixMyStreet/SendReport/London.pm b/perllib/FixMyStreet/SendReport/London.pm index cb76c7a24..29368314f 100644 --- a/perllib/FixMyStreet/SendReport/London.pm +++ b/perllib/FixMyStreet/SendReport/London.pm @@ -1,25 +1,16 @@ package FixMyStreet::SendReport::Email; +use Moose; +use namespace::autoclean; + +BEGIN { extends 'FixMyStreet::SendReport'; } + use Digest::MD5; use LWP::UserAgent; use LWP::Simple; use Utils; -my %councils = (); -my @to; - -sub reset { - %councils = (); - @to = (); -} - -sub add_council { - my $council = shift; - my $name = shift; - - $councils{ $council } = $name; -} sub construct_message { my %h = @_; return <<EOF, diff --git a/perllib/FixMyStreet/SendReport/Open311.pm b/perllib/FixMyStreet/SendReport/Open311.pm index a76c44cce..cb41de336 100644 --- a/perllib/FixMyStreet/SendReport/Open311.pm +++ b/perllib/FixMyStreet/SendReport/Open311.pm @@ -1,28 +1,21 @@ package FixMyStreet::SendReport::Open311; +use Moose; +use namespace::autoclean; + +BEGIN { extends 'FixMyStreet::SendReport'; } + use FixMyStreet::App; use mySociety::Config; use Open311; -my %councils = (); -my @to; - -sub reset { - %councils = (); - @to = (); -} - -sub add_council { - my $council = shift; - my $name = shift; - - $councils{ $council } = $name; -} - sub send { return if mySociety::Config::get('STAGING_SITE'); my $self = shift; my ( $row, $h, $to, $template, $recips, $nomail ) = @_; + + my $result = -1; + foreach my $council ( keys %{ $self->councils } ) { my $conf = FixMyStreet::App->model("DB::Open311conf")->search( { area_id => $self->councils->{ $council }, endpoint => { '!=', '' } } )->first; #print 'posting to end point for ' . $conf->area_id . "\n" if $verbose; @@ -69,6 +62,8 @@ sub send { } } } + + return $result; } 1; |