parent
507bdef5d3
commit
0e09c63201
@ -0,0 +1,78 @@
|
|||||||
|
diff --git a/Cassandane/Cyrus/Flags.pm b/Cassandane/Cyrus/Flags.pm
|
||||||
|
index a61d256..eedaf40 100644
|
||||||
|
--- a/Cassandane/Cyrus/Flags.pm
|
||||||
|
+++ b/Cassandane/Cyrus/Flags.pm
|
||||||
|
@@ -239,6 +239,73 @@ sub test_seen_otheruser
|
||||||
|
$self->check_messages(\%msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
+# https://github.com/cyrusimap/cyrus-imapd/issues/3240
|
||||||
|
+sub test_seen_sharedmb_nosharedseen
|
||||||
|
+ :UnixHierarchySep :AltNamespace
|
||||||
|
+{
|
||||||
|
+ my ($self) = @_;
|
||||||
|
+
|
||||||
|
+ my $folder = 'shared';
|
||||||
|
+
|
||||||
|
+ # shared mailbox with sharedseen=false
|
||||||
|
+ my $admintalk = $self->{adminstore}->get_client();
|
||||||
|
+ $admintalk->create($folder);
|
||||||
|
+ $self->assert_str_equals('ok', $admintalk->get_last_completion_response());
|
||||||
|
+ $admintalk->setacl('shared', 'cassandane' => 'lrswipkxtecdan');
|
||||||
|
+ $self->assert_str_equals('ok', $admintalk->get_last_completion_response());
|
||||||
|
+ $admintalk->setmetadata($folder,
|
||||||
|
+ '/shared/vendor/cmu/cyrus-imapd/sharedseen' => 'false'
|
||||||
|
+ );
|
||||||
|
+ $self->assert_str_equals('ok', $admintalk->get_last_completion_response());
|
||||||
|
+
|
||||||
|
+
|
||||||
|
+ # add some messages
|
||||||
|
+ my $talk = $self->{store}->get_client();
|
||||||
|
+ $self->{store}->set_folder("Shared Folders/$folder");
|
||||||
|
+ $self->{store}->_select();
|
||||||
|
+ $self->assert_num_equals(1, $talk->uid());
|
||||||
|
+ $self->{store}->set_fetch_attributes(qw(uid flags));
|
||||||
|
+
|
||||||
|
+ xlog $self, "Add two messages";
|
||||||
|
+ my %msg;
|
||||||
|
+ $msg{A} = $self->make_message('Message A');
|
||||||
|
+ $msg{A}->set_attributes(id => 1,
|
||||||
|
+ uid => 1,
|
||||||
|
+ flags => []);
|
||||||
|
+ $msg{B} = $self->make_message('Message B');
|
||||||
|
+ $msg{B}->set_attributes(id => 2,
|
||||||
|
+ uid => 2,
|
||||||
|
+ flags => []);
|
||||||
|
+ $self->check_messages(\%msg);
|
||||||
|
+
|
||||||
|
+ # fiddle with seen flag, making sure we get both the expected results
|
||||||
|
+ # and the expected untagged fetch response
|
||||||
|
+ xlog $self, "Set \\Seen on message A";
|
||||||
|
+ my $res = $talk->store('1', '+flags', '(\\Seen)');
|
||||||
|
+ $self->assert_deep_equals({ '1' => { 'flags' => [ '\\Seen' ] }}, $res);
|
||||||
|
+ $msg{A}->set_attribute(flags => ['\\Seen']);
|
||||||
|
+ $self->check_messages(\%msg);
|
||||||
|
+
|
||||||
|
+ xlog $self, "Clear \\Seen on message A";
|
||||||
|
+ $res = $talk->store('1', '-flags', '(\\Seen)');
|
||||||
|
+ $self->assert_deep_equals({ '1' => { 'flags' => [] }}, $res);
|
||||||
|
+ $msg{A}->set_attribute(flags => []);
|
||||||
|
+ $self->check_messages(\%msg);
|
||||||
|
+
|
||||||
|
+ xlog $self, "Set \\Seen on message A again";
|
||||||
|
+ $res = $talk->store('1', '+flags', '(\\Seen)');
|
||||||
|
+ $self->assert_deep_equals({ '1' => { 'flags' => [ '\\Seen' ] }}, $res);
|
||||||
|
+ $msg{A}->set_attribute(flags => ['\\Seen']);
|
||||||
|
+ $self->check_messages(\%msg);
|
||||||
|
+
|
||||||
|
+ # seen flag should survive a reconnect
|
||||||
|
+ xlog $self, "Reconnect, \\Seen should still be on message A";
|
||||||
|
+ $self->{store}->disconnect();
|
||||||
|
+ $self->{store}->connect();
|
||||||
|
+ $self->{store}->_select();
|
||||||
|
+ $self->check_messages(\%msg);
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
#
|
||||||
|
# Test that
|
||||||
|
# - the \Flagged flag can be set
|
@ -0,0 +1,60 @@
|
|||||||
|
From 6dc8b483b5045a94e72e631a8faee388713c3c05 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Bron Gondwana <brong@fastmail.fm>
|
||||||
|
Date: Wed, 21 Sep 2022 16:08:07 +1000
|
||||||
|
Subject: [PATCH] index: track changes for modseq bump when setting seen on
|
||||||
|
shared folders
|
||||||
|
|
||||||
|
---
|
||||||
|
imap/index.c | 15 +++++++++++++++
|
||||||
|
1 file changed, 15 insertions(+)
|
||||||
|
|
||||||
|
diff --git a/imap/index.c b/imap/index.c
|
||||||
|
index af06e94e6..5c96216ad 100644
|
||||||
|
--- a/imap/index.c
|
||||||
|
+++ b/imap/index.c
|
||||||
|
@@ -4778,6 +4778,7 @@ static int index_storeflag(struct index_state *state,
|
||||||
|
int dirty = 0;
|
||||||
|
modseq_t oldmodseq;
|
||||||
|
struct index_map *im = &state->map[msgno-1];
|
||||||
|
+ int seen_dirty = 0;
|
||||||
|
int r;
|
||||||
|
|
||||||
|
memset(modified_flags, 0, sizeof(struct index_modified_flags));
|
||||||
|
@@ -4803,6 +4804,7 @@ static int index_storeflag(struct index_state *state,
|
||||||
|
im->isseen = new;
|
||||||
|
state->seen_dirty = 1;
|
||||||
|
dirty++;
|
||||||
|
+ seen_dirty = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -4925,6 +4927,7 @@ static int index_storeflag(struct index_state *state,
|
||||||
|
else
|
||||||
|
system_flags &= ~FLAG_SEEN;
|
||||||
|
}
|
||||||
|
+
|
||||||
|
/* add back the internal tracking flags */
|
||||||
|
system_flags |= keep;
|
||||||
|
|
||||||
|
@@ -4942,6 +4945,18 @@ static int index_storeflag(struct index_state *state,
|
||||||
|
r = msgrecord_set_userflags(msgrec, user_flags);
|
||||||
|
if (r) return r;
|
||||||
|
|
||||||
|
+ // patch back in seen state for non-internal-seen
|
||||||
|
+ if (seen_dirty && !state->internalseen) {
|
||||||
|
+ if (im->isseen) {
|
||||||
|
+ modified_flags->added_system_flags |= FLAG_SEEN;
|
||||||
|
+ modified_flags->added_flags++;
|
||||||
|
+ }
|
||||||
|
+ else {
|
||||||
|
+ modified_flags->removed_system_flags |= FLAG_SEEN;
|
||||||
|
+ modified_flags->removed_flags++;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
/* if it's silent and unchanged, update the seen value, but
|
||||||
|
* not if qresync is enabled - RFC 4551 says that the MODSEQ
|
||||||
|
* must always been told, and we prefer just to tell flags
|
||||||
|
--
|
||||||
|
2.43.0
|
||||||
|
|
Loading…
Reference in new issue