| 1 | package SWISH::Prog::Aggregator::Mail; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use Data::Dump qw( dump ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | 1 | ▶ | use Search::Tools::XML; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use Mail::Box::Manager; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | 1 | ▶ | use base qw( SWISH::Prog::Aggregator ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||
| 11 | 1 | our $VERSION = '0.75'; | |||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||
| 13 | 1 | my $XMLer = Search::Tools::XML->new(); | |||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||
| 15 | =pod | ||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||
| 17 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||
| 19 | SWISH::Prog::Aggregator::Mail - crawl a mail box | ||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||
| 21 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||
| 23 | use SWISH::Prog::Aggregator::Mail; | ||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||
| 25 | my $aggregator = | ||||||||||||||||||||||||||||||||||||||||||
| 26 | SWISH::Prog::Aggregator::Mail->new( | ||||||||||||||||||||||||||||||||||||||||||
| 27 | indexer => SWISH::Prog::Indexer::Native->new() | ||||||||||||||||||||||||||||||||||||||||||
| 28 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||
| 30 | $aggregator->indexer->start; | ||||||||||||||||||||||||||||||||||||||||||
| 31 | $aggregator->crawl('path/to/my/maildir'); | ||||||||||||||||||||||||||||||||||||||||||
| 32 | $aggregator->indexer->finish; | ||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||
| 35 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||
| 37 | SWISH::Prog::Aggregator::Mail is a SWISH::Prog::Aggregator | ||||||||||||||||||||||||||||||||||||||||||
| 38 | subclass designed for providing full-text search for your email. | ||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||
| 40 | SWISH::Prog::Aggregator::Mail uses Mail::Box, available from CPAN. | ||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||
| 42 | =head1 METHODS | ||||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||
| 44 | Since SWISH::Prog::Aggregator::Mail inherits from SWISH::Prog::Aggregator, | ||||||||||||||||||||||||||||||||||||||||||
| 45 | read the SWISH::Prog::Aggregator docs first. | ||||||||||||||||||||||||||||||||||||||||||
| 46 | Any overridden methods are documented here. | ||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||
| 48 | =head2 init | ||||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||
| 50 | Adds the special C<mail> MetaName to the Config object before | ||||||||||||||||||||||||||||||||||||||||||
| 51 | opening indexer. | ||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||
| 53 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||
| 55 | 0 | ▶ | sub init { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
init: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 56 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 57 | 0 | $self->SUPER::init(@_); | |||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||
| 59 | # add top-level metaname | ||||||||||||||||||||||||||||||||||||||||||
| 60 | 0 | $self->config->MetaNameAlias('swishdefault mail'); | |||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||
| 62 | 0 | my @meta = qw( | |||||||||||||||||||||||||||||||||||||||||
| 63 | url | ||||||||||||||||||||||||||||||||||||||||||
| 64 | id | ||||||||||||||||||||||||||||||||||||||||||
| 65 | subject | ||||||||||||||||||||||||||||||||||||||||||
| 66 | date | ||||||||||||||||||||||||||||||||||||||||||
| 67 | size | ||||||||||||||||||||||||||||||||||||||||||
| 68 | from | ||||||||||||||||||||||||||||||||||||||||||
| 69 | to | ||||||||||||||||||||||||||||||||||||||||||
| 70 | cc | ||||||||||||||||||||||||||||||||||||||||||
| 71 | bcc | ||||||||||||||||||||||||||||||||||||||||||
| 72 | type | ||||||||||||||||||||||||||||||||||||||||||
| 73 | part | ||||||||||||||||||||||||||||||||||||||||||
| 74 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||
| 76 | 0 | $self->config->MetaNames(@meta); | |||||||||||||||||||||||||||||||||||||||||
| 77 | 0 | $self->config->PropertyNames(@meta); | |||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||
| 79 | # save all body text in the swishdescription property for excerpts | ||||||||||||||||||||||||||||||||||||||||||
| 80 | 0 | $self->config->StoreDescription('XML* <body>'); | |||||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||
| 84 | # basic flow: | ||||||||||||||||||||||||||||||||||||||||||
| 85 | # recurse through maildir, get all messages, | ||||||||||||||||||||||||||||||||||||||||||
| 86 | # convert each message to xml, create Doc object and call index() | ||||||||||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||||||||||
| 88 | =head2 crawl( I<path_to_maildir> ) | ||||||||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||||||
| 90 | Create index. | ||||||||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||||||
| 92 | Returns number of emails indexed. | ||||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||
| 94 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||||||||
| 96 | 0 | ▶ | sub crawl { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
crawl: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 97 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 98 | 0 | ▶ | my $maildir = shift or croak "maildir required"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 99 | 0 | my $manager = Mail::Box::Manager->new; | |||||||||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||||||||||
| 101 | 0 | $self->{count} = 0; | |||||||||||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||||||||||
| 103 | 0 | ▶ | my $folder = $manager->open( | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 104 | folderdir => $maildir, | ||||||||||||||||||||||||||||||||||||||||||
| 105 | folder => '=', | ||||||||||||||||||||||||||||||||||||||||||
| 106 | extract => 'ALWAYS' | ||||||||||||||||||||||||||||||||||||||||||
| 107 | ) or croak "can't open $maildir"; | ||||||||||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||||||||||
| 109 | 0 | $self->_process_folder($folder); | |||||||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | $folder->close( write => 'NEVER' ); | |||||||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||||||
| 113 | 0 | return $self->{count}; | |||||||||||||||||||||||||||||||||||||||||
| 114 | } | ||||||||||||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | ▶ | sub _addresses { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_addresses: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 117 | 0 | ▶ | return join( ', ', map { ref($_) ? $_->format : $_ } @_ ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 118 | } | ||||||||||||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||||||||||||
| 120 | 0 | ▶ | sub _process_folder { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_process_folder: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||
| 121 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 122 | 0 | ▶ | my $folder = shift or croak "folder required"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||||||||||
| 124 | 0 | my @subs = sort $folder->listSubFolders; | |||||||||||||||||||||||||||||||||||||||||
| 125 | 0 | my $indexer = $self->indexer; | |||||||||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | for my $sub (@subs) { | |||||||||||||||||||||||||||||||||||||||||
| 128 | 0 | my $subf = $folder->openSubFolder($sub); | |||||||||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||||||||||
| 130 | 0 | ▶ | warn "searching $sub\n" if $self->verbose; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||||||||||||
| 132 | 0 | foreach my $message ( $subf->messages ) { | |||||||||||||||||||||||||||||||||||||||||
| 133 | 0 | my $doc = $self->get_doc( $sub, $message ); | |||||||||||||||||||||||||||||||||||||||||
| 134 | 0 | $indexer->process($doc); | |||||||||||||||||||||||||||||||||||||||||
| 135 | 0 | $self->_increment_count; | |||||||||||||||||||||||||||||||||||||||||
| 136 | } | ||||||||||||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||||||||||||
| 138 | 0 | $self->_process_folder($subf); | |||||||||||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||||||||||||
| 140 | 0 | $subf->close( write => 'NEVER' ); | |||||||||||||||||||||||||||||||||||||||||
| 141 | } | ||||||||||||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||||||||||||
| 143 | } | ||||||||||||||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||||||||||||
| 145 | 0 | ▶ | sub _filter_attachment { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_filter_attachment: not called CC=7 SCAR=40.3
| |||||||||||||||||||||||||||||||||||||||||||
| 146 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 147 | 0 | ▶ | my $msg_url = shift or croak "message url required"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 148 | 0 | ▶ | my $attm = shift or croak "attachment object required"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||||||||||
| 150 | 0 | my $type = $attm->body->mimeType->type; | |||||||||||||||||||||||||||||||||||||||||
| 151 | 0 | my $filename = $attm->body->dispositionFilename; | |||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | my $content = $attm->decoded . ''; # force stringify | |||||||||||||||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | ▶ | if ( $self->swish_filter_obj->can_filter($type) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||||||||||||
| 156 | 0 | my $f = $self->swish_filter_obj->convert( | |||||||||||||||||||||||||||||||||||||||||
| 157 | document => \$content, | ||||||||||||||||||||||||||||||||||||||||||
| 158 | content_type => $type, | ||||||||||||||||||||||||||||||||||||||||||
| 159 | name => $filename, | ||||||||||||||||||||||||||||||||||||||||||
| 160 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||||||||||||||||
| 162 | 0 | ▶ | if ( !$f | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
not $f && $f->was_filtered or $f->is_binary
$f && $f->was_filtered
MC/DC0%0/3
not $f && $f->was_filtered or $f->is_binary
$f
$f->was_filtered
$f->is_binary
Truth table0%0/4
not(A && B) or C
A= $fB= $f->was_filteredC= $f->is_binary
| |||||||||||||||||||||||||||||||||||||||||||
| 163 | || !$f->was_filtered | ||||||||||||||||||||||||||||||||||||||||||
| 164 | || $f->is_binary ) # is is_binary necessary? | ||||||||||||||||||||||||||||||||||||||||||
| 165 | { | ||||||||||||||||||||||||||||||||||||||||||
| 166 | 0 | warn "skipping $filename in message $msg_url - filtering error\n"; | |||||||||||||||||||||||||||||||||||||||||
| 167 | 0 | return ''; | |||||||||||||||||||||||||||||||||||||||||
| 168 | } | ||||||||||||||||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||||||||||||||||
| 170 | 0 | $content = ${ $f->fetch_doc }; | |||||||||||||||||||||||||||||||||||||||||
| 171 | } | ||||||||||||||||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||||||||||||||||
| 173 | 0 | return join( '', | |||||||||||||||||||||||||||||||||||||||||
| 174 | '<title>', $XMLer->escape($filename), | ||||||||||||||||||||||||||||||||||||||||||
| 175 | '</title>', $XMLer->escape($content) ); | ||||||||||||||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||||||||||||
| 177 | } | ||||||||||||||||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||||||||||||||||
| 179 | =head2 get_doc( I<folder>, I<Mail::Message> ) | ||||||||||||||||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||||||||||||||||
| 181 | Extract data and content from I<Mail::Message> in I<folder> and return | ||||||||||||||||||||||||||||||||||||||||||
| 182 | doc_class() object. | ||||||||||||||||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||||||||||||||||
| 184 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||||||||||||||||
| 186 | 0 | ▶ | sub get_doc { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_doc: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 187 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 188 | 0 | ▶ | my $folder = shift or croak "folder required"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 189 | 0 | ▶ | my $message = shift or croak "mail meta required"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||||||||||||||||
| 191 | # >head->createFromLine; | ||||||||||||||||||||||||||||||||||||||||||
| 192 | 0 | ▶ | my %meta = ( | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$message->subject || '[ no subject ]'
MC/DC0%0/1
$message->subject || '[ no subject ]'
$message->subject
Truth table0%0/2
A
A= $message->subject
| |||||||||||||||||||||||||||||||||||||||||||
| 193 | url => join( '.', $folder, $message->messageId ), | ||||||||||||||||||||||||||||||||||||||||||
| 194 | id => $message->messageId, | ||||||||||||||||||||||||||||||||||||||||||
| 195 | subject => $message->subject || '[ no subject ]', | ||||||||||||||||||||||||||||||||||||||||||
| 196 | date => $message->timestamp, | ||||||||||||||||||||||||||||||||||||||||||
| 197 | size => $message->size, | ||||||||||||||||||||||||||||||||||||||||||
| 198 | from => _addresses( $message->from ), | ||||||||||||||||||||||||||||||||||||||||||
| 199 | to => _addresses( $message->to ), | ||||||||||||||||||||||||||||||||||||||||||
| 200 | cc => _addresses( $message->cc ), | ||||||||||||||||||||||||||||||||||||||||||
| 201 | bcc => _addresses( $message->bcc ), | ||||||||||||||||||||||||||||||||||||||||||
| 202 | type => $message->contentType, | ||||||||||||||||||||||||||||||||||||||||||
| 203 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||||||||||||||||
| 205 | 0 | my @parts = $message->parts; | |||||||||||||||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||||||||||||||||
| 207 | 0 | for my $part (@parts) { | |||||||||||||||||||||||||||||||||||||||||
| 208 | push( | ||||||||||||||||||||||||||||||||||||||||||
| 209 | 0 | @{ $meta{parts} }, | |||||||||||||||||||||||||||||||||||||||||
| 210 | 0 | $self->_filter_attachment( $meta{url}, $part ) | |||||||||||||||||||||||||||||||||||||||||
| 211 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 212 | } | ||||||||||||||||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||||||||||||||||
| 214 | 0 | my $title = $meta{subject}; | |||||||||||||||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||||||||||||||||
| 216 | 0 | my $xml = $self->_mail2xml( $title, \%meta ); | |||||||||||||||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||||||||||||||||
| 218 | my $doc = $self->doc_class->new( | ||||||||||||||||||||||||||||||||||||||||||
| 219 | content => $xml, | ||||||||||||||||||||||||||||||||||||||||||
| 220 | url => $meta{url}, | ||||||||||||||||||||||||||||||||||||||||||
| 221 | modtime => $meta{date}, | ||||||||||||||||||||||||||||||||||||||||||
| 222 | 0 | parser => 'XML*', | |||||||||||||||||||||||||||||||||||||||||
| 223 | type => 'application/xml', | ||||||||||||||||||||||||||||||||||||||||||
| 224 | data => \%meta | ||||||||||||||||||||||||||||||||||||||||||
| 225 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||||||||||||||||
| 227 | 0 | return $doc; | |||||||||||||||||||||||||||||||||||||||||
| 228 | } | ||||||||||||||||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||||||||||||||||
| 230 | 0 | ▶ | sub _mail2xml { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_mail2xml: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||
| 231 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 232 | 0 | my $title = shift; | |||||||||||||||||||||||||||||||||||||||||
| 233 | 0 | my $meta = shift; | |||||||||||||||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||||||||||||||||
| 235 | 0 | my $xml | |||||||||||||||||||||||||||||||||||||||||
| 236 | = "<mail>" | ||||||||||||||||||||||||||||||||||||||||||
| 237 | . "<swishtitle>" | ||||||||||||||||||||||||||||||||||||||||||
| 238 | . $XMLer->utf8_safe($title) | ||||||||||||||||||||||||||||||||||||||||||
| 239 | . "</swishtitle>" | ||||||||||||||||||||||||||||||||||||||||||
| 240 | . "<head>"; | ||||||||||||||||||||||||||||||||||||||||||
| 241 | |||||||||||||||||||||||||||||||||||||||||||
| 242 | 0 | for my $m ( sort keys %$meta ) { | |||||||||||||||||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||||||||||||||||
| 244 | 0 | ▶ | if ( $m eq 'parts' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||||||||||||||||
| 246 | 0 | $xml .= '<body>'; | |||||||||||||||||||||||||||||||||||||||||
| 247 | 0 | for my $part ( @{ $meta->{$m} } ) { | |||||||||||||||||||||||||||||||||||||||||
| 248 | 0 | $xml .= '<part>'; | |||||||||||||||||||||||||||||||||||||||||
| 249 | 0 | $xml .= $part; | |||||||||||||||||||||||||||||||||||||||||
| 250 | 0 | $xml .= '</part>'; | |||||||||||||||||||||||||||||||||||||||||
| 251 | } | ||||||||||||||||||||||||||||||||||||||||||
| 252 | 0 | $xml .= '</body>'; | |||||||||||||||||||||||||||||||||||||||||
| 253 | } | ||||||||||||||||||||||||||||||||||||||||||
| 254 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 255 | 0 | $xml .= $XMLer->start_tag($m); | |||||||||||||||||||||||||||||||||||||||||
| 256 | 0 | $xml .= $XMLer->escape( $meta->{$m} ); | |||||||||||||||||||||||||||||||||||||||||
| 257 | 0 | $xml .= $XMLer->end_tag($m); | |||||||||||||||||||||||||||||||||||||||||
| 258 | } | ||||||||||||||||||||||||||||||||||||||||||
| 259 | } | ||||||||||||||||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||||||||||||||||
| 261 | 0 | $xml .= "</head></mail>"; | |||||||||||||||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||||||||||||||||
| 263 | 0 | return $xml; | |||||||||||||||||||||||||||||||||||||||||
| 264 | } | ||||||||||||||||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||||||||||||||||
| 266 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 267 | |||||||||||||||||||||||||||||||||||||||||||
| 268 | __END__ | ||||||||||||||||||||||||||||||||||||||||||