diff options
Diffstat (limited to 'perllib/FixMyStreet/DB/Result/Problem.pm')
-rw-r--r-- | perllib/FixMyStreet/DB/Result/Problem.pm | 59 |
1 files changed, 27 insertions, 32 deletions
diff --git a/perllib/FixMyStreet/DB/Result/Problem.pm b/perllib/FixMyStreet/DB/Result/Problem.pm index 8625bf17a..c73f7efca 100644 --- a/perllib/FixMyStreet/DB/Result/Problem.pm +++ b/perllib/FixMyStreet/DB/Result/Problem.pm @@ -867,6 +867,33 @@ sub update_send_failed { } ); } +=head2 updates_sent_to_body + +Returns 1 if updates left on this report will be sent to any of the receiving +bodies by some mechanism. Right now that mechanism is Open311. + +=cut + +sub updates_sent_to_body { + my $self = shift; + return unless $self->send_method_used && $self->send_method_used eq 'Open311'; + + # Some bodies only send updates *to* FMS, they don't receive updates. + # NB See also the list in bin/send-comments + my $excluded = qr{Lewisham|Oxfordshire}; + + my @bodies = values %{ $self->bodies }; + my @updates_sent = grep { + $_->send_comments && + ( + $_->send_method eq 'Open311' || + $_->send_method eq 'Noop' # Sending might be temporarily disabled + ) && + !($_->name =~ /$excluded/) + } @bodies; + return scalar @updates_sent; +} + sub add_send_method { my $self = shift; my $sender = shift; @@ -919,38 +946,6 @@ sub latest_moderation_log_entry { return $self->admin_log_entries->search({ action => 'moderation' }, { order_by => { -desc => 'id' } })->first; } -sub photos { - my $self = shift; - my $photoset = $self->get_photoset; - my $i = 0; - my $id = $self->id; - my @photos = map { - my $cachebust = substr($_, 0, 8); - # Some Varnish configurations (e.g. on mySociety infra) strip cookies from - # images, which means image requests will be redirected to the login page - # if LOGIN_REQUIRED is set. To stop this happening, Varnish should be - # configured to not strip cookies if the cookie_passthrough param is - # present, which this line ensures will be if LOGIN_REQUIRED is set. - my $extra = ''; - if (FixMyStreet->config('LOGIN_REQUIRED')) { - $cachebust .= '&cookie_passthrough=1'; - $extra = '?cookie_passthrough=1'; - } - my ($hash, $format) = split /\./, $_; - { - id => $hash, - url_temp => "/photo/temp.$hash.$format$extra", - url_temp_full => "/photo/fulltemp.$hash.$format$extra", - url => "/photo/$id.$i.$format?$cachebust", - url_full => "/photo/$id.$i.full.$format?$cachebust", - url_tn => "/photo/$id.$i.tn.$format?$cachebust", - url_fp => "/photo/$id.$i.fp.$format?$cachebust", - idx => $i++, - } - } $photoset->all_ids; - return \@photos; -} - __PACKAGE__->has_many( "admin_log_entries", "FixMyStreet::DB::Result::AdminLog", |