Cleanup when deleting or canceling.
This commit is contained in:
parent
40ba318fac
commit
2e27fd5c21
1 changed files with 29 additions and 1 deletions
|
|
@ -23,6 +23,8 @@ sub cancel {
|
||||||
sendDate => undef,
|
sendDate => undef,
|
||||||
} );
|
} );
|
||||||
|
|
||||||
|
$self->deleteQueuedEmails;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -66,6 +68,25 @@ sub crud_definition {
|
||||||
return $definition;
|
return $definition;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub delete {
|
||||||
|
my $self = shift;
|
||||||
|
|
||||||
|
$self->deleteQueuedEmails;
|
||||||
|
|
||||||
|
return $self->SUPER::delete;
|
||||||
|
}
|
||||||
|
|
||||||
|
sub deleteQueuedEmails {
|
||||||
|
my $self = shift;
|
||||||
|
|
||||||
|
my $it = $self->getQueuedEmailIterator;
|
||||||
|
while ( my $email = $it->() ) {
|
||||||
|
$email->delete;
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
sub getAsset {
|
sub getAsset {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my $session = $self->session;
|
my $session = $self->session;
|
||||||
|
|
@ -75,6 +96,13 @@ sub getAsset {
|
||||||
return $asset;
|
return $asset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub getQueuedEmailIterator {
|
||||||
|
my $self = shift;
|
||||||
|
my $session = $self->session;
|
||||||
|
|
||||||
|
return WebGUI::Mailing::Email->getQueued( $session, $self->getId );
|
||||||
|
}
|
||||||
|
|
||||||
sub getNextInSendQueue {
|
sub getNextInSendQueue {
|
||||||
my $class = shift;
|
my $class = shift;
|
||||||
my $session = shift;
|
my $session = shift;
|
||||||
|
|
@ -168,7 +196,7 @@ sub sendQueuedEmails {
|
||||||
|
|
||||||
$self->update( { state => 'sending' } );
|
$self->update( { state => 'sending' } );
|
||||||
|
|
||||||
my $it = WebGUI::Mailing::Email->getQueued( $session, $self->getId );
|
my $it = $self->getQueuedEmailIterator;
|
||||||
while ( my $email = $it->() ) {
|
while ( my $email = $it->() ) {
|
||||||
return if $timeLimit && time >= $timeLimit;
|
return if $timeLimit && time >= $timeLimit;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue