aerc/worker/types/messages.go

273 lines
3.4 KiB
Go
Raw Normal View History

package types
import (
2019-03-31 17:10:10 +02:00
"io"
"time"
"git.sr.ht/~rjarry/aerc/config"
"git.sr.ht/~rjarry/aerc/models"
)
type WorkerMessage interface {
InResponseTo() WorkerMessage
getId() int64
setId(id int64)
Account() string
setAccount(string)
}
type Message struct {
inResponseTo WorkerMessage
id int64
acct string
}
2018-02-01 03:54:52 +01:00
func RespondTo(msg WorkerMessage) Message {
return Message{
inResponseTo: msg,
}
}
func (m Message) InResponseTo() WorkerMessage {
return m.inResponseTo
}
func (m Message) getId() int64 {
return m.id
}
func (m *Message) setId(id int64) {
m.id = id
}
func (m *Message) Account() string {
return m.acct
}
func (m *Message) setAccount(name string) {
m.acct = name
}
// Meta-messages
2018-01-14 11:30:11 +01:00
2018-02-02 01:34:08 +01:00
type Done struct {
Message
}
type Error struct {
Message
Error error
}
type ConnError struct {
Message
Error error
}
type Unsupported struct {
Message
}
2018-02-01 03:54:52 +01:00
// Actions
2018-01-14 11:30:11 +01:00
type Configure struct {
Message
2018-01-11 15:04:18 +01:00
Config *config.AccountConfig
}
type Connect struct {
Message
}
type Reconnect struct {
Message
}
type Disconnect struct {
Message
}
2018-02-02 01:34:08 +01:00
type ListDirectories struct {
Message
}
2019-01-13 22:18:10 +01:00
type OpenDirectory struct {
Message
Directory string
}
type FetchDirectoryContents struct {
Message
SortCriteria []*SortCriterion
FilterCriteria []string
}
type FetchDirectoryThreaded struct {
Message
SortCriteria []*SortCriterion
FilterCriteria []string
}
2019-06-24 22:29:13 +02:00
type SearchDirectory struct {
Message
Argv []string
2019-06-24 22:29:13 +02:00
}
type DirectoryThreaded struct {
Message
Threads []*Thread
}
type CreateDirectory struct {
Message
Directory string
2019-07-11 06:49:09 +02:00
Quiet bool
}
type RemoveDirectory struct {
Message
Directory string
Quiet bool
}
type FetchMessageHeaders struct {
Message
Uids []uint32
}
type FetchFullMessages struct {
Message
Uids []uint32
}
2019-03-31 17:10:10 +02:00
type FetchMessageBodyPart struct {
Message
Uid uint32
Part []int
2019-03-31 17:10:10 +02:00
}
imap: add option to cache headers Add option to cache headers for imap accounts. Cache db is located at $XDG_CACHE_DIR/aerc/{account name}. The cache is cleaned of stale entries when aerc is first opened. Two new account level configuration options are introduced: * cache-headers (Default: false) * cache-max-age (Default: 30 days (720 hours)) The change in worker/imap/open.go is to set the selected directory. This is required to access the UIDVALIDITY field, which is used in combination with the message ID to form the key for use in the cache db. The key structure is: "header.{UIDVALIDITY}.{UID}" Where reasonable, cache does not stop aerc from running. In general, if there is an error in the cache, aerc should continue working as usual. Errors are either displayed to the user or logged. All messages are stored without flags, and when retrieved have the flags set to SEEN. This is to prevent UI flashes. A new method to FetchMessageFlags is introduced to update flags of cached headers. This is done asynchronously, and the user will see their messages appear and then any flags updated. The message will initially show as SEEN, but will update to unread. I considered updating the cache with the last-known flag state, however it seems prudent to spare the R/W cycle and assume that - eventually - all messages will end up read, and if it isn't the update will occur rather quickly. Note that leveldb puts a lock on the database, preventing multiple instances of aerc from accessing the cache at the same time. Much of this work is based on previous efforts by Vladimír Magyar. Implements: https://todo.sr.ht/~rjarry/aerc/2 Thanks: Vladimír Magyar <vladimir@mgyar.me> Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Tested-by: inwit <inwit@sindominio.net> Reviewed-by: Koni Marti <koni.marti@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc>
2022-06-15 14:23:51 +02:00
type FetchMessageFlags struct {
Message
Uids []uint32
}
2019-03-21 04:23:38 +01:00
type DeleteMessages struct {
Message
Uids []uint32
2019-03-21 04:23:38 +01:00
}
// Flag messages with different mail types
type FlagMessages struct {
2019-06-09 20:55:34 +02:00
Message
Enable bool
2020-07-17 17:50:24 +02:00
Flag models.Flag
Uids []uint32
2019-06-09 20:55:34 +02:00
}
2020-05-25 16:59:48 +02:00
type AnsweredMessages struct {
Message
Answered bool
Uids []uint32
}
2019-05-14 22:34:42 +02:00
type CopyMessages struct {
Message
Destination string
Uids []uint32
2019-05-14 22:34:42 +02:00
}
type MoveMessages struct {
Message
Destination string
Uids []uint32
}
type AppendMessage struct {
Message
Destination string
Flags []models.Flag
Date time.Time
Reader io.Reader
Length int
}
type CheckMail struct {
Message
Directories []string
Command string
Timeout time.Duration
}
2018-02-01 03:54:52 +01:00
// Messages
2018-02-02 01:54:19 +01:00
type Directory struct {
2018-02-01 03:54:52 +01:00
Message
Dir *models.Directory
}
2019-01-13 22:18:10 +01:00
type DirectoryInfo struct {
Message
Info *models.DirectoryInfo
SkipSort bool
2019-01-13 22:18:10 +01:00
}
type DirectoryContents struct {
Message
Uids []uint32
}
2019-06-24 22:29:13 +02:00
type SearchResults struct {
Message
Uids []uint32
}
type MessageInfo struct {
Message
Info *models.MessageInfo
NeedsFlags bool
}
2019-03-21 04:23:38 +01:00
type FullMessage struct {
2019-03-30 03:35:53 +01:00
Message
Content *models.FullMessage
2019-03-30 03:35:53 +01:00
}
2019-03-31 17:10:10 +02:00
type MessageBodyPart struct {
Message
Part *models.MessageBodyPart
2019-03-31 17:10:10 +02:00
}
2019-03-21 04:23:38 +01:00
type MessagesDeleted struct {
Message
Uids []uint32
}
type MessagesCopied struct {
Message
Destination string
Uids []uint32
}
type MessagesMoved struct {
Message
Destination string
Uids []uint32
}
type ModifyLabels struct {
Message
Uids []uint32
Add []string
Remove []string
}
2019-12-21 16:21:25 +01:00
type LabelList struct {
Message
Labels []string
}
type CheckMailDirectories struct {
Message
Directories []string
}