diff options
Diffstat (limited to 'perllib/FixMyStreet/SendReport')
-rw-r--r-- | perllib/FixMyStreet/SendReport/EastHants.pm | 4 | ||||
-rw-r--r-- | perllib/FixMyStreet/SendReport/Email.pm | 8 | ||||
-rw-r--r-- | perllib/FixMyStreet/SendReport/London.pm | 4 | ||||
-rw-r--r-- | perllib/FixMyStreet/SendReport/Open311.pm | 3 |
4 files changed, 17 insertions, 2 deletions
diff --git a/perllib/FixMyStreet/SendReport/EastHants.pm b/perllib/FixMyStreet/SendReport/EastHants.pm index 61c38e591..681a9d4c4 100644 --- a/perllib/FixMyStreet/SendReport/EastHants.pm +++ b/perllib/FixMyStreet/SendReport/EastHants.pm @@ -32,7 +32,7 @@ EOF sub send { return if mySociety::Config::get('STAGING_SITE'); - my ( $row, $h, $to, $template, $recips, $nomail ) = @_; + my ( $self, $row, $h, $to, $template, $recips, $nomail ) = @_; # FIXME: should not recreate this each time my $eh_service; @@ -53,7 +53,9 @@ sub send { } otherwise { my $e = shift; print "Caught an error: $e\n"; + $self->error( "Error sending to East Hants: $e" ); }; + $self->success( !$return ); return $return; } diff --git a/perllib/FixMyStreet/SendReport/Email.pm b/perllib/FixMyStreet/SendReport/Email.pm index 0b8ac8115..239bee715 100644 --- a/perllib/FixMyStreet/SendReport/Email.pm +++ b/perllib/FixMyStreet/SendReport/Email.pm @@ -4,6 +4,8 @@ use Moose; BEGIN { extends 'FixMyStreet::SendReport'; } +use mySociety::EmailUtil; + sub build_recipient_list { my $self = shift; my $row = shift; @@ -66,6 +68,12 @@ sub send { $nomail ); + if ( $result == mySociety::EmailUtil::EMAIL_SUCCESS ) { + $self->success(1); + } else { + $self->error( 'Failed to send email' ); + } + return $result; } diff --git a/perllib/FixMyStreet/SendReport/London.pm b/perllib/FixMyStreet/SendReport/London.pm index 9296f2446..58ecb2375 100644 --- a/perllib/FixMyStreet/SendReport/London.pm +++ b/perllib/FixMyStreet/SendReport/London.pm @@ -33,7 +33,7 @@ EOF sub send { return if mySociety::Config::get('STAGING_SITE'); - my ( $row, $h, $to, $template, $recips, $nomail ) = @_; + my ( $self, $row, $h, $to, $template, $recips, $nomail ) = @_; $h->{message} = construct_message( %$h ); my $phone = $h->{phone}; @@ -80,6 +80,7 @@ sub send { my $out = $response->content; if ($response->code ne 200) { print "Failed to post $h->{id} to London API, response was " . $response->code . " $out\n"; + $self->error( "Failed to post $h->{id} to London API, response was " . $response->code . " $out" ); return 1; } my ($id) = $out =~ /<caseid>(.*?)<\/caseid>/; @@ -90,6 +91,7 @@ sub send { $row->external_id( $id ); $row->external_body( $org ); $row->external_team( $team ); + $self->success(1); return 0; } diff --git a/perllib/FixMyStreet/SendReport/Open311.pm b/perllib/FixMyStreet/SendReport/Open311.pm index cb41de336..beed04658 100644 --- a/perllib/FixMyStreet/SendReport/Open311.pm +++ b/perllib/FixMyStreet/SendReport/Open311.pm @@ -54,6 +54,7 @@ sub send { if ( $resp ) { $row->external_id( $resp ); $result *= 0; + $self->success( 1 ) } else { $result *= 1; # temporary fix to resolve some issues with west berks @@ -63,6 +64,8 @@ sub send { } } + $self->error( 'Failed to send over Open311' ) unless $self->success; + return $result; } |