]> Sergey Matveev's repositories - public-inbox.git/commitdiff
net_writer: use "FLAGS.SILENT" to set keywords
authorEric Wong <e@80x24.org>
Sun, 2 May 2021 06:05:41 +0000 (06:05 +0000)
committerEric Wong <e@80x24.org>
Mon, 3 May 2021 18:45:27 +0000 (18:45 +0000)
Instead of "+FLAGS.SILENT" which merely adds to the keywords.
We store all keywords together, so it's unlikely we will rely
on the "+FLAGS.SILENT" or "-FLAGS.SILENT".

lib/PublicInbox/NetWriter.pm
xt/net_writer-imap.t

index 49ac02a6eedd6fae23cf6d3a5fbb3c93d1096233..06d69f2787a6d218e78bfadfbaae8b1661bae158 100644 (file)
@@ -53,17 +53,15 @@ sub imap_delete_1 {
        $$delete_mic->delete_message($uid);
 }
 
-sub imap_set_kw {
-       my ($self, $url, $uid, $kw) = @_;
-       my $mic = mic_for_folder($self, my $uri = $url) or return;
-       $mic->set_flag(kw2flags($kw), $uid);
+sub imap_add_kw {
+       my ($self, $mic, $uid, $kw) = @_;
+       $mic->store($uid, '+FLAGS.SILENT', '('.kw2flags($kw).')');
        $mic; # caller must ->expunge
 }
 
-sub imap_unset_kw {
-       my ($self, $url, $uid, $kw) = @_;
-       my $mic = mic_for_folder($self, my $uri = $url) or return;
-       $mic->unset_flag(kw2flags($kw), $uid);
+sub imap_set_kw {
+       my ($self, $mic, $uid, $kw) = @_;
+       $mic->store($uid, 'FLAGS.SILENT', '('.kw2flags($kw).')');
        $mic; # caller must ->expunge
 }
 
index 007de35ea7155eb4e5ce87d4c6596b159ebd4db7..1298b958f683ba5d40404146e8162651736fc087 100644 (file)
@@ -157,8 +157,13 @@ test_lei(sub {
 
        lei_ok qw(import -F eml), $f, \'import local copy w/o keywords';
 
-       $nwr->imap_set_kw($folder_uri, $uid[0], [ 'seen' ])->expunge
-               or BAIL_OUT "expunge $@";
+       $mic = $nwr->mic_for_folder($folder_uri);
+       # dummy set to ensure second set_kw clobbers
+       $nwr->imap_set_kw($mic, $uid[0], [ qw(seen answered flagged) ]
+                       )->expunge or BAIL_OUT "expunge $@";
+       $nwr->imap_set_kw($mic, $uid[0], [ 'seen' ]
+                       )->expunge or BAIL_OUT "expunge $@";
+       $mic = undef;
        @res = ();
        $nwr->imap_each($folder_uri, $imap_slurp_all, \@res);
        is_deeply(\@res, [ [ ['seen'], $exp ] ], 'seen flag set') or