Q:Plugin.pm: abstracted out store_deferred_reject

This commit is contained in:
Matt Simerson 2013-03-27 18:16:43 -04:00
parent 498016828e
commit 5b74b9c1d3

View File

@ -225,13 +225,7 @@ sub get_reject {
# the naughty plugin will reject later # the naughty plugin will reject later
if ( $reject eq 'naughty' ) { if ( $reject eq 'naughty' ) {
$self->log(LOGINFO, "fail, NAUGHTY" . $log_mess); $self->log(LOGINFO, "fail, NAUGHTY" . $log_mess);
if ( ! $self->connection->notes('naughty') ) { return $self->store_deferred_reject( $smtp_mess );
$self->connection->notes('naughty', $smtp_mess);
};
if ( ! $self->connection->notes('naughty_reject_type') ) {
$self->connection->notes('naughty_reject_type', $self->{_args}{reject_type} );
}
return (DECLINED);
}; };
# they asked for reject, we give them reject # they asked for reject, we give them reject
@ -251,6 +245,24 @@ sub get_reject_type {
: $default; : $default;
}; };
sub store_deferred_reject {
my ($self, $smtp_mess) = @_;
# store the reject message that the naughty plugin will return later
if ( ! $self->connection->notes('naughty') ) {
$self->connection->notes('naughty', $smtp_mess);
}
else {
# append this reject message to the message
my $prev = $self->connection->notes('naughty');
$self->connection->notes('naughty', "$prev\015\012$smtp_mess");
};
if ( ! $self->connection->notes('naughty_reject_type') ) {
$self->connection->notes('naughty_reject_type', $self->{_args}{reject_type} );
}
return (DECLINED);
};
sub is_immune { sub is_immune {
my $self = shift; my $self = shift;