aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/Open311/GetServiceRequestUpdates.pm
diff options
context:
space:
mode:
Diffstat (limited to 'perllib/Open311/GetServiceRequestUpdates.pm')
-rw-r--r--perllib/Open311/GetServiceRequestUpdates.pm32
1 files changed, 3 insertions, 29 deletions
diff --git a/perllib/Open311/GetServiceRequestUpdates.pm b/perllib/Open311/GetServiceRequestUpdates.pm
index 2620b176a..8e83d08b9 100644
--- a/perllib/Open311/GetServiceRequestUpdates.pm
+++ b/perllib/Open311/GetServiceRequestUpdates.pm
@@ -107,7 +107,7 @@ sub update_comments {
my $c = $p->comments->search( { external_id => $request->{update_id} } );
if ( !$c->first ) {
- my $state = $self->map_state( $request->{status} );
+ my $state = $open311->map_state( $request->{status} );
my $comment = $self->schema->resultset('Comment')->new(
{
problem => $p,
@@ -124,16 +124,8 @@ sub update_comments {
}
);
- if ($request->{media_url}) {
- my $ua = LWP::UserAgent->new;
- my $res = $ua->get($request->{media_url});
- if ( $res->is_success && $res->content_type eq 'image/jpeg' ) {
- my $photoset = FixMyStreet::App::Model::PhotoSet->new({
- data_items => [ $res->decoded_content ],
- });
- $comment->photo($photoset->data);
- }
- }
+ $open311->add_media($request->{media_url}, $comment)
+ if $request->{media_url};
# if the comment is older than the last update
# do not change the status of the problem as it's
@@ -195,22 +187,4 @@ sub comment_text_for_request {
return "";
}
-sub map_state {
- my $self = shift;
- my $incoming_state = shift;
-
- $incoming_state = lc($incoming_state);
- $incoming_state =~ s/_/ /g;
-
- my %state_map = (
- fixed => 'fixed - council',
- 'not councils responsibility' => 'not responsible',
- 'no further action' => 'unable to fix',
- open => 'confirmed',
- closed => 'fixed - council'
- );
-
- return $state_map{$incoming_state} || $incoming_state;
-}
-
1;