diff options
Diffstat (limited to 'perllib')
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Admin.pm | 6 | ||||
-rw-r--r-- | perllib/FixMyStreet/DB/Result/Problem.pm | 8 | ||||
-rw-r--r-- | perllib/FixMyStreet/Script/Reports.pm | 9 | ||||
-rwxr-xr-x | perllib/Open311/PostServiceRequestUpdates.pm | 2 |
4 files changed, 19 insertions, 6 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Admin.pm b/perllib/FixMyStreet/App/Controller/Admin.pm index 8aac408e4..3bf4f911c 100644 --- a/perllib/FixMyStreet/App/Controller/Admin.pm +++ b/perllib/FixMyStreet/App/Controller/Admin.pm @@ -905,7 +905,7 @@ sub report_edit : Path('report_edit') : Args(1) { if ( $c->get_param('resend') ) { $c->forward('/auth/check_csrf_token'); - $problem->whensent(undef); + $problem->resend; $problem->update(); $c->stash->{status_message} = '<p><em>' . _('That problem will now be resent.') . '</em></p>'; @@ -1023,7 +1023,7 @@ sub report_edit_category : Private { # If the report has changed bodies (and not to a subset!) we need to resend it my %old_map = map { $_ => 1 } @{$problem->bodies_str_ids}; if (grep !$old_map{$_}, @new_body_ids) { - $problem->whensent(undef); + $problem->resend; } # If the send methods of the old/new contacts differ we need to resend the report my @new_send_methods = uniq map { @@ -1034,7 +1034,7 @@ sub report_edit_category : Private { } @contacts; my %old_send_methods = map { $_ => 1 } split /,/, ($problem->send_method_used || "Email"); if (grep !$old_send_methods{$_}, @new_send_methods) { - $problem->whensent(undef); + $problem->resend; } $problem->bodies_str(join( ',', @new_body_ids )); diff --git a/perllib/FixMyStreet/DB/Result/Problem.pm b/perllib/FixMyStreet/DB/Result/Problem.pm index a222c78cd..0b8bc4de0 100644 --- a/perllib/FixMyStreet/DB/Result/Problem.pm +++ b/perllib/FixMyStreet/DB/Result/Problem.pm @@ -893,7 +893,7 @@ bodies by some mechanism. Right now that mechanism is Open311. sub updates_sent_to_body { my $self = shift; - return unless $self->send_method_used && $self->send_method_used eq 'Open311'; + return unless $self->send_method_used && $self->send_method_used =~ /Open311/; # Some bodies only send updates *to* FMS, they don't receive updates. my $cobrand = $self->get_cobrand_logged; @@ -922,6 +922,12 @@ sub add_send_method { } } +sub resend { + my $self = shift; + $self->whensent(undef); + $self->send_method_used(undef); +} + sub as_hashref { my ($self, $c, $cols) = @_; diff --git a/perllib/FixMyStreet/Script/Reports.pm b/perllib/FixMyStreet/Script/Reports.pm index dd8f4e370..5cadd4fa2 100644 --- a/perllib/FixMyStreet/Script/Reports.pm +++ b/perllib/FixMyStreet/Script/Reports.pm @@ -211,12 +211,13 @@ sub send(;$) { # Multiply results together, so one success counts as a success. my $result = -1; + my @methods; for my $sender ( keys %reporters ) { debug_print("sending using " . $sender, $row->id) if $debug_mode; $sender = $reporters{$sender}; my $res = $sender->send( $row, \%h ); $result *= $res; - $row->add_send_method($sender) if !$res; + push @methods, $sender if !$res; if ( $sender->unconfirmed_counts) { foreach my $e (keys %{ $sender->unconfirmed_counts } ) { foreach my $c (keys %{ $sender->unconfirmed_counts->{$e} }) { @@ -229,6 +230,12 @@ sub send(;$) { if FixMyStreet->test_mode && $sender->can('open311_test_req_used'); } + # Add the send methods now because e.g. Open311 + # send() calls $row->discard_changes + foreach (@methods) { + $row->add_send_method($_); + } + unless ($result) { $row->update( { whensent => \'current_timestamp', diff --git a/perllib/Open311/PostServiceRequestUpdates.pm b/perllib/Open311/PostServiceRequestUpdates.pm index 63e149ece..e2172c028 100755 --- a/perllib/Open311/PostServiceRequestUpdates.pm +++ b/perllib/Open311/PostServiceRequestUpdates.pm @@ -60,7 +60,7 @@ sub process_body { 'problem.whensent' => { '!=' => undef }, 'problem.external_id' => { '!=' => undef }, 'problem.bodies_str' => { -like => '%' . $body->id . '%' }, - 'problem.send_method_used' => 'Open311', + 'problem.send_method_used' => { -like => '%Open311%' }, }, { join => 'problem', |