aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authordakkar <dakkar@thenautilus.net>2016-06-19 18:22:14 +0100
committerdakkar <dakkar@thenautilus.net>2016-06-19 18:22:14 +0100
commit1ea33ee05cc3f681be561c6a0b9f87846406c24a (patch)
treeabac91e193385901adccdd42c335c22210184ec2 /lib
parentAvoidDups role (diff)
downloadSietima-1ea33ee05cc3f681be561c6a0b9f87846406c24a.tar.gz
Sietima-1ea33ee05cc3f681be561c6a0b9f87846406c24a.tar.bz2
Sietima-1ea33ee05cc3f681be561c6a0b9f87846406c24a.zip
Debounce role
Diffstat (limited to 'lib')
-rw-r--r--lib/Sietima/Role/Debounce.pm22
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;