]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/NetReader.pm
watch: IMAP: ignore \Deleted and \Draft messages
[public-inbox.git] / lib / PublicInbox / NetReader.pm
index 785211bff14ef136445f76e8901de2db7a86d2ce..d3094fc7137eeb6546f1596ff3fa7d7d669ca399 100644 (file)
@@ -10,11 +10,7 @@ use PublicInbox::Eml;
 
 our %IMAPflags2kw = map {; "\\\u$_" => $_ } qw(seen answered flagged draft);
 
-# TODO: trim this down, this is huge
-our @EXPORT = qw(uri_new uri_section
-               nn_new imap_uri nntp_uri
-               cfg_bool cfg_intvl imap_common_init nntp_common_init
-               );
+our @EXPORT = qw(uri_section imap_uri nntp_uri);
 
 # returns the git config section name, e.g [imap "imaps://user@example.com"]
 # without the mailbox, so we can share connections between different inboxes
@@ -94,15 +90,6 @@ sub mic_for { # mic = Mail::IMAPClient
        $mic;
 }
 
-sub uri_new {
-       my ($url) = @_;
-       require URI;
-
-       # URI::snews exists, URI::nntps does not, so use URI::snews
-       $url =~ s!\Anntps://!snews://!i;
-       URI->new($url);
-}
-
 # Net::NNTP doesn't support CAPABILITIES, yet
 sub try_starttls ($) {
        my ($host) = @_;
@@ -359,9 +346,16 @@ sub _imap_do_msg ($$$$$) {
        $$raw =~ s/\r\n/\n/sg;
        my $kw = [];
        for my $f (split(/ /, $flags)) {
-               my $k = $IMAPflags2kw{$f} // next; # TODO: X-Label?
-               push @$kw, $k;
+               if (my $k = $IMAPflags2kw{$f}) {
+                       push @$kw, $k;
+               } elsif ($f eq "\\Recent") { # not in JMAP
+               } elsif ($f eq "\\Deleted") { # not in JMAP
+                       return;
+               } elsif ($self->{verbose}) {
+                       warn "# unknown IMAP flag $f <$uri;uid=$uid>\n";
+               }
        }
+       @$kw = sort @$kw; # for all UI/UX purposes
        my ($eml_cb, @args) = @{$self->{eml_each}};
        $eml_cb->($uri, $uid, $kw, PublicInbox::Eml->new($raw), @args);
 }