aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/SendReport/Email/SingleBodyOnly.pm
blob: 1ae938317d5d49ef2dc40f0da0fe79e9894cb744 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
package FixMyStreet::SendReport::Email::SingleBodyOnly;

use Moo;
extends 'FixMyStreet::SendReport::Email';

has contact => (
    is => 'ro',
    default => sub { die 'Need to override contact' }
);

sub build_recipient_list {
    my ( $self, $row, $h ) = @_;

    return unless @{$self->bodies} == 1;
    my $body = $self->bodies->[0];

    # We don't care what the category was, look up the relevant contact
    my $contact = $self->fetch_category($body, $row, $self->contact) or return;

    @{$self->to} = map { [ $_, $body->name ] } split /,/, $contact->email;
    return 1;
}

1;