aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Somerville <matthew-github@dracos.co.uk>2017-04-12 16:18:01 +0100
committerMatthew Somerville <matthew-github@dracos.co.uk>2017-04-12 16:18:01 +0100
commitefe6ac273fa3ec9edc48e7d196d59f2e9a82a224 (patch)
tree0178ff9df53d73c4d1f7965bcefeb30d18f25154
parent4c8f35f69a2435492e1bd5f38d20211b6b492c22 (diff)
Don't error when devolved body, blank send methods
The check assumed that if a body was devolved, either the contact or the body would have a send method. Instead, use a contact send method if devolved and it exists, a body send method if it exists or the fallback if neither. Fixes #1374.
-rw-r--r--perllib/FixMyStreet/Cobrand/Default.pm12
1 files changed, 5 insertions, 7 deletions
diff --git a/perllib/FixMyStreet/Cobrand/Default.pm b/perllib/FixMyStreet/Cobrand/Default.pm
index 6d9f38d78..ac70fff08 100644
--- a/perllib/FixMyStreet/Cobrand/Default.pm
+++ b/perllib/FixMyStreet/Cobrand/Default.pm
@@ -873,13 +873,11 @@ sub get_body_sender {
# look up via category
my $contact = $body->contacts->search( { category => $category } )->first;
- if ( $body->can_be_devolved ) {
- if ( $contact->send_method ) {
- return { method => $contact->send_method, config => $contact, contact => $contact };
- } else {
- return { method => $body->send_method, config => $body, contact => $contact };
- }
- } elsif ( $body->send_method ) {
+ if ( $body->can_be_devolved && $contact->send_method ) {
+ return { method => $contact->send_method, config => $contact, contact => $contact };
+ }
+
+ if ( $body->send_method ) {
return { method => $body->send_method, config => $body, contact => $contact };
}