-
Notifications
You must be signed in to change notification settings - Fork 102
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
implement imap quota extension (rfc 9208)
we only have a "storage" limit. for total disk usage. we don't have a limit on messages (count) or mailboxes (count). also not on total annotation size, but we don't have support annotations at all at the moment. we don't implement setquota. with rfc 9208 that's allowed. with the previous quota rfc 2087 it wasn't. the status command can now return "DELETED-STORAGE". which should be the disk space that can be reclaimed by removing messages with the \Deleted flags. however, it's not very likely clients set the \Deleted flag without expunging the message immediately. we don't want to go through all messages to calculate the sum of message sizes with the deleted flag. we also don't currently track that in MailboxCount. so we just respond with "0". not compliant, but let's wait until someone complains. when returning quota information, it is not possible to give the current usage when no limit is configured. clients implementing rfc 9208 should probably conclude from the presence of QUOTA=RES-* capabilities (only in rfc 9208, not in 2087) and the absence of those limits in quota responses (or the absence of an untagged quota response at all) that a resource type doesn't have a limit. thunderbird will claim there is no quota information when no limit was configured, so we can probably conclude that it implements rfc 2087, but not rfc 9208. we now also show the usage & limit on the account page. for issue #115 by pmarini
- Loading branch information
Showing
17 changed files
with
428 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package imapserver | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/mjl-/mox/imapclient" | ||
) | ||
|
||
func TestQuota1(t *testing.T) { | ||
tc := start(t) | ||
defer tc.close() | ||
|
||
tc.client.Login("[email protected]", password0) | ||
|
||
// We don't implement setquota. | ||
tc.transactf("bad", `setquota "" (STORAGE 123)`) | ||
|
||
tc.transactf("bad", "getquotaroot") // Missing param. | ||
tc.transactf("bad", "getquotaroot inbox bogus") // Too many params. | ||
|
||
tc.transactf("bad", "getquota") // Missing param. | ||
tc.transactf("bad", "getquota a b") // Too many params. | ||
|
||
// tc does not have a limit. | ||
tc.transactf("ok", "getquotaroot inbox") | ||
tc.xuntagged(imapclient.UntaggedQuotaroot([]string{""})) | ||
|
||
tc.transactf("no", "getquota bogusroot") | ||
tc.transactf("ok", `getquota ""`) | ||
tc.xuntagged() | ||
|
||
// Check that we get a DELETED-STORAGE status attribute with value 0, also if | ||
// messages are marked deleted. We don't go through the trouble. | ||
tc.transactf("ok", "status inbox (DELETED-STORAGE)") | ||
tc.xuntagged(imapclient.UntaggedStatus{Mailbox: "Inbox", Attrs: map[string]int64{"DELETED-STORAGE": 0}}) | ||
|
||
// tclimit does have a limit. | ||
tclimit := startArgs(t, false, false, true, true, "limit") | ||
defer tclimit.close() | ||
|
||
tclimit.client.Login("[email protected]", password0) | ||
|
||
tclimit.transactf("ok", "getquotaroot inbox") | ||
tclimit.xuntagged( | ||
imapclient.UntaggedQuotaroot([]string{""}), | ||
imapclient.UntaggedQuota{Root: "", Resources: []imapclient.QuotaResource{{Name: imapclient.QuotaResourceStorage, Usage: 0, Limit: 1}}}, | ||
) | ||
|
||
tclimit.transactf("ok", `getquota ""`) | ||
tclimit.xuntagged(imapclient.UntaggedQuota{Root: "", Resources: []imapclient.QuotaResource{{Name: imapclient.QuotaResourceStorage, Usage: 0, Limit: 1}}}) | ||
|
||
tclimit.transactf("ok", "status inbox (DELETED-STORAGE)") | ||
tclimit.xuntagged(imapclient.UntaggedStatus{Mailbox: "Inbox", Attrs: map[string]int64{"DELETED-STORAGE": 0}}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.