user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
From: "Eric Wong (Contractor, The Linux Foundation)" <e@80x24.org>
To: meta@public-inbox.org
Cc: "Eric Wong (Contractor, The Linux Foundation)" <e@80x24.org>
Subject: [PATCH 02/14] v2writable: append, instead of prepending generated Message-ID
Date: Thu, 29 Mar 2018 10:28:07 +0000	[thread overview]
Message-ID: <20180329102819.15234-3-e@80x24.org> (raw)
In-Reply-To: <20180329102819.15234-1-e@80x24.org>

The original Message-ID is still the most important when
discussing with other recipients who do not rely on a message
flowing through public-inbox.  So whatever Message-ID we use
to deduplicate internally will be secondary and less important.

All of our front-end v2 code is order-independent, so we won't
let the message count against us, that way.
---
 lib/PublicInbox/Import.pm     | 8 ++++----
 lib/PublicInbox/V2Writable.pm | 2 +-
 t/psgi_v2.t                   | 9 +++++----
 t/v2writable.t                | 8 ++++----
 4 files changed, 14 insertions(+), 13 deletions(-)

diff --git a/lib/PublicInbox/Import.pm b/lib/PublicInbox/Import.pm
index 6824fac..e07edda 100644
--- a/lib/PublicInbox/Import.pm
+++ b/lib/PublicInbox/Import.pm
@@ -297,12 +297,12 @@ sub drop_unwanted_headers ($) {
 }
 
 # used by V2Writable, too
