73 lines
1.6 KiB
Perl
73 lines
1.6 KiB
Perl
package WebGUI::Workflow::Activity::SendQueuedMailings;
|
|
|
|
use base 'WebGUI::Workflow::Activity';
|
|
|
|
#-------------------------------------------------------------------
|
|
|
|
=head2 definition ( session, definition )
|
|
|
|
See WebGUI::Workflow::Activity::definition() for details.
|
|
|
|
=cut
|
|
|
|
sub definition {
|
|
my $class = shift;
|
|
my $session = shift;
|
|
my $definition = shift;
|
|
|
|
push( @{ $definition }, {
|
|
name => 'Send queued newsletter mailings',
|
|
# properties => {
|
|
# someField => {
|
|
# fieldType=>"integer",
|
|
# label=>"Some Field",
|
|
# defaultValue=>0,
|
|
# hoverHelp=>"Hover help for some field."
|
|
# },
|
|
# }
|
|
} );
|
|
|
|
return $class->SUPER::definition( $session, $definition );
|
|
}
|
|
|
|
|
|
#-------------------------------------------------------------------
|
|
|
|
=head2 execute ( [ object ] )
|
|
|
|
See WebGUI::Workflow::Activity::execute() for details.
|
|
|
|
=cut
|
|
|
|
sub execute {
|
|
my $self = shift;
|
|
my $object = shift;
|
|
my $instance = shift;
|
|
my $session = $self->session;
|
|
|
|
my $maxTime = time + $self->getTTL;
|
|
|
|
# For now only process test mails.
|
|
my $it = WebGUI::Mailing::Email->getQueuedTestEmails( $session );
|
|
while ( my $email = $it->() ) {
|
|
return $self->WAITING(1) if time >= $maxTime;
|
|
|
|
$email->send;
|
|
}
|
|
|
|
my $it = WebGUI::Mailing::Email->getSendableEmails( $session );
|
|
while ( my $email = $it->() ) {
|
|
$session->log->warn( "processing" . $email->getId );
|
|
return $self->WAITING(1) if time >= $maxTime;
|
|
|
|
$email->send;
|
|
}
|
|
|
|
return $self->COMPLETE;
|
|
}
|
|
|
|
|
|
|
|
1;
|
|
|
|
#vim:ft=perl
|