2021-07-18 23:03:28 +01:00
|
|
|
/*
|
2026-02-14 02:34:09 +05:00
|
|
|
* (Original Copyright (c) 2021 Neil Alexander)
|
2021-07-18 23:03:28 +01:00
|
|
|
*
|
2026-02-14 02:34:09 +05:00
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
2021-07-18 23:03:28 +01:00
|
|
|
*/
|
|
|
|
|
|
2021-07-07 18:15:07 +01:00
|
|
|
package storage
|
|
|
|
|
|
2026-02-14 02:34:09 +05:00
|
|
|
import (
|
|
|
|
|
"io"
|
|
|
|
|
|
|
|
|
|
"github.com/neilalexander/yggmail/internal/storage/types"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
type BlobStore interface {
|
|
|
|
|
StoreMail(aPk string, mailbox string, reader io.Reader) (string, int64, error)
|
|
|
|
|
ReadMail(location string) (io.ReadCloser, error)
|
|
|
|
|
DeleteMail(location string) error
|
|
|
|
|
MoveMail(oldLocation string, newMailbox string) (string, error)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type MailStore interface {
|
|
|
|
|
Storage
|
|
|
|
|
MailCreateRaw(pk string, mailbox string, data io.Reader, location string, size int64) (int, error)
|
|
|
|
|
}
|
2021-07-07 18:15:07 +01:00
|
|
|
|
|
|
|
|
type Storage interface {
|
|
|
|
|
ConfigGet(key string) (string, error)
|
|
|
|
|
ConfigSet(key, value string) error
|
2021-07-09 00:08:26 +01:00
|
|
|
ConfigSetPassword(password string) error
|
|
|
|
|
ConfigTryPassword(password string) (bool, error)
|
2021-07-07 18:15:07 +01:00
|
|
|
|
2026-02-14 02:34:09 +05:00
|
|
|
AccountGet(pk string) (*types.Account, error)
|
|
|
|
|
AccountCreate(acc *types.Account) error
|
|
|
|
|
AccountDelete(pk string) error
|
|
|
|
|
AccountList() ([]*types.Account, error)
|
|
|
|
|
|
|
|
|
|
MailboxSelect(pk string, mailbox string) (bool, error)
|
|
|
|
|
MailNextID(pk string, mailbox string) (int, error)
|
|
|
|
|
MailIDForSeq(pk string, mailbox string, seq int) (int, error)
|
|
|
|
|
MailUnseen(pk string, mailbox string) (int, error)
|
|
|
|
|
MailboxList(pk string, onlySubscribed bool) ([]string, error)
|
|
|
|
|
MailboxCreate(pk string, name string) error
|
|
|
|
|
MailboxRename(pk string, old, new string) error
|
|
|
|
|
MailboxDelete(pk string, name string) error
|
|
|
|
|
MailboxSubscribe(pk string, name string, subscribed bool) error
|
|
|
|
|
|
|
|
|
|
MailCreate(pk string, mailbox string, r io.Reader, size int) (int, error)
|
|
|
|
|
MailSelect(pk string, mailbox string, id int) (int, *types.Mail, error)
|
|
|
|
|
MailSearch(pk string, mailbox string) ([]uint32, error)
|
|
|
|
|
MailUpdateFlags(pk string, mailbox string, id int, seen, answered, flagged, deleted bool) error
|
|
|
|
|
MailDelete(pk string, mailbox string, id int) error
|
|
|
|
|
MailExpunge(pk string, mailbox string) error
|
|
|
|
|
MailCount(pk string, mailbox string) (int, error)
|
|
|
|
|
MailMove(pk string, mailbox string, id int, destination string) (int, error)
|
2021-07-09 23:43:09 +01:00
|
|
|
|
|
|
|
|
QueueListDestinations() ([]string, error)
|
|
|
|
|
QueueMailIDsForDestination(destination string) ([]types.QueuedMail, error)
|
2026-02-14 02:34:09 +05:00
|
|
|
QueueInsertDestinationForID(pk string, destination string, id int, from, rcpt string) error
|
|
|
|
|
QueueDeleteDestinationForID(pk string, destination string, id int) error
|
|
|
|
|
QueueSelectIsMessagePendingSend(pk string, mailbox string, id int) (bool, error)
|
2021-07-07 18:15:07 +01:00
|
|
|
}
|