Add mailing send workflow activity.
This commit is contained in:
parent
80c1ce0b44
commit
aff6b5d5d0
1 changed files with 66 additions and 0 deletions
66
lib/WebGUI/Workflow/Activity/SendQueuedMailings.pm
Normal file
66
lib/WebGUI/Workflow/Activity/SendQueuedMailings.pm
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
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;
|
||||
}
|
||||
|
||||
return $self->COMPLETE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
1;
|
||||
|
||||
#vim:ft=perl
|
||||
Loading…
Add table
Add a link
Reference in a new issue