about summary refs log tree commit homepage
path: root/lib/PublicInbox/V2Writable.pm
diff options
context:
space:
mode:
authorEric Wong (Contractor, The Linux Foundation) <e@80x24.org>2018-03-19 08:14:46 +0000
committerEric Wong (Contractor, The Linux Foundation) <e@80x24.org>2018-03-19 08:16:34 +0000
commit12c3eb5b2b0860292a32d5743ea0157996e9a4b9 (patch)
treee77046682726121988548e0ef968cf33233f3d6d /lib/PublicInbox/V2Writable.pm
parent1cc19f3f8ffe37e341e219884c6856210ba6fa52 (diff)
downloadpublic-inbox-12c3eb5b2b0860292a32d5743ea0157996e9a4b9.tar.gz
This allows us to share code for generating Message-IDs
between v1 and v2 repos.

For v1, this introduces a slight incompatibility in message
removal iff the original message lacked a Message-ID AND
the training request came from a message which did not
pass through the public-inbox:

The workaround for this would be to reuse the bad message from
the archive itself.
Diffstat (limited to 'lib/PublicInbox/V2Writable.pm')
-rw-r--r--lib/PublicInbox/V2Writable.pm6
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/PublicInbox/V2Writable.pm b/lib/PublicInbox/V2Writable.pm
index fbc71c89..a305842e 100644
--- a/lib/PublicInbox/V2Writable.pm
+++ b/lib/PublicInbox/V2Writable.pm
@@ -146,19 +146,19 @@ sub num_for_harder {
 
         my $hdr = $mime->header_obj;
         my $dig = content_digest($mime);
-        $$mid0 = $dig->clone->hexdigest . '@localhost';
+        $$mid0 = PublicInbox::Import::digest2mid($dig);
         my $num = $self->{skel}->{mm}->mid_insert($$mid0);
         unless (defined $num) {
                 # it's hard to spoof the last Received: header
                 my @recvd = $hdr->header_raw('Received');
                 $dig->add("Received: $_") foreach (@recvd);
-                $$mid0 = $dig->clone->hexdigest . '@localhost';
+                $$mid0 = PublicInbox::Import::digest2mid($dig);
                 $num = $self->{skel}->{mm}->mid_insert($$mid0);
 
                 # fall back to a random Message-ID and give up determinism:
                 until (defined($num)) {
                         $dig->add(rand);
-                        $$mid0 = $dig->clone->hexdigest . '@localhost';
+                        $$mid0 = PublicInbox::Import::digest2mid($dig);
                         warn "using random Message-ID <$$mid0> as fallback\n";
                         $num = $self->{skel}->{mm}->mid_insert($$mid0);
                 }