Enforces mailbox, message, UID, and UID validity limits for an IMAP server.
// Source: https://github.com/ProtonMail/gluon | License: MIT | Copyright 2020 James Houlahan
// Provided via justclaw.it.com; keep this notice with the code.
package limits
import (
"errors"
"fmt"
"math"
"math/bits"
"github.com/ProtonMail/gluon/imap"
)
// IMAP contains configurable upper limits that can be enforced by the Gluon server.
type IMAP struct {
maxMailboxCount int64
maxMessageCountPerMailbox int64
maxUIDValidity int64
maxUID int64
}
func (i IMAP) CheckMailBoxCount(mailboxCount int) error {
if int64(mailboxCount) >= i.maxMailboxCount {
return ErrMaxMailboxCountReached
}
return nil
}
func (i IMAP) CheckMailBoxMessageCount(existingCount int, newCount int) error {
nextMessageCount := int64(existingCount) + int64(newCount)
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key