diff options
-rw-r--r-- | perllib/FixMyStreet/SendReport/Open311.pm | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/perllib/FixMyStreet/SendReport/Open311.pm b/perllib/FixMyStreet/SendReport/Open311.pm index beed04658..56138b75b 100644 --- a/perllib/FixMyStreet/SendReport/Open311.pm +++ b/perllib/FixMyStreet/SendReport/Open311.pm @@ -20,6 +20,23 @@ sub send { 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; + # Extra bromley fields + if ( $row->council =~ /2482/ ) { + if ( $row->send_fail_count > 0 ) { + next if bromley_retry_timeout( $row ); + } + + my $extra = $row->extra; + push @$extra, { name => 'northing', value => $h->{northing} }; + push @$extra, { name => 'easting', value => $h->{easting} }; + push @$extra, { name => 'report_url', value => $h->{url} }; + push @$extra, { name => 'service_request_id_ext', value => $row->id }; + push @$extra, { name => 'report_title', value => $row->title }; + push @$extra, { name => 'public_anonymity_required', value => $row->anonymous ? 'TRUE' : 'FALSE' }; + push @$extra, { name => 'email_alerts_requested', value => 'FALSE' }; # always false as can never request them + push @$extra, { name => 'requested_datetime', value => $row->confirmed }; + $row->extra( $extra ); + } # FIXME: we've already looked this up before my $contact = FixMyStreet::App->model("DB::Contact")->find( { @@ -47,7 +64,7 @@ sub send { my $resp = $open311->send_service_request( $row, $h, $contact->email ); # make sure we don't save user changes from above - if ( $row->council =~ /2218/ ) { + if ( $row->council =~ /2218/ || $row->council =~ /2482/ ) { $row->discard_changes(); } @@ -69,4 +86,17 @@ sub send { return $result; } +sub bromley_retry_timeout { + my $row = shift; + + my $tz = DateTime::TimeZone->new( name => 'local' ); + my $now = DateTime->now( time_zone => $tz ); + my $diff = $now - $row->send_fail_timestamp; + if ( $diff->in_units( 'minutes' ) < 30 ) { + return 1; + } + + return 0; +} + 1; |