aboutsummaryrefslogtreecommitdiffstats
path: root/perllib
diff options
context:
space:
mode:
Diffstat (limited to 'perllib')
-rw-r--r--perllib/FixMyStreet/Cobrand/Default.pm2
-rwxr-xr-xperllib/Open311/PostServiceRequestUpdates.pm25
2 files changed, 16 insertions, 11 deletions
diff --git a/perllib/FixMyStreet/Cobrand/Default.pm b/perllib/FixMyStreet/Cobrand/Default.pm
index c8e11f93d..73340338b 100644
--- a/perllib/FixMyStreet/Cobrand/Default.pm
+++ b/perllib/FixMyStreet/Cobrand/Default.pm
@@ -961,7 +961,7 @@ sub get_body_sender {
# look up via category
my $contact = $body->contacts->search( { category => $category } )->first;
- if ( $body->can_be_devolved && $contact->send_method ) {
+ if ( $body->can_be_devolved && $contact && $contact->send_method ) {
return { method => $contact->send_method, config => $contact, contact => $contact };
}
diff --git a/perllib/Open311/PostServiceRequestUpdates.pm b/perllib/Open311/PostServiceRequestUpdates.pm
index 68823343c..d7345ea4d 100755
--- a/perllib/Open311/PostServiceRequestUpdates.pm
+++ b/perllib/Open311/PostServiceRequestUpdates.pm
@@ -14,14 +14,12 @@ use Open311;
use constant SEND_METHOD_OPEN311 => 'Open311';
has verbose => ( is => 'ro', default => 0 );
-has current_open311 => ( is => 'rw' );
sub send {
my $self = shift;
my $bodies = $self->fetch_bodies;
foreach my $body (values %$bodies) {
- $self->construct_open311($body);
$self->process_body($body);
}
}
@@ -41,18 +39,25 @@ sub fetch_bodies {
}
sub construct_open311 {
- my ($self, $body) = @_;
- my $o = Open311->new($self->open311_params($body));
- $self->current_open311($o);
+ my ($self, $body, $comment) = @_;
+ my $o = Open311->new($self->open311_params($body, $comment));
+ return $o;
}
sub open311_params {
- my ($self, $body) = @_;
+ my ($self, $body, $comment) = @_;
+
+ my $conf = $body;
+ if ($comment) {
+ my $cobrand_logged = $comment->get_cobrand_logged;
+ my $sender = $cobrand_logged->get_body_sender($body, $comment->problem->category);
+ $conf = $sender->{config};
+ }
my %open311_conf = (
- endpoint => $body->endpoint,
- jurisdiction => $body->jurisdiction,
- api_key => $body->api_key,
+ endpoint => $conf->endpoint,
+ jurisdiction => $conf->jurisdiction,
+ api_key => $conf->api_key,
extended_statuses => $body->send_extended_statuses,
fixmystreet_body => $body,
);
@@ -119,7 +124,7 @@ sub process_update {
return;
}
- my $o = $self->current_open311;
+ my $o = $self->construct_open311($body, $comment);
$cobrand->call_hook(open311_pre_send => $comment, $o);