diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Sietima/Role/Debounce.pm | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/lib/Sietima/Role/Debounce.pm b/lib/Sietima/Role/Debounce.pm new file mode 100644 index 0000000..490dfc8 --- /dev/null +++ b/lib/Sietima/Role/Debounce.pm @@ -0,0 +1,22 @@ +package Sietima::Role::Debounce; +use 5.020; +use Moo::Role; + +my $been_there = 'X-Been-There'; + +around munge_mail => sub { + my ($orig,$self,$incoming_mail) = @_; + + my $return_path = $self->return_path->address; + if (my $there = $incoming_mail->header_str($been_there)) { + return if $there =~ m{\b\Q$return_path\E\b}; + } + + $incoming_mail->header_str_set( + $been_there => $return_path, + ); + + return $self->$orig($incoming_mail); +}; + +1; |