mirror of
https://git.notmuchmail.org/git/notmuch
synced 2025-01-03 07:11:41 +01:00
lib: calculate message depth in thread
This will be used in reparenting messages without useful in-reply-to, but with useful references
This commit is contained in:
parent
a330858284
commit
0a7181dd16
2 changed files with 29 additions and 0 deletions
|
@ -32,6 +32,7 @@ struct _notmuch_message {
|
|||
int frozen;
|
||||
char *message_id;
|
||||
char *thread_id;
|
||||
size_t thread_depth;
|
||||
char *in_reply_to;
|
||||
notmuch_string_list_t *tag_list;
|
||||
notmuch_string_list_t *filename_term_list;
|
||||
|
@ -118,6 +119,9 @@ _notmuch_message_create_for_document (const void *talloc_owner,
|
|||
/* the message is initially not synchronized with Xapian */
|
||||
message->last_view = 0;
|
||||
|
||||
/* Calculated after the thread structure is computed */
|
||||
message->thread_depth = 0;
|
||||
|
||||
/* Each of these will be lazily created as needed. */
|
||||
message->message_id = NULL;
|
||||
message->thread_id = NULL;
|
||||
|
@ -599,6 +603,25 @@ _notmuch_message_add_reply (notmuch_message_t *message,
|
|||
_notmuch_message_list_add_message (message->replies, reply);
|
||||
}
|
||||
|
||||
size_t
|
||||
_notmuch_message_get_thread_depth (notmuch_message_t *message) {
|
||||
return message->thread_depth;
|
||||
}
|
||||
|
||||
void
|
||||
_notmuch_message_label_depths (notmuch_message_t *message,
|
||||
size_t depth)
|
||||
{
|
||||
message->thread_depth = depth;
|
||||
|
||||
for (notmuch_messages_t *messages = _notmuch_messages_create (message->replies);
|
||||
notmuch_messages_valid (messages);
|
||||
notmuch_messages_move_to_next (messages)) {
|
||||
notmuch_message_t *child = notmuch_messages_get (messages);
|
||||
_notmuch_message_label_depths (child, depth+1);
|
||||
}
|
||||
}
|
||||
|
||||
const notmuch_string_list_t *
|
||||
_notmuch_message_get_references (notmuch_message_t *message)
|
||||
{
|
||||
|
|
|
@ -543,6 +543,12 @@ _notmuch_message_remove_unprefixed_terms (notmuch_message_t *message);
|
|||
const char *
|
||||
_notmuch_message_get_thread_id_only(notmuch_message_t *message);
|
||||
|
||||
size_t _notmuch_message_get_thread_depth (notmuch_message_t *message);
|
||||
|
||||
void
|
||||
_notmuch_message_label_depths (notmuch_message_t *message,
|
||||
size_t depth);
|
||||
|
||||
notmuch_message_list_t *
|
||||
_notmuch_message_sort_subtrees (void *ctx, notmuch_message_list_t *list);
|
||||
|
||||
|
|
Loading…
Reference in a new issue