[Bps-public-commit] r18710 - in Net-IMAP-Server: lib/Net/IMAP/Server

alexmv at bestpractical.com alexmv at bestpractical.com
Thu Mar 5 14:35:23 EST 2009


Author: alexmv
Date: Thu Mar  5 14:35:23 2009
New Revision: 18710

Modified:
   Net-IMAP-Server/   (props changed)
   Net-IMAP-Server/lib/Net/IMAP/Server/Mailbox.pm

Log:
 r42872 at kohr-ah:  chmrr | 2009-03-05 14:23:45 -0500
  * Fix a major bug where UNSEEN reported the total number of unseen
    messages in the mailbox, rather than the sequence of the first
    unseen message.  Reported by Jan Dvorak <jdvorak at uikt.mendelu.cz>


Modified: Net-IMAP-Server/lib/Net/IMAP/Server/Mailbox.pm
==============================================================================
--- Net-IMAP-Server/lib/Net/IMAP/Server/Mailbox.pm	(original)
+++ Net-IMAP-Server/lib/Net/IMAP/Server/Mailbox.pm	Thu Mar  5 14:35:23 2009
@@ -464,13 +464,21 @@
 
 =head3 unseen
 
-Returns the number of messages which do not have the C<\Seen> flag set.
+Returns the sequence number of the first messages which does not have
+the C<\Seen> flag set.  Returns undef if all messages have been marked
+as C<\Seen>.
 
 =cut
 
 sub unseen {
     my $self = shift;
-    return scalar grep { not $_->has_flag('\Seen') } @{ $self->messages };
+    for ( @{ $self->messages } ) {
+        next if $_->has_flag('\Seen');
+        return Net::IMAP::Server->connection
+            ? Net::IMAP::Server->connection->sequence($_)
+            : $_->sequence;
+    }
+    return undef;
 }
 
 =head3 permanentflags



More information about the Bps-public-commit mailing list