imapsql

package
v0.28.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 17, 2026 License: GPL-3.0 Imports: 38 Imported by: 0

Documentation

Overview

Package imapsql implements SQL-based storage module using go-imap-sql library (github.com/foxcpp/go-imap-sql).

Interfaces implemented: - module.StorageBackend - module.PlainAuth - module.DeliveryTarget

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(_, instName string, _, inlineArgs []string) (module.Module, error)

Types

type ExtBlob

type ExtBlob struct {
	io.ReadCloser
}

func (ExtBlob) Sync

func (e ExtBlob) Sync() error

func (ExtBlob) Write

func (e ExtBlob) Write(p []byte) (n int, err error)

type ExtBlobStore

type ExtBlobStore struct {
	Base module.BlobStore
}

func (ExtBlobStore) Create

func (e ExtBlobStore) Create(key string, objSize int64) (imapsql.ExtStoreObj, error)

func (ExtBlobStore) Delete

func (e ExtBlobStore) Delete(keys []string) error

func (ExtBlobStore) Open

func (e ExtBlobStore) Open(key string) (imapsql.ExtStoreObj, error)

type Storage

type Storage struct {
	Back   *imapsql.Backend
	GORMDB *gorm.DB

	Log log.Logger

	// QuotaCache is the in-memory quota cache for fast per-user lookups.
	// Exported so the IMAP endpoint, admin API, and CLI can access it.
	QuotaCache *quota.Cache
	// contains filtered or unexported fields
}

func (*Storage) BlockUser added in v0.15.0

func (store *Storage) BlockUser(username, reason string) error

BlockUser adds a username to the blocklist, preventing re-registration.

func (*Storage) Close

func (store *Storage) Close() error

func (*Storage) CreateIMAPAcct

func (store *Storage) CreateIMAPAcct(accountName string) error

func (*Storage) CreateMessageLimit

func (store *Storage) CreateMessageLimit() *uint32

func (*Storage) DeleteAccount added in v0.15.0

func (store *Storage) DeleteAccount(username, reason string) error

DeleteAccount performs a full account removal: 1. Delete IMAP storage (account + mailboxes + messages) 2. Delete quota record from DB 3. Block the username from re-registration

func (*Storage) DeleteIMAPAcct

func (store *Storage) DeleteIMAPAcct(accountName string) error

func (*Storage) EnableUpdatePipe

func (store *Storage) EnableUpdatePipe(mode updatepipe.BackendMode) error

func (*Storage) GetAccountDate

func (store *Storage) GetAccountDate(username string) (created int64, err error)

func (*Storage) GetAllAccountInfo added in v0.15.0

func (store *Storage) GetAllAccountInfo() (map[string]module.AccountInfo, error)

func (*Storage) GetAllUsedStorage added in v0.15.0

func (store *Storage) GetAllUsedStorage() (map[string]int64, error)

GetAllUsedStorage returns per-user storage usage in a single query.

func (*Storage) GetDefaultQuota

func (store *Storage) GetDefaultQuota() int64

func (*Storage) GetGORMDB added in v0.14.1

func (store *Storage) GetGORMDB() *gorm.DB

GetGORMDB implements module.GORMProvider. It exposes the shared GORM database connection so other modules (e.g. target.remote for DNS cache) can add their tables to the same database.

func (*Storage) GetIMAPAcct

func (store *Storage) GetIMAPAcct(accountName string) (backend.User, error)

func (*Storage) GetOrCreateIMAPAcct

func (store *Storage) GetOrCreateIMAPAcct(username string) (backend.User, error)

func (*Storage) GetQuota

func (store *Storage) GetQuota(username string) (used, max int64, isDefault bool, err error)

func (*Storage) GetStat

func (store *Storage) GetStat() (totalStorage int64, accountsCount int, err error)

func (*Storage) I18NLevel

func (store *Storage) I18NLevel() int

func (*Storage) IMAPExtensions

func (store *Storage) IMAPExtensions() []string

func (*Storage) Init

func (store *Storage) Init(cfg *config.Map) error

func (*Storage) InstanceName

func (store *Storage) InstanceName() string

func (*Storage) IsBlocked added in v0.15.0

func (store *Storage) IsBlocked(username string) (bool, error)

IsBlocked checks if a username is in the blocklist.

func (*Storage) IsJitRegistrationEnabled added in v0.10.0

func (store *Storage) IsJitRegistrationEnabled() (bool, error)

func (*Storage) IsRegistrationOpen

func (store *Storage) IsRegistrationOpen() (bool, error)

func (*Storage) ListBlockedUsers added in v0.15.0

func (store *Storage) ListBlockedUsers() ([]module.BlockedUserEntry, error)

ListBlockedUsers returns all blocked usernames.

func (*Storage) ListIMAPAccts

func (store *Storage) ListIMAPAccts() ([]string, error)

func (*Storage) Login

func (store *Storage) Login(_ *imap.ConnInfo, usenrame, password string) (backend.User, error)

func (*Storage) Lookup

func (store *Storage) Lookup(ctx context.Context, key string) (string, bool, error)

func (*Storage) MigrateFirstLoginFromCreatedAt added in v0.12.0

func (store *Storage) MigrateFirstLoginFromCreatedAt() error

func (*Storage) Name

func (store *Storage) Name() string

func (*Storage) PruneMessages

func (store *Storage) PruneMessages(retention time.Duration) error

func (*Storage) PruneUnreadIMAPMsgs added in v0.12.4

func (store *Storage) PruneUnreadIMAPMsgs(retention time.Duration) error

func (*Storage) PruneUnusedAccounts added in v0.12.0

func (store *Storage) PruneUnusedAccounts(retention time.Duration) error

func (*Storage) PurgeAllIMAPMsgs added in v0.12.4

func (store *Storage) PurgeAllIMAPMsgs() error

func (*Storage) PurgeIMAPMsgs

func (store *Storage) PurgeIMAPMsgs(username string) error

func (*Storage) PurgeReadIMAPMsgs added in v0.12.4

func (store *Storage) PurgeReadIMAPMsgs() error

func (*Storage) ResetQuota

func (store *Storage) ResetQuota(username string) error

func (*Storage) SetDefaultQuota

func (store *Storage) SetDefaultQuota(max int64) error

func (*Storage) SetQuota

func (store *Storage) SetQuota(username string, max int64) error

func (*Storage) Start

func (store *Storage) Start(ctx context.Context, msgMeta *module.MsgMetadata, mailFrom string) (module.Delivery, error)

func (*Storage) SupportedThreadAlgorithms

func (store *Storage) SupportedThreadAlgorithms() []sortthread.ThreadAlgorithm

func (*Storage) UnblockUser added in v0.15.0

func (store *Storage) UnblockUser(username string) error

UnblockUser removes a username from the blocklist.

func (*Storage) UpdateFirstLogin added in v0.12.0

func (store *Storage) UpdateFirstLogin(username string) error

type WriteExtBlob

type WriteExtBlob struct {
	module.Blob
}

func (WriteExtBlob) Read

func (w WriteExtBlob) Read(p []byte) (n int, err error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL