[Jifty-commit] r907 - in jifty/trunk: lib/Jifty

jifty-commit at lists.jifty.org jifty-commit at lists.jifty.org
Sun Apr 23 22:16:51 EDT 2006


Author: jesse
Date: Sun Apr 23 22:16:51 2006
New Revision: 907

Modified:
   jifty/trunk/   (props changed)
   jifty/trunk/lib/Jifty/Notification.pm

Log:
 r11820 at hualien:  jesse | 2006-04-23 22:15:51 -0400
 Jifty::Notification refactoring to not try to send mail to undef


Modified: jifty/trunk/lib/Jifty/Notification.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Notification.pm	(original)
+++ jifty/trunk/lib/Jifty/Notification.pm	Sun Apr 23 22:16:51 2006
@@ -80,28 +80,31 @@
 
 sub send_one_message {
     my $self = shift;
-    return unless my @recipients = $self->recipients;
-
+    my @recipients = $self->recipients;
+    my $to = join( ', ',
+      map { ( $_->can('email') ? $_->email : $_ ) } grep {$_} @recipients );
+     return unless ($to);
     my $message = Email::Simple->create(
-        header => [
-            From => $self->from || 'A Jifty Application <nobody>',
-            To   => join (', ', @recipients),
-            Subject => $self->subject || 'No subject',
-        ],
-        body => join ("\n", $self->preface, $self->body, $self->footer)
+      header => [
+        From => $self->from || 'A Jifty Application <nobody>',
+        To => $to,
+        Subject => $self->subject || 'No subject',
+      ],
+      body => join( "\n", $self->preface, $self->body, $self->footer )
     );
 
-    my $method = Jifty->config->framework('Mailer');
+    my $method   = Jifty->config->framework('Mailer');
     my $args_ref = Jifty->config->framework('MailerArgs');
     $args_ref = [] unless defined $args_ref;
 
-    my $sender = Email::Send->new({mailer => $method, mailer_args => $args_ref });
-    
+    my $sender
+      = Email::Send->new( { mailer => $method, mailer_args => $args_ref } );
+
     my $ret = $sender->send($message);
 
     unless ($ret) {
-        $self->log->error("Error sending mail: $ret");
-    } 
+      $self->log->error("Error sending mail: $ret");
+    }
 
     $ret;
 } 
@@ -186,17 +189,9 @@
 sub send {
     my $self = shift;
 
-    if ($self->to) {
-        if ($self->to->can('email')) {
-            $self->recipients($self->to->email);
-        } else {
-            $self->recipients($self->to);
-        }
-        $self->send_one_message(@_);
-    }
-    for my $to ($self->to_list) {
+    for my $to ($self->to, $self->to_list) {
         $self->to($to);
-        $self->recipients($to->email);
+        $self->recipients($to);
         $self->send_one_message(@_);
     }
 }


More information about the Jifty-commit mailing list