aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/Open311/PostServiceRequestUpdates.pm
diff options
context:
space:
mode:
authorMatthew Somerville <matthew@mysociety.org>2020-06-23 16:30:29 +0100
committerMatthew Somerville <matthew@mysociety.org>2020-06-23 18:18:26 +0100
commit4b780de3e34128a4581dbc4daead30be00ceadb4 (patch)
tree3e52feb4e64c9752d5d73098bd74986846850333 /perllib/Open311/PostServiceRequestUpdates.pm
parent58a7df7603b657e8b56bae9b46a0451b4534e9ad (diff)
[Open311] Use devolved data on update sending.
Diffstat (limited to 'perllib/Open311/PostServiceRequestUpdates.pm')
-rwxr-xr-xperllib/Open311/PostServiceRequestUpdates.pm25
1 files changed, 15 insertions, 10 deletions
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);