changeset 7379:dbbb91f70719 HEAD

THREAD fixes: If sent date isn't usable, fallback to received date. If thread building would introduce loop, the message should not have a parent then.
author Timo Sirainen <tss@iki.fi>
date Sat, 08 Mar 2008 05:48:02 +0200
parents 1570eb502366
children dfd811aa0418
files src/imap/imap-thread.c
diffstat 1 files changed, 7 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/imap/imap-thread.c	Sat Mar 08 04:40:38 2008 +0200
+++ b/src/imap/imap-thread.c	Sat Mar 08 05:48:02 2008 +0200
@@ -392,14 +392,14 @@
 		return;
 	}
 
+	if (child->parent != NULL)
+		unlink_child(ctx, child, FALSE);
+
 	if (find_parent(parent, child)) {
 		/* this would create a loop, not allowed */
 		return;
 	}
 
-	if (child->parent != NULL)
-		unlink_child(ctx, child, FALSE);
-
 	/* link them */
 	child->parent = parent;
 
@@ -449,6 +449,10 @@
 
 	if (mail_get_date(mail, &sent_date, NULL) < 0)
 		sent_date = 0;
+	if (sent_date == 0) {
+		if (mail_get_received_date(mail, &sent_date) < 0)
+			sent_date = 0;
+	}
 
 	if (mail_get_first_header(mail, "message-id", &message_id) < 0)
 		message_id = NULL;