Fixes to support direct email specification in queued messages.

This commit is contained in:
Chris 2015-04-15 12:10:13 +01:00
parent 3481b61cd0
commit c214303007

View File

@ -21,6 +21,7 @@
#
package Webperl::Message::Transport::Email;
use utf8;
use strict;
use base qw(Webperl::Message::Transport);
use Encode;
@ -128,12 +129,26 @@ sub deliver {
# And the recipients
foreach my $recipient (@{$message -> {"recipients"}}) {
my $recip;
# Is the recipient identified by an ID number? If so, map to an email address
if($recipient -> {"recipient_id"}) {
# Skip users who shouldn't get emails
next if(!$force && !$self -> use_transport($recipient -> {"recipient_id"}));
my $recip = $self -> _get_user_email($recipient -> {"recipient_id"})
$recip = $self -> _get_user_email($recipient -> {"recipient_id"})
or return $self -> self_error("Recipient email lookup failed: ".$self -> errstr());
# Is an email address specified directly? Use it if so.
} elsif($recipient -> {"email"}) {
$recip = $recipient -> {"email"};
# This should never happen.
} else {
# IMPOSSIBRU!
return $self -> self_error("עזרה, אני נאלצת לעמול במכרות של קידוד");
}
$to .= "," if($to);
$to .= $recip;
}