| Mail::Box::Thread::Node(3pm) | User Contributed Perl Documentation | Mail::Box::Thread::Node(3pm) |
Mail::Box::Thread::Node - one node in a message thread
Mail::Box::Thread::Node is a Mail::Reporter
my $node = Mail::Box::Thread::Node->new; $node->addMessage($message); ...
The "Mail::Box::Thread::Node" maintains one node in the linked list of threads. Each node contains one message, and a list of its follow-ups. Next to that, it refers to its own ancestor and contains information about the trustworthiness of that relationship.
To complicate things a little, because the thread-manager can maintain multiple folders, and merge there content, you may find the same message in more folders. All versions of the same message (based on message-id) are stored in the same node.
Extends "DESCRIPTION" in Mail::Reporter.
Extends "METHODS" in Mail::Reporter.
Extends "Constructors" in Mail::Reporter.
-Option --Defined in --Default
dummy_type undef
log Mail::Reporter 'WARNINGS'
message undef
messageId undef
trace Mail::Reporter 'WARNINGS'
In scalar context, this method returns the first instance of the message that is not deleted. If all instances are flagged for deletion, then you get the first deleted message. When the open folders only contain references to the message, but no instance, you get a dummy message (see Mail::Message::Dummy).
In list context, all instances of the message which have been found are returned.
example:
my $threads = $mgr->threads(folders => [$draft, $sent]);
my $node = $draft->message(1)->thread;
foreach my $instance ($node->message) {
print "Found in ", $instance->folder, ".\n";
}
print "Subject is ", $node->message->subject, ".\n";
Defining the same relation more than once will not cause information to be duplicated.
The relation may be specified more than once, but only the most confident relation is used. For example, if a reply ($quality equals "REPLY") is specified, later calls to the follow method will have no effect. If "follows" is called with a $quality that matches the current quality, the new thread overrides the previous.
If the message seems to be the first message of a thread, the value "undef" is returned. (Remember that some MUA are not adding reference information to the message's header, so you can never be sure a message is the start of a thread)
In list context, this method returns a second string value indicating the confidence that the messages are related. When extended thread discovery is enabled, then some heuristics are applied to determine if messages are related. Values for the STRING may be:
This relation was directly derived from an `in-reply-to' message header field. The relation has a high confidence.
This relation is based on information found in a `Reference' message header field. One message may reference a list of messages which precede it in the thread. The heuristic attempts to determine relationships between messages assuming that the references are in order. This relation has a lower confidence.
The relation is a big guess, with low confidence. It may be based on a subject which seems to be related, or commonalities in the message's body.
More constants may be added later.
example:
my $question = $answer->repliedTo;
my ($question, $quality) = $answer->repliedTo;
if($question && $quality eq 'REPLY') { ... };
Some convenience methods are added to threads, to simplify retrieving information from it.
example:
$newfolder->addMessages($folder->ids($thread->ids));
$folder->delete($thread->ids);
example:
my @t = $folder->message(3)
->threadStart
->threadMessages;
The optional CODE argument is a reference to a routine which will be called for each message in the thread. The routine will be called with the message as the first argument. The default shows the subject of the message. In the first example below, this routine is called seven times.
example:
print $node->threadToString;
may result in
Subject of this message
|- Re: Subject of this message
|-*- Re: Re: Subject of this message
| |- Re(2) Subject of this message
| |- [3] Re(2) Subject of this message
| `- Re: Subject of this message (reply)
`- Re: Subject of this message
The `*' represents a missing message (a "dummy" message). The `[3]' presents a folded thread with three messages.
print $node->threadToString(\&show);
sub show($) {
my $message = shift;
my $subject = $message->head->get('subject');
length $subject ? $subject : '<no subject>';
}
Extends "Error handling" in Mail::Reporter.
Extends "Cleanup" in Mail::Reporter.
This module is part of Mail-Box distribution version 3.010, built on July 18, 2023. Website: http://perl.overmeer.net/CPAN/
Copyrights 2001-2023 by [Mark Overmeer]. For other contributors see ChangeLog.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See http://dev.perl.org/licenses/
| 2023-12-11 | perl v5.36.0 |