if ($was_ghost) {
$doc_id = $smsg->doc_id;
- $self->link_message($smsg);
+ $self->link_message($smsg, $smsg->thread_id);
$doc->set_data($smsg->to_doc_data);
$db->replace_document($doc_id, $doc);
} else {
}
sub link_message {
- my ($self, $smsg) = @_;
+ my ($self, $smsg, $old_tid) = @_;
my $doc = $smsg->{doc};
my $mid = $smsg->mid;
my $mime = $smsg->mime;
# but we can never trust clients to do the right thing
my $ref = shift @refs;
$tid = $self->_resolve_mid_to_tid($ref);
+ $self->merge_threads($tid, $old_tid) if defined $old_tid;
# the rest of the refs should point to this tid:
foreach $ref (@refs) {
my ($git, $blob, $sizeref) = @_;
my $mime = eval {
my $str = $git->cat_file($blob, $sizeref);
+ # fixup bugs from import:
+ $$str =~ s/\A[\r\n]*From [^\r\n]*\r?\n//s;
Email::MIME->new($str);
};
$@ ? undef : $mime;