Skip to content

Commit

Permalink
[Surrey] Don’t fetch & upload photos from media_url
Browse files Browse the repository at this point in the history
Photos should only be uploaded if the photo content was
POSTed from FMS.
  • Loading branch information
davea committed Sep 17, 2024
1 parent 39cd0e1 commit d8cfef2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 14 deletions.
12 changes: 2 additions & 10 deletions perllib/Open311/Endpoint/Integration/Boomi.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
}

Expand Down
6 changes: 2 additions & 4 deletions t/open311/endpoint/surrey_boomi.t
Original file line number Diff line number Diff line change
Expand Up @@ -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",
},
]
};
Expand Down Expand Up @@ -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",
},
]
};
Expand Down

0 comments on commit d8cfef2

Please sign in to comment.