Documentation ¶
Index ¶
- Constants
- func AddDeletedSubscription(ctx context.Context, tx *ent.Tx, mboxName string, mboxID imap.MailboxID) error
- func AddMessageFlag(ctx context.Context, tx *ent.Tx, messageIDs []imap.InternalMessageID, ...) error
- func BumpMailboxUIDNext(ctx context.Context, tx *ent.Tx, mbox *ent.Mailbox, withCount ...int) error
- func ClearRecentFlag(ctx context.Context, tx *ent.Tx, mboxID imap.InternalMailboxID, ...) error
- func ClearRecentFlags(ctx context.Context, tx *ent.Tx, mboxID imap.InternalMailboxID) error
- func CreateAndAddMessageToMailbox(ctx context.Context, tx *ent.Tx, mboxID imap.InternalMailboxID, ...) (imap.UID, imap.FlagSet, error)
- func CreateMailbox(ctx context.Context, tx *ent.Tx, mboxID imap.MailboxID, name string, ...) (*ent.Mailbox, error)
- func CreateMailboxIfNotExists(ctx context.Context, tx *ent.Tx, mbox imap.Mailbox, delimiter string, ...) error
- func CreateMessages(ctx context.Context, tx *ent.Tx, reqs ...*CreateMessageReq) ([]*ent.Message, error)
- func DeleteDB(dir, userID string) error
- func DeleteDeferredDBFiles(dir string) error
- func DeleteMailboxWithRemoteID(ctx context.Context, tx *ent.Tx, mboxID imap.MailboxID) error
- func DeleteMessages(ctx context.Context, tx *ent.Tx, messageIDs ...imap.InternalMessageID) error
- func FilterMailboxContains(ctx context.Context, client *ent.Client, mboxID imap.InternalMailboxID, ...) ([]imap.InternalMessageID, error)
- func FilterMailboxContainsInternalID(ctx context.Context, client *ent.Client, mboxID imap.InternalMailboxID, ...) ([]imap.InternalMessageID, error)
- func GetAllMailboxes(ctx context.Context, client *ent.Client) ([]*ent.Mailbox, error)
- func GetAllMessagesIDsAsMap(ctx context.Context, client *ent.Client) (map[imap.InternalMessageID]struct{}, error)
- func GetDeferredDeleteDBPath(dir string) string
- func GetDeletedSubscriptionSet(ctx context.Context, client *ent.Client) (map[imap.MailboxID]*ent.DeletedSubscription, error)
- func GetHighestMessageID(ctx context.Context, client *ent.Client) (imap.InternalMessageID, error)
- func GetImportedMessageData(ctx context.Context, client *ent.Client, messageID imap.InternalMessageID) (*ent.Message, error)
- func GetMailboxAttributes(ctx context.Context, client *ent.Client, mboxID imap.InternalMailboxID) (imap.FlagSet, error)
- func GetMailboxByID(ctx context.Context, client *ent.Client, id imap.InternalMailboxID) (*ent.Mailbox, error)
- func GetMailboxByName(ctx context.Context, client *ent.Client, name string) (*ent.Mailbox, error)
- func GetMailboxByRemoteID(ctx context.Context, client *ent.Client, id imap.MailboxID) (*ent.Mailbox, error)
- func GetMailboxCount(ctx context.Context, client *ent.Client) (int, error)
- func GetMailboxFlags(ctx context.Context, client *ent.Client, mboxID imap.InternalMailboxID) (imap.FlagSet, error)
- func GetMailboxIDFromRemoteID(ctx context.Context, client *ent.Client, mboxID imap.MailboxID) (imap.InternalMailboxID, error)
- func GetMailboxIDWithRemoteID(ctx context.Context, client *ent.Client, mboxID imap.MailboxID) (imap.InternalMailboxID, error)
- func GetMailboxMessageCount(ctx context.Context, client *ent.Client, mboxID imap.InternalMailboxID) (int, error)
- func GetMailboxMessageCountAndUID(ctx context.Context, client *ent.Client, mboxID imap.InternalMailboxID) (int, imap.UID, error)
- func GetMailboxMessageIDPairs(ctx context.Context, client *ent.Client, mailboxID imap.InternalMailboxID) ([]ids.MessageIDPair, error)
- func GetMailboxName(ctx context.Context, client *ent.Client, mboxID imap.InternalMailboxID) (string, error)
- func GetMailboxNameWithRemoteID(ctx context.Context, client *ent.Client, mboxID imap.MailboxID) (string, error)
- func GetMailboxPermanentFlags(ctx context.Context, client *ent.Client, mboxID imap.InternalMailboxID) (imap.FlagSet, error)
- func GetMailboxRecentCount(ctx context.Context, client *ent.Client, mbox *ent.Mailbox) (int, error)
- func GetMailboxUID(ctx context.Context, client *ent.Client, mboxID imap.InternalMailboxID) (imap.UID, error)
- func GetMessage(ctx context.Context, client *ent.Client, messageID imap.InternalMessageID) (*ent.Message, error)
- func GetMessageDateAndSize(ctx context.Context, client *ent.Client, messageID imap.InternalMessageID) (*ent.Message, error)
- func GetMessageDeleted(ctx context.Context, client *ent.Client, mboxID imap.InternalMailboxID, ...) (map[imap.InternalMessageID]bool, error)
- func GetMessageFromRemoteIDWithDeletedFlag(ctx context.Context, client *ent.Client, id imap.MessageID) (*ent.Message, error)
- func GetMessageIDFromRemoteID(ctx context.Context, client *ent.Client, id imap.MessageID) (imap.InternalMessageID, error)
- func GetMessageIDsMarkedDeleted(ctx context.Context, client *ent.Client) ([]imap.InternalMessageID, error)
- func GetMessageMailboxIDs(ctx context.Context, client *ent.Client, messageID imap.InternalMessageID) ([]imap.InternalMailboxID, error)
- func GetMessageRemoteIDFromID(ctx context.Context, client *ent.Client, id imap.InternalMessageID) (imap.MessageID, error)
- func GetMessageWithIDWithDeletedFlag(ctx context.Context, client *ent.Client, id imap.InternalMessageID) (*ent.Message, error)
- func GetOrCreateMailbox(ctx context.Context, tx *ent.Tx, mbox imap.Mailbox, delimiter string, ...) (*ent.Mailbox, error)
- func HasMessageWithID(ctx context.Context, client *ent.Client, id imap.InternalMessageID) (bool, error)
- func HasMessageWithRemoteID(ctx context.Context, client *ent.Client, id imap.MessageID) (bool, error)
- func IsMessageInMailbox(ctx context.Context, client *ent.Client, mboxID imap.InternalMailboxID, ...) (bool, error)
- func MailboxExistsWithID(ctx context.Context, client *ent.Client, mboxID imap.InternalMailboxID) (bool, error)
- func MailboxExistsWithName(ctx context.Context, client *ent.Client, name string) (bool, error)
- func MailboxExistsWithRemoteID(ctx context.Context, client *ent.Client, mboxID imap.MailboxID) (bool, error)
- func MarkMessageAsDeleted(ctx context.Context, tx *ent.Tx, messageID imap.InternalMessageID) error
- func MarkMessageAsDeletedAndAssignRandomRemoteID(ctx context.Context, tx *ent.Tx, messageID imap.InternalMessageID) error
- func MarkMessageAsDeletedWithRemoteID(ctx context.Context, tx *ent.Tx, messageID imap.MessageID) error
- func MessageExistsWithRemoteID(ctx context.Context, client *ent.Client, messageID imap.MessageID) (bool, error)
- func NewFlagSet(msgUID *ent.UID, flags []*ent.MessageFlag) imap.FlagSet
- func ReadResult[T any](ctx context.Context, db *DB, fn func(context.Context, *ent.Client) (T, error)) (T, error)
- func RemoveDeletedSubscriptionWithName(ctx context.Context, tx *ent.Tx, mboxName string) (int, error)
- func RemoveMessageFlag(ctx context.Context, tx *ent.Tx, messageIDs []imap.InternalMessageID, ...) error
- func RemoveMessagesFromMailbox(ctx context.Context, tx *ent.Tx, messageIDs []imap.InternalMessageID, ...) error
- func RenameMailboxWithRemoteID(ctx context.Context, tx *ent.Tx, mboxID imap.MailboxID, name string) error
- func SetDeletedFlag(ctx context.Context, tx *ent.Tx, mboxID imap.InternalMailboxID, ...) error
- func SetMessageFlags(ctx context.Context, tx *ent.Tx, messageIDs []imap.InternalMessageID, ...) error
- func TranslateRemoteMailboxIDs(ctx context.Context, client *ent.Client, mboxIDs []imap.MailboxID) ([]imap.InternalMailboxID, error)
- func UpdateRemoteMailboxID(ctx context.Context, tx *ent.Tx, internalID imap.InternalMailboxID, ...) error
- func UpdateRemoteMessageID(ctx context.Context, tx *ent.Tx, internalID imap.InternalMessageID, ...) error
- func WriteResult[T any](ctx context.Context, db *DB, fn func(context.Context, *ent.Tx) (T, error)) (T, error)
- type CreateAndAddMessagesResult
- type CreateMessageReq
- type DB
- type MessageFlagSet
- type SnapshotMessageResult
- type UIDWithFlags
- func AddMessagesToMailbox(ctx context.Context, tx *ent.Tx, messageIDs []imap.InternalMessageID, ...) ([]UIDWithFlags, error)
- func BumpMailboxUIDsForMessage(ctx context.Context, tx *ent.Tx, messageIDs []imap.InternalMessageID, ...) ([]UIDWithFlags, error)
- func GetMessageUIDsWithFlagsAfterAddOrUIDBump(ctx context.Context, client *ent.Client, mboxID imap.InternalMailboxID, ...) ([]UIDWithFlags, error)
Constants ¶
const ChunkLimit = 1000
Variables ¶
This section is empty.
Functions ¶
func AddDeletedSubscription ¶ added in v0.15.0
func AddMessageFlag ¶
func BumpMailboxUIDNext ¶
func ClearRecentFlag ¶
func ClearRecentFlag(ctx context.Context, tx *ent.Tx, mboxID imap.InternalMailboxID, messageID imap.InternalMessageID) error
func ClearRecentFlags ¶
func CreateMailbox ¶
func CreateMessages ¶
func DeleteDB ¶
DeleteDB will rename all the database files for the given user to a directory within the same folder to avoid issues with ent not being able to close the database on demand. The database will be cleaned up on the next run on the Gluon server.
func DeleteDeferredDBFiles ¶ added in v0.16.0
DeleteDeferredDBFiles deletes all data from previous databases that were scheduled for removal.
func DeleteMailboxWithRemoteID ¶
DeleteMailboxWithRemoteID deletes the mailbox with the given remote ID. It returns the (potentially new) global UID validity.
func DeleteMessages ¶
func FilterMailboxContains ¶
func FilterMailboxContains(ctx context.Context, client *ent.Client, mboxID imap.InternalMailboxID, messageIDs []ids.MessageIDPair) ([]imap.InternalMessageID, error)
func FilterMailboxContainsInternalID ¶ added in v0.15.0
func FilterMailboxContainsInternalID(ctx context.Context, client *ent.Client, mboxID imap.InternalMailboxID, messageIDs []imap.InternalMessageID) ([]imap.InternalMessageID, error)
func GetAllMailboxes ¶
func GetAllMessagesIDsAsMap ¶
func GetDeferredDeleteDBPath ¶ added in v0.16.0
func GetDeletedSubscriptionSet ¶ added in v0.15.0
func GetHighestMessageID ¶
func GetImportedMessageData ¶ added in v0.14.0
func GetMailboxAttributes ¶ added in v0.15.0
func GetMailboxByID ¶
func GetMailboxByName ¶
func GetMailboxByRemoteID ¶
func GetMailboxCount ¶ added in v0.15.0
func GetMailboxFlags ¶ added in v0.15.0
func GetMailboxIDFromRemoteID ¶ added in v0.14.0
func GetMailboxMessageCount ¶ added in v0.14.0
func GetMailboxMessageCountAndUID ¶ added in v0.15.0
func GetMailboxMessageIDPairs ¶
func GetMailboxMessageIDPairs(ctx context.Context, client *ent.Client, mailboxID imap.InternalMailboxID) ([]ids.MessageIDPair, error)
func GetMailboxName ¶
func GetMailboxPermanentFlags ¶ added in v0.15.0
func GetMailboxRecentCount ¶
func GetMailboxUID ¶ added in v0.15.0
func GetMessage ¶
func GetMessageDateAndSize ¶
func GetMessageDeleted ¶
func GetMessageDeleted(ctx context.Context, client *ent.Client, mboxID imap.InternalMailboxID, messageIDs []imap.InternalMessageID) (map[imap.InternalMessageID]bool, error)
func GetMessageFromRemoteIDWithDeletedFlag ¶ added in v0.14.0
func GetMessageMailboxIDs ¶
func GetMessageMailboxIDs(ctx context.Context, client *ent.Client, messageID imap.InternalMessageID) ([]imap.InternalMailboxID, error)
func GetMessageRemoteIDFromID ¶ added in v0.14.0
func GetMessageWithIDWithDeletedFlag ¶ added in v0.14.0
func GetOrCreateMailbox ¶ added in v0.14.0
func HasMessageWithID ¶
func HasMessageWithRemoteID ¶
func IsMessageInMailbox ¶ added in v0.15.0
func IsMessageInMailbox(ctx context.Context, client *ent.Client, mboxID imap.InternalMailboxID, messageID imap.InternalMailboxID) (bool, error)
func MailboxExistsWithID ¶
func MailboxExistsWithName ¶
func MarkMessageAsDeleted ¶ added in v0.14.0
func MarkMessageAsDeletedAndAssignRandomRemoteID ¶ added in v0.16.0
func NewFlagSet ¶
func ReadResult ¶
func RemoveDeletedSubscriptionWithName ¶ added in v0.15.0
func RemoveMessageFlag ¶
func RemoveMessagesFromMailbox ¶
func RemoveMessagesFromMailbox(ctx context.Context, tx *ent.Tx, messageIDs []imap.InternalMessageID, mboxID imap.InternalMailboxID) error
func SetDeletedFlag ¶
func SetDeletedFlag(ctx context.Context, tx *ent.Tx, mboxID imap.InternalMailboxID, messageIDs []imap.InternalMessageID, deleted bool) error
func SetMessageFlags ¶
func UpdateRemoteMailboxID ¶
func UpdateRemoteMessageID ¶
Types ¶
type CreateMessageReq ¶
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
func NewDB ¶
NewDB creates a new database instance. If the database does not exist, it will be created and the second return value will be true.
type MessageFlagSet ¶
type MessageFlagSet struct { ID imap.InternalMessageID RemoteID imap.MessageID FlagSet imap.FlagSet }
func GetMessageFlags ¶
func GetMessageFlags(ctx context.Context, client *ent.Client, messageIDs []imap.InternalMessageID) ([]MessageFlagSet, error)
GetMessageFlags returns the flags of the given messages. It does not include per-mailbox flags (\Deleted, \Recent)!
type SnapshotMessageResult ¶
type SnapshotMessageResult struct { InternalID imap.InternalMessageID `json:"uid_message"` RemoteID imap.MessageID `json:"remote_id"` UID imap.UID `json:"uid"` Recent bool `json:"recent"` Deleted bool `json:"deleted"` Flags string `json:"flags"` }
func GetMailboxMessagesForNewSnapshot ¶
func GetMailboxMessagesForNewSnapshot(ctx context.Context, client *ent.Client, mboxID imap.InternalMailboxID) ([]SnapshotMessageResult, error)
func (*SnapshotMessageResult) GetFlagSet ¶
func (msg *SnapshotMessageResult) GetFlagSet() imap.FlagSet
type UIDWithFlags ¶
type UIDWithFlags struct { InternalID imap.InternalMessageID `json:"uid_message"` RemoteID imap.MessageID `json:"remote_id"` UID imap.UID `json:"uid"` Recent bool `json:"recent"` Deleted bool `json:"deleted"` Flags string `json:"flags"` }
func AddMessagesToMailbox ¶
func AddMessagesToMailbox(ctx context.Context, tx *ent.Tx, messageIDs []imap.InternalMessageID, mboxID imap.InternalMailboxID) ([]UIDWithFlags, error)
func BumpMailboxUIDsForMessage ¶
func BumpMailboxUIDsForMessage(ctx context.Context, tx *ent.Tx, messageIDs []imap.InternalMessageID, mboxID imap.InternalMailboxID) ([]UIDWithFlags, error)
func GetMessageUIDsWithFlagsAfterAddOrUIDBump ¶
func GetMessageUIDsWithFlagsAfterAddOrUIDBump(ctx context.Context, client *ent.Client, mboxID imap.InternalMailboxID, messageIDs []imap.InternalMessageID) ([]UIDWithFlags, error)
GetMessageUIDsWithFlagsAfterAddOrUIDBump exploits a property of adding a message to or bumping the UIDs of existing message in mailbox. It can only be used if you can guarantee that the messageID list contains only IDs that have recently added or bumped in the mailbox.
func (*UIDWithFlags) GetFlagSet ¶
func (u *UIDWithFlags) GetFlagSet() imap.FlagSet