diff options
author | Eric Wong (Contractor, The Linux Foundation) <e@80x24.org> | 2018-03-19 08:14:45 +0000 |
---|---|---|
committer | Eric Wong (Contractor, The Linux Foundation) <e@80x24.org> | 2018-03-19 08:16:34 +0000 |
commit | 1cc19f3f8ffe37e341e219884c6856210ba6fa52 (patch) | |
tree | 5675ac096e978525baabdc1f3125954bcd4f1d3d /lib/PublicInbox/WatchMaildir.pm | |
parent | 23e03ed7126302e00e6a5ccb0f6f5fed61e58c96 (diff) | |
download | public-inbox-1cc19f3f8ffe37e341e219884c6856210ba6fa52.tar.gz |
This can probably be moved to Import for code reuse.
Diffstat (limited to 'lib/PublicInbox/WatchMaildir.pm')
-rw-r--r-- | lib/PublicInbox/WatchMaildir.pm | 25 |
1 files changed, 8 insertions, 17 deletions
diff --git a/lib/PublicInbox/WatchMaildir.pm b/lib/PublicInbox/WatchMaildir.pm index c72d9396..f2d3db95 100644 --- a/lib/PublicInbox/WatchMaildir.pm +++ b/lib/PublicInbox/WatchMaildir.pm @@ -12,6 +12,8 @@ use PublicInbox::Import; use PublicInbox::MDA; use PublicInbox::Spawn qw(spawn); use File::Temp qw//; +use PublicInbox::MID qw(mids); +use PublicInbox::ContentId qw(content_digest); sub new { my ($class, $config) = @_; @@ -144,25 +146,14 @@ sub _remove_spam { }) } -# used to hash the relevant portions of a message when there are conflicts -sub _hash_mime2 { - my ($mime) = @_; - require Digest::SHA; - my $dig = Digest::SHA->new('SHA-1'); - $dig->add($mime->header_obj->header_raw('Subject')); - $dig->add($mime->body_raw); - $dig->hexdigest; -} - sub _force_mid { my ($mime) = @_; - # probably a bad idea, but we inject a Message-Id if - # one is missing, here.. - my $mid = $mime->header_obj->header_raw('Message-Id'); - if (!defined $mid || $mid =~ /\A\s*\z/) { - $mid = '<' . _hash_mime2($mime) . '@generated>'; - $mime->header_set('Message-Id', $mid); - } + my $hdr = $mime->header_obj; + my $mids = mids($hdr); + return if @$mids; + my $dig = content_digest($mime); + my $mid = $dig->clone->hexdigest . '@localhost'; + $hdr->header_set('Message-Id', $mid); } sub _try_path { |