-sub prepend_mid ($$) {
+sub append_mid ($$) {
 	my ($hdr, $mid0) = @_;
 	# @cur is likely empty if we need to call this sub, but it could
 	# have random unparseable crap which we'll preserve, too.
-	my @cur = $hdr->header_raw('Message-Id');
-	$hdr->header_set('Message-Id', "<$mid0>", @cur);
+	my @cur = $hdr->header_raw('Message-ID');
+	$hdr->header_set('Message-ID', @cur, "<$mid0>");
 }
 
 sub v1_mid0 ($) {
@@ -312,7 +312,7 @@ sub v1_mid0 ($) {
 
 	if (!scalar(@$mids)) { # spam often has no Message-Id
 		my $mid0 = digest2mid(content_digest($mime));
-		prepend_mid($hdr, $mid0);
+		append_mid($hdr, $mid0);
 		return $mid0;
 	}
 	$mids->[0];
diff --git a/lib/PublicInbox/V2Writable.pm b/lib/PublicInbox/V2Writable.pm
index 01ec98a..9b280c6 100644
--- a/lib/PublicInbox/V2Writable.pm
+++ b/lib/PublicInbox/V2Writable.pm
@@ -173,7 +173,7 @@ sub num_for_harder {
 			$num = $self->{skel}->{mm}->mid_insert($$mid0);
 		}
 	}
-	PublicInbox::Import::prepend_mid($hdr, $$mid0);
+	PublicInbox::Import::append_mid($hdr, $$mid0);
 	$num;
 }
 
diff --git a/t/psgi_v2.t b/t/psgi_v2.t
index 9964b47..11b2c79 100644
--- a/t/psgi_v2.t
+++ b/t/psgi_v2.t
@@ -7,6 +7,7 @@ use File::Temp qw/tempdir/;
 use PublicInbox::MIME;
 use PublicInbox::Config;
 use PublicInbox::WWW;
+use PublicInbox::MID qw(mids);
 my @mods = qw(DBD::SQLite Search::Xapian HTTP::Request::Common Plack::Test
 		URI::Escape Plack::Builder);
 foreach my $mod (@mods) {
@@ -46,8 +47,8 @@ local $SIG{__WARN__} = sub { push @warn, @_ };
 $mime->header_set(Date => 'Fri, 02 Oct 1993 00:01:00 +0000');
 ok($im->add($mime), 'added duplicate-but-different message');
 is(scalar(@warn), 1, 'got one warning');
-my @mids = $mime->header_obj->header_raw('Message-Id');
-$new_mid = PublicInbox::MID::mid_clean($mids[0]);
+my $mids = mids($mime->header_obj);
+$new_mid = $mids->[1];
 $im->done;
 
 my $cfgpfx = "publicinbox.v2test";
@@ -93,8 +94,8 @@ is(scalar(@warn), 2, 'got another warning');
 like($warn[0], qr/mismatched/, 'warned about mismatched messages');
 is($warn[0], $warn[1], 'both warnings are the same');
 
-@mids = $mime->header_obj->header_raw('Message-Id');
-my $third = PublicInbox::MID::mid_clean($mids[0]);
+$mids = mids($mime->header_obj);
+my $third = $mids->[-1];
 $im->done;
 
 test_psgi(sub { $www->call(@_) }, sub {
diff --git a/t/v2writable.t b/t/v2writable.t
index 6cabf0d..c48f060 100644
--- a/t/v2writable.t
+++ b/t/v2writable.t
@@ -79,8 +79,8 @@ if ('ensure git configs are correct') {
 	ok($im->add($mime), 'reused mid ok');
 	like(join(' ', @warn), qr/reused/, 'warned about reused MID');
 	my @mids = $mime->header_obj->header_raw('Message-Id');
-	is($mids[1], '<a-mid@b>', 'original mid not changed');
-	like($mids[0], $sane_mid, 'new MID added');
+	is($mids[0], '<a-mid@b>', 'original mid not changed');
+	like($mids[1], $sane_mid, 'new MID added');
 	is(scalar(@mids), 2, 'only one new MID added');
 
 	@warn = ();
@@ -95,8 +95,8 @@ if ('ensure git configs are correct') {
 	ok($im->add($mime), 'random MID made');
 	like(join(' ', @warn), qr/using random/, 'warned about using random');
 	@mids = $mime->header_obj->header_raw('Message-Id');
-	is($mids[1], '<a-mid@b>', 'original mid not changed');
-	like($mids[0], $sane_mid, 'new MID added');
+	is($mids[0], '<a-mid@b>', 'original mid not changed');
+	like($mids[1], $sane_mid, 'new MID added');
 	is(scalar(@mids), 2, 'only one new MID added');
 
 	@warn = ();
-- 
EW


  parent reply	other threads:[~2018-03-29 10:28 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-29 10:28 [PATCH 00/14] purging support, v1 conversions, cleanups + more Eric Wong (Contractor, The Linux Foundation)
2018-03-29 10:28 ` [PATCH 01/14] www: remove unnecessary ghost checks Eric Wong (Contractor, The Linux Foundation)
2018-03-29 10:28 ` Eric Wong (Contractor, The Linux Foundation) [this message]
2018-03-29 10:28 ` [PATCH 03/14] lookup by Message-ID favors the "primary" one Eric Wong (Contractor, The Linux Foundation)
2018-03-29 10:28 ` [PATCH 04/14] www: fix attachment downloads for conflicted Message-IDs Eric Wong (Contractor, The Linux Foundation)
2018-03-29 10:28 ` [PATCH 05/14] searchmsg: document why we store To: and Cc: for NNTP Eric Wong (Contractor, The Linux Foundation)
2018-03-29 10:28 ` [PATCH 06/14] public-inbox-convert: tool for converting old to new inboxes Eric Wong (Contractor, The Linux Foundation)
2018-03-29 10:28 ` [PATCH 07/14] v2writable: support purging messages from git entirely Eric Wong (Contractor, The Linux Foundation)
2018-03-29 10:28 ` [PATCH 08/14] search: cleanup uniqueness checking Eric Wong (Contractor, The Linux Foundation)
2018-03-29 10:28 ` [PATCH 09/14] search: get rid of most lookup_* subroutines Eric Wong (Contractor, The Linux Foundation)
2018-03-29 10:28 ` [PATCH 10/14] search: move find_doc_ids to searchidx Eric Wong (Contractor, The Linux Foundation)
2018-03-29 10:28 ` [PATCH 11/14] v2writable: cleanup: get rid of unused fields Eric Wong (Contractor, The Linux Foundation)
2018-03-29 10:28 ` [PATCH 12/14] mbox: avoid extracting Message-ID for linkification Eric Wong (Contractor, The Linux Foundation)
2018-03-29 10:28 ` [PATCH 13/14] www: cleanup expensive fallback for legacy URLs Eric Wong (Contractor, The Linux Foundation)
2018-03-29 10:28 ` [PATCH 14/14] view: get rid of some unnecessary imports Eric Wong (Contractor, The Linux Foundation)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://public-inbox.org/README

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180329102819.15234-3-e@80x24.org \
    --to=e@80x24.org \
    --cc=meta@public-inbox.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/public-inbox.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).