aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet
diff options
context:
space:
mode:
Diffstat (limited to 'perllib/FixMyStreet')
-rw-r--r--perllib/FixMyStreet/App/Controller/Open311/Updates.pm17
-rw-r--r--perllib/FixMyStreet/App/Controller/Report/New.pm13
-rw-r--r--perllib/FixMyStreet/DB/Result/Problem.pm81
3 files changed, 1 insertions, 110 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Open311/Updates.pm b/perllib/FixMyStreet/App/Controller/Open311/Updates.pm
index 105400a8a..d5754bab7 100644
--- a/perllib/FixMyStreet/App/Controller/Open311/Updates.pm
+++ b/perllib/FixMyStreet/App/Controller/Open311/Updates.pm
@@ -3,7 +3,6 @@ package FixMyStreet::App::Controller::Open311::Updates;
use utf8;
use Moose;
use namespace::autoclean;
-use Open311;
use Open311::GetServiceRequestUpdates;
BEGIN { extends 'Catalyst::Controller'; }
@@ -31,7 +30,6 @@ sub receive : Regex('^open311/v2/servicerequestupdates.(xml|json)$') : Args(0) {
$body = $c->model('DB::Body')->find({ id => $c->get_param('jurisdiction_id') });
}
$c->detach('bad_request', ['jurisdiction_id']) unless $body;
- my $user = $body->comment_user;
my $key = $c->get_param('api_key') || '';
my $token = $c->cobrand->feature('open311_token') || '';
@@ -45,21 +43,8 @@ sub receive : Regex('^open311/v2/servicerequestupdates.(xml|json)$') : Args(0) {
$request->{$_} = $c->get_param($_) || $c->detach('bad_request', [ $_ ]);
}
- my %open311_conf = (
- endpoint => $body->endpoint,
- api_key => $body->api_key,
- jurisdiction => $body->jurisdiction,
- extended_statuses => $body->send_extended_statuses,
- );
-
- my $cobrand = $body->get_cobrand_handler;
- $cobrand->call_hook(open311_config_updates => \%open311_conf)
- if $cobrand;
-
- my $open311 = Open311->new(%open311_conf);
my $updates = Open311::GetServiceRequestUpdates->new(
- system_user => $user,
- current_open311 => $open311,
+ system_user => $body->comment_user,
current_body => $body,
);
diff --git a/perllib/FixMyStreet/App/Controller/Report/New.pm b/perllib/FixMyStreet/App/Controller/Report/New.pm
index ad324fe60..f5933d754 100644
--- a/perllib/FixMyStreet/App/Controller/Report/New.pm
+++ b/perllib/FixMyStreet/App/Controller/Report/New.pm
@@ -1679,21 +1679,8 @@ sub create_related_things : Private {
foreach my $body (values %{$problem->bodies}) {
my $user = $body->comment_user or next;
- my %open311_conf = (
- endpoint => $body->endpoint || '',
- api_key => $body->api_key || '',
- jurisdiction => $body->jurisdiction || '',
- extended_statuses => $body->send_extended_statuses,
- );
-
- my $cobrand = $body->get_cobrand_handler;
- $cobrand->call_hook(open311_config_updates => \%open311_conf)
- if $cobrand;
-
- my $open311 = Open311->new(%open311_conf);
my $updates = Open311::GetServiceRequestUpdates->new(
system_user => $user,
- current_open311 => $open311,
current_body => $body,
blank_updates_permitted => 1,
);
diff --git a/perllib/FixMyStreet/DB/Result/Problem.pm b/perllib/FixMyStreet/DB/Result/Problem.pm
index 42983c9ad..0653de32b 100644
--- a/perllib/FixMyStreet/DB/Result/Problem.pm
+++ b/perllib/FixMyStreet/DB/Result/Problem.pm
@@ -838,87 +838,6 @@ sub local_coords {
}
}
-=head2 update_from_open311_service_request
-
- $p->update_from_open311_service_request( $request, $body, $system_user );
-
-Updates the problem based on information in the passed in open311 request
-(standard, not the extension that uses GetServiceRequestUpdates) . If the
-request has an older update time than the problem's lastupdate time then
-nothing happens.
-
-Otherwise a comment will be created if there is status update text in the
-open311 request. If the open311 request has a state of closed then the problem
-will be marked as fixed.
-
-NB: a comment will always be created if the problem is being marked as fixed.
-
-Fixed problems will not be re-opened by this method.
-
-=cut
-
-sub update_from_open311_service_request {
- my ( $self, $request, $body, $system_user ) = @_;
-
- my ( $updated, $status_notes );
-
- if ( ! ref $request->{updated_datetime} ) {
- $updated = $request->{updated_datetime};
- }
-
- if ( ! ref $request->{status_notes} ) {
- $status_notes = $request->{status_notes};
- }
-
- my $update = $self->new_related(comments => {
- state => 'confirmed',
- created => $updated || \'current_timestamp',
- confirmed => \'current_timestamp',
- text => $status_notes,
- mark_open => 0,
- mark_fixed => 0,
- user => $system_user,
- anonymous => 0,
- name => $body->name,
- });
-
- my $w3c = DateTime::Format::W3CDTF->new;
- my $req_time = $w3c->parse_datetime( $request->{updated_datetime} );
-
- # set a timezone here as the $req_time will have one and if we don't
- # use a timezone then the date comparisons are invalid.
- # of course if local timezone is not the one that went into the data
- # base then we're also in trouble
- my $lastupdate = $self->lastupdate;
- $lastupdate->set_time_zone( FixMyStreet->local_time_zone );
-
- # update from open311 is older so skip
- if ( $req_time < $lastupdate ) {
- return 0;
- }
-
- if ( $request->{status} eq 'closed' ) {
- if ( $self->state ne 'fixed' ) {
- $self->state('fixed');
- $update->mark_fixed(1);
-
- if ( !$status_notes ) {
- # FIXME - better text here
- $status_notes = _('Closed by council');
- }
- }
- }
-
- if ( $status_notes ) {
- $update->text( $status_notes );
- $self->lastupdate( $req_time );
- $self->update;
- $update->insert;
- }
-
- return 1;
-}
-
sub update_send_failed {
my $self = shift;
my $msg = shift;