mirror of
https://github.com/mjl-/mox.git
synced 2025-07-12 11:44:38 +03:00
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
This commit is contained in:
@ -1539,11 +1539,31 @@ func (Admin) Accounts(ctx context.Context) []string {
|
||||
}
|
||||
|
||||
// Account returns the parsed configuration of an account.
|
||||
func (Admin) Account(ctx context.Context, account string) map[string]any {
|
||||
ac, ok := mox.Conf.Account(account)
|
||||
if !ok {
|
||||
xcheckuserf(ctx, errors.New("no such account"), "looking up account")
|
||||
func (Admin) Account(ctx context.Context, account string) (accountConfig map[string]any, diskUsage int64) {
|
||||
log := pkglog.WithContext(ctx)
|
||||
|
||||
acc, err := store.OpenAccount(log, account)
|
||||
if err != nil && errors.Is(err, store.ErrAccountUnknown) {
|
||||
xcheckuserf(ctx, err, "looking up account")
|
||||
}
|
||||
xcheckf(ctx, err, "open account")
|
||||
defer func() {
|
||||
err := acc.Close()
|
||||
log.Check(err, "closing account")
|
||||
}()
|
||||
|
||||
var ac config.Account
|
||||
acc.WithRLock(func() {
|
||||
ac, _ = mox.Conf.Account(acc.Name)
|
||||
|
||||
err := acc.DB.Read(ctx, func(tx *bstore.Tx) error {
|
||||
du := store.DiskUsage{ID: 1}
|
||||
err := tx.Get(&du)
|
||||
diskUsage = du.MessageSize
|
||||
return err
|
||||
})
|
||||
xcheckf(ctx, err, "get disk usage")
|
||||
})
|
||||
|
||||
// todo: should change sherpa to understand config.Account directly, with its anonymous structs.
|
||||
buf, err := json.Marshal(ac)
|
||||
@ -1552,7 +1572,7 @@ func (Admin) Account(ctx context.Context, account string) map[string]any {
|
||||
err = json.Unmarshal(buf, &r)
|
||||
xcheckf(ctx, err, "unmarshal from json")
|
||||
|
||||
return r
|
||||
return r, diskUsage
|
||||
}
|
||||
|
||||
// ConfigFiles returns the paths and contents of the static and dynamic configuration files.
|
||||
|
Reference in New Issue
Block a user