unofficial mirror of meta@public-inbox.org
 help / color / mirror / Atom feed
From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Subject: [PATCH 5/6] net_writer: use "FLAGS.SILENT" to set keywords
Date: Sun,  2 May 2021 06:05:41 +0000	[thread overview]
Message-ID: <20210502060542.11598-6-e@80x24.org> (raw)
In-Reply-To: <20210502060542.11598-1-e@80x24.org>

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 | 14 ++++++--------
 xt/net_writer-imap.t         |  9 +++++++--
 2 files changed, 13 insertions(+), 10 deletions(-)

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

  parent reply	other threads:[~2021-05-02  6:05 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-02  6:05 [PATCH 0/6] lei: more steps towards kw sync Eric Wong
2021-05-02  6:05 ` [PATCH 1/6] lei <q|up>: combine written/results into one line Eric Wong
2021-05-02  6:05 ` [PATCH 2/6] lei_input: common net_merge_all_done for lei <import|tag> Eric Wong
2021-05-02  6:05 ` [PATCH 3/6] lei_input: reject --mail-sync if using HTTP(S) for now Eric Wong
2021-05-02  6:05 ` [PATCH 4/6] lei: simplify workers_start API Eric Wong
2021-05-02  6:05 ` Eric Wong [this message]
2021-05-02  6:05 ` [PATCH 6/6] lei <q|up>: writes to Maildirs and IMAP use mail-sync Eric Wong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://public-inbox.org/README

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210502060542.11598-6-e@80x24.org \
    --to=e@80x24.org \
    --cc=meta@public-inbox.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).