imapserver: implement UIDONLY extension, RFC 9586

Once clients enable this extension, commands can no longer refer to "message
sequence numbers" (MSNs), but can only refer to messages with UIDs. This means
both sides no longer have to carefully keep their sequence numbers in sync
(error-prone), and don't have to keep track of a mapping of sequence numbers to
UIDs (saves resources).

With UIDONLY enabled, all FETCH responses are replaced with UIDFETCH response.
This commit is contained in:
Mechiel Lukkien
2025-04-11 11:45:49 +02:00
parent 8bab38eac4
commit 507ca73b96
41 changed files with 2405 additions and 1545 deletions

View File

@ -2,13 +2,19 @@ package imapserver
import (
"testing"
"github.com/mjl-/mox/imapclient"
)
func TestUnsubscribe(t *testing.T) {
tc := start(t)
tc := start(t, false)
defer tc.close()
tc.client.Login("mjl@mox.example", password0)
tc.login("mjl@mox.example", password0)
tc2 := startNoSwitchboard(t, false)
defer tc2.closeNoWait()
tc2.login("mjl@mox.example", password0)
tc.transactf("bad", "unsubscribe") // Missing param.
tc.transactf("bad", "unsubscribe ") // Missing param.
@ -17,9 +23,16 @@ func TestUnsubscribe(t *testing.T) {
tc.transactf("no", "unsubscribe a/b") // Does not exist and is not subscribed.
tc.transactf("ok", "unsubscribe expungebox") // Does not exist anymore but is still subscribed.
tc.transactf("no", "unsubscribe expungebox") // Not subscribed.
tc2.transactf("ok", "noop")
tc2.xuntagged(imapclient.UntaggedList{Flags: []string{`\NonExistent`}, Separator: '/', Mailbox: "expungebox"})
tc.transactf("ok", "create a/b")
tc2.transactf("ok", "noop")
tc.transactf("ok", "unsubscribe a/b")
tc.transactf("ok", "unsubscribe a/b") // Can unsubscribe even if there is no subscription.
tc2.transactf("ok", "noop")
tc2.xuntagged(imapclient.UntaggedList{Flags: []string(nil), Separator: '/', Mailbox: "a/b"})
tc.transactf("ok", "subscribe a/b")
tc.transactf("ok", "unsubscribe a/b")
}