summaryrefslogtreecommitdiff
path: root/fml/lib/Mail/ThreadTrack/HeaderRewrite.pm
blob: 7d5afe9161621c700701d2cf912f09b8a634952c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#-*- perl -*-
#
#  Copyright (C) 2001 Ken'ichi Fukamachi
#   All rights reserved. This program is free software; you can
#   redistribute it and/or modify it under the same terms as Perl itself. 
#
# $FML: HeaderRewrite.pm,v 1.3 2001/11/03 01:22:14 fukachan Exp $
#

package Mail::ThreadTrack::HeaderRewrite;
use strict;
use vars qw(@ISA @EXPORT @EXPORT_OK $AUTOLOAD);
use Carp;

=head1 NAME

Mail::ThreadTrack::HeaderRewrite - what is this

=head1 SYNOPSIS

=head1 DESCRIPTION

=head1 METHODS

=cut

=head2 C<rewrite_header($msg)>

C<$msg> is Mail::Message object.

=cut


# Descriptions: 
#    Arguments: $self $args
# Side Effects: 
# Return Value: none
sub rewrite_header
{
    my ($self, $msg) = @_;
    my $header = $msg->rfc822_message_header;

    if (defined $self->{ _status_info }) {
	$header->add('X-Thread-Status', $self->{ _status_info });
    }

    if (defined $self->{ _thread_id }) {
	$header->add('X-Thread-ID', $self->{ _thread_id });
    }

    if (defined $self->{ _status_history }) {
	$header->add('X-Thread-History', $self->{ _status_history });
    }
}


# Descriptions: prepare header information
#    Arguments: $self $msg
# Side Effects: 
# Return Value: none
sub prepare_history_info
{
    my ($self, $msg) = @_;
    my $thread_id  = $self->get_thread_id();

    # prepare hash table tied to db_dir/*db's
    my $rh = $self->{ _hash_table };

    my $buf    = '';
    my (@aid)  = split(/\s+/, $rh->{ _articles  }->{ $thread_id });
    my $sender = $rh->{ _sender }->{ $aid[0] };
    my $when   = $rh->{ _date }->{ $aid[0] };

    # clean up
    $sender =~ s/[\s\n]*$//;
    $when   =~ s/[\s\n]*$//;

    use Mail::Message::Date;
    $when = Mail::Message::Date->new($when)->mail_header_style();
    
    $buf .= "\t\n";
    $buf .= "\tthis thread is opended at article $aid[0]\n";
    $buf .= "\tby $sender\n";
    $buf .= "\ton $when\n";
    $buf .= "\tarticle references: @aid\n";
    $self->{ _status_history } = $buf;
}


=head1 AUTHOR

Ken'ichi Fukamachi

=head1 COPYRIGHT

Copyright (C) 2001 Ken'ichi Fukamachi

All rights reserved. This program is free software; you can
redistribute it and/or modify it under the same terms as Perl itself. 

=head1 HISTORY

Mail::ThreadTrack::HeaderRewrite appeared in fml5 mailing list driver package.
See C<http://www.fml.org/> for more details.

=cut


1;