From d8cfef2a844ae048a3b3a30f515d1d174b2cad10 Mon Sep 17 00:00:00 2001 From: Dave Arter Date: Tue, 17 Sep 2024 15:27:17 +0100 Subject: [PATCH] =?UTF-8?q?[Surrey]=20Don=E2=80=99t=20fetch=20&=20upload?= =?UTF-8?q?=20photos=20from=20media=5Furl?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Photos should only be uploaded if the photo content was POSTed from FMS. --- perllib/Open311/Endpoint/Integration/Boomi.pm | 12 ++---------- t/open311/endpoint/surrey_boomi.t | 6 ++---- 2 files changed, 4 insertions(+), 14 deletions(-) diff --git a/perllib/Open311/Endpoint/Integration/Boomi.pm b/perllib/Open311/Endpoint/Integration/Boomi.pm index ddf21809f..40da49f9e 100644 --- a/perllib/Open311/Endpoint/Integration/Boomi.pm +++ b/perllib/Open311/Endpoint/Integration/Boomi.pm @@ -308,19 +308,11 @@ sub _add_attachments { my @attachments; - my $ua = LWP::UserAgent->new(agent => "FixMyStreet/open311-adapter"); - for my $photo (@{ $args->{media_url} }) { - my $photo_response = $ua->get($photo); - unless ( $photo_response->is_success) { - $self->logger->error("Failed to retrieve photo from $photo\n"); - die "Failed to retrieve photo from $photo"; - } - + my $filename = (URI->new($photo)->path_segments)[-1]; push @attachments, { - fileName => $photo_response->filename, url => $photo, - base64 => encode_base64($photo_response->content), + fileName => $filename, }; } diff --git a/t/open311/endpoint/surrey_boomi.t b/t/open311/endpoint/surrey_boomi.t index 3783f6faa..8e1937fcb 100644 --- a/t/open311/endpoint/surrey_boomi.t +++ b/t/open311/endpoint/surrey_boomi.t @@ -33,8 +33,7 @@ $lwp->mock(request => sub { "attachments" => [ { "url" => "http://localhost/photo/one.jpeg", - "fileName" => "1.jpeg", - "base64" => "/9j/4AAQSkZJRgABAQAAAAAAAAD/2wBDAAMCAgICAgMCAgIDAwMDBAYEBAQEBAgGBgUGCQgKCgkI\nCQkKDA8MCgsOCwkJDRENDg8QEBEQCgwSExIQEw8QEBD/wAALCAABAAEBAREA/8QAFAABAAAAAAAA\nAAAAAAAAAAAACf/EABQQAQAAAAAAAAAAAAAAAAAAAAD/2gAIAQEAAD8AKp//2Q==\n", + "fileName" => "one.jpeg", }, ] }; @@ -133,8 +132,7 @@ $lwp->mock(request => sub { "attachments" => [ { "url" => "http://localhost/photo/one.jpeg", - "fileName" => "1.jpeg", - "base64" => "/9j/4AAQSkZJRgABAQAAAAAAAAD/2wBDAAMCAgICAgMCAgIDAwMDBAYEBAQEBAgGBgUGCQgKCgkI\nCQkKDA8MCgsOCwkJDRENDg8QEBEQCgwSExIQEw8QEBD/wAALCAABAAEBAREA/8QAFAABAAAAAAAA\nAAAAAAAAAAAACf/EABQQAQAAAAAAAAAAAAAAAAAAAAD/2gAIAQEAAD8AKp//2Q==\n", + "fileName" => "one.jpeg", }, ] };