From: Eric Wong Date: Sun, 2 May 2021 06:05:41 +0000 (+0000) Subject: net_writer: use "FLAGS.SILENT" to set keywords X-Git-Tag: v1.7.0~699 X-Git-Url: http://www.git.stargrave.org/?p=public-inbox.git;a=commitdiff_plain;h=91f60a476b2407d21d5f85e832164699d4e407ec net_writer: use "FLAGS.SILENT" to set keywords 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". --- diff --git a/lib/PublicInbox/NetWriter.pm b/lib/PublicInbox/NetWriter.pm index 49ac02a6..06d69f27 100644 --- a/lib/PublicInbox/NetWriter.pm +++ b/lib/PublicInbox/NetWriter.pm @@ -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 } diff --git a/xt/net_writer-imap.t b/xt/net_writer-imap.t index 007de35e..1298b958 100644 --- a/xt/net_writer-imap.t +++ b/xt/net_writer-imap.t @@ -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