use parent qw(PublicInbox::ExtSearch);
use PublicInbox::Search qw(xap_terms);
use PublicInbox::ContentHash qw(content_digest content_hash);
-use PublicInbox::MID qw(mids mids_in);
+use PublicInbox::MID qw(mids mids_for_index);
# get combined docid from over.num:
# (not generic Xapian, only works with our sharding scheme)
my ($eml) = @_;
my $dig = content_digest($eml);
my $chash = $dig->clone->digest;
- my $mids = mids_in($eml,
- qw(Message-ID X-Alt-Message-ID Resent-Message-ID));
+ my $mids = mids_for_index($eml);
unless (@$mids) {
$eml->{-lei_fake_mid} = $mids->[0] =
- PublicInbox::Import::digest2mid($dig, $eml);
+ PublicInbox::Import::digest2mid($dig, $eml, 0);
}
($chash, $mids);
}
my $xoids = xoids_for($self, $eml) // return;
$docids //= [];
@$docids = sort { $a <=> $b } values %$xoids;
- my @cur_kw = msg_keywords($self, $docids->[0]);
- join("\0", @$new_kw_sorted) eq join("\0", @cur_kw) ? 0 : 1;
+ my $cur_kw = msg_keywords($self, $docids->[0]);
+
+ # RFC 5550 sec 5.9 on the $Forwarded keyword states:
+ # "Once set, the flag SHOULD NOT be cleared"
+ if (exists($cur_kw->{forwarded}) &&
+ !grep(/\Aforwarded\z/, @$new_kw_sorted)) {
+ delete $cur_kw->{forwarded};
+ }
+ $cur_kw = join("\0", sort keys %$cur_kw);
+ join("\0", @$new_kw_sorted) eq $cur_kw ? 0 : 1;
}
sub all_terms {