diff options
author | Jannis M. Hoffmann <jannis.hoffmann@rwth-aachen.de> | 2021-08-24 11:10:39 +0200 |
---|---|---|
committer | Jannis M. Hoffmann <jannis.hoffmann@rwth-aachen.de> | 2021-08-24 11:10:39 +0200 |
commit | 2388747fbf954de990862a6c01713d50823e8725 (patch) | |
tree | c3b3a7dc80f1d6a978d25e3048f7a6afb9fa08e0 /lib/JWebmail/Model/Driver/QMailAuthuser/Extract.pm | |
parent | bf5554febae6f299c716b5a9582c6bfd6980b728 (diff) |
overhauled testing
Diffstat (limited to 'lib/JWebmail/Model/Driver/QMailAuthuser/Extract.pm')
-rwxr-xr-x | lib/JWebmail/Model/Driver/QMailAuthuser/Extract.pm | 25 |
1 files changed, 11 insertions, 14 deletions
diff --git a/lib/JWebmail/Model/Driver/QMailAuthuser/Extract.pm b/lib/JWebmail/Model/Driver/QMailAuthuser/Extract.pm index 30ac4e9..5c31d58 100755 --- a/lib/JWebmail/Model/Driver/QMailAuthuser/Extract.pm +++ b/lib/JWebmail/Model/Driver/QMailAuthuser/Extract.pm @@ -1,3 +1,4 @@ +#!/usr/bin/env perl package JWebmail::Model::Driver::QMailAuthuser::Extract; use v5.18; @@ -8,16 +9,15 @@ use utf8; use POSIX (); use JSON::PP; use Carp; -use Encode v2.88 qw(decode); +use List::Util 'min'; +use Encode v2.88 'decode'; use open IO => ':encoding(UTF-8)', ':std'; no warnings 'experimental::smartmatch'; use Mail::Box::Manager; -use constant { - ROOT_MAILDIR => '.', -}; +use constant ROOT_MAILDIR => '.'; sub main { @@ -109,19 +109,18 @@ sub list { my $sref = _sort_mails($sortby); my @msgs = $f->messages; @msgs = sort { &$sref } @msgs; - @msgs = @msgs[$start..$end]; + @msgs = @msgs[$start..min($#msgs, $end)]; my @msgs2; for my $msg (@msgs) { my $msg2 = { - #subject => scalar decode_mimewords($msg->subject), subject => decode('MIME-Header', $msg->subject), from => _addresses($msg->from), to => _addresses($msg->to), cc => _addresses($msg->cc), bcc => _addresses($msg->bcc), - date => _iso8601_utc($msg->timestamp), + date_received => _iso8601_utc($msg->timestamp), size => $msg->size, content_type => ''. $msg->contentType, mid => $msg->messageId, @@ -175,7 +174,7 @@ sub read_mail { to => _addresses($msg->to), cc => _addresses($msg->cc), bcc => _addresses($msg->bcc), - date => _iso8601_utc($msg->timestamp), + date_received => _iso8601_utc($msg->timestamp), size => $msg->size, content_type => ''. $msg->contentType, body => do { @@ -191,9 +190,7 @@ sub read_mail { sub search { - my $f = shift; - my $search_pattern = shift; - my $folder = shift; + my ($f, $search_pattern, $folder) = @_; $folder = ".$folder"; $f = $f->openSubFolder($folder) if $folder ne ROOT_MAILDIR; @@ -214,7 +211,7 @@ sub search { to => _addresses($msg->to), cc => _addresses($msg->cc), bcc => _addresses($msg->bcc), - date => _iso8601_utc($msg->timestamp), + date_received => _iso8601_utc($msg->timestamp), size => $msg->size, content_type => ''. $msg->contentType, mid => $msg->messageId, @@ -229,7 +226,7 @@ sub search { sub folders { my $f = shift; - return [grep { $_ =~ m/^\./ && $_ =~ s/\.// && 1 } $f->listSubFolders]; + return [grep { $_ =~ m/^\./ && $_ =~ s/\.// } $f->listSubFolders]; } @@ -290,4 +287,4 @@ Currently Mail::Box::Manager does all the hard work. L<JWebmail::Model::Driver::QMailAuthuser> -=cut
\ No newline at end of file +=cut |