diff options
author | Hakim Cassimally <hakim@mysociety.org> | 2015-03-04 14:48:21 +0000 |
---|---|---|
committer | Dave Arter <davea@mysociety.org> | 2015-10-06 09:09:23 +0100 |
commit | d004b2df0c85615eab6924c35f478b45bdf84b2d (patch) | |
tree | 652c8880cd8a37f81b9f907c037aa2ffd0254b2d /perllib/FixMyStreet/Cobrand | |
parent | 597019d4fc28d160588d137ac58d948393f26af2 (diff) |
[Zurich] Attach images to external body
See mysociety/FixMyStreet-Commercial#675
Diffstat (limited to 'perllib/FixMyStreet/Cobrand')
-rw-r--r-- | perllib/FixMyStreet/Cobrand/Zurich.pm | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/perllib/FixMyStreet/Cobrand/Zurich.pm b/perllib/FixMyStreet/Cobrand/Zurich.pm index ca92470f2..3c1baaa48 100644 --- a/perllib/FixMyStreet/Cobrand/Zurich.pm +++ b/perllib/FixMyStreet/Cobrand/Zurich.pm @@ -670,6 +670,32 @@ sub _admin_send_email { } ); } +sub munge_sendreport_params { + my ($self, $c, $row, $h, $params) = @_; + if ($row->state =~ /^(closed|investigating)$/ && $row->get_extra_metadata('publish_photo')) { + # we attach images to reports sent to external bodies + my $photoset = $row->get_photoset($c); + my @images = $photoset->all_images + or return; + my $index = 0; + my $id = $row->id; + my @attachments = map { + my $i = $index++; + { + body => $_->[1], + attributes => { + filename => "$id.$i.jpeg", + content_type => 'image/jpeg', + encoding => 'base64', + # quoted-printable ends up with newlines corrupting binary data + name => "$id.$i.jpeg", + }, + } + } @images; + $params->{attachments} = \@attachments; + } +} + sub admin_fetch_all_bodies { my ( $self, @bodies ) = @_; @@ -761,7 +787,7 @@ sub admin_stats { # replace newlines with HTML <br/> element $detail =~ s{\r?\n}{ <br/> }g; - $public_response =~ s{\r?\n}{ <br/> }g; + $public_response =~ s{\r?\n}{ <br/> }g if $public_response; # Assemble photo URL, if report has a photo my $media_url = $report->get_photo_params->{url} ? ($c->cobrand->base_url . $report->get_photo_params->{url}) : ''; |