2018-01-10 02:39:00 +01:00
|
|
|
package types
|
|
|
|
|
|
|
|
import (
|
2019-03-31 17:10:10 +02:00
|
|
|
"io"
|
2019-03-11 04:45:00 +01:00
|
|
|
"time"
|
|
|
|
|
2021-11-05 10:19:46 +01:00
|
|
|
"git.sr.ht/~rjarry/aerc/config"
|
|
|
|
"git.sr.ht/~rjarry/aerc/models"
|
2018-01-10 02:39:00 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
type WorkerMessage interface {
|
|
|
|
InResponseTo() WorkerMessage
|
2019-05-19 11:50:19 +02:00
|
|
|
getId() int64
|
|
|
|
setId(id int64)
|
2022-10-06 18:46:41 +02:00
|
|
|
Account() string
|
|
|
|
setAccount(string)
|
2018-01-10 02:39:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
type Message struct {
|
|
|
|
inResponseTo WorkerMessage
|
2019-05-19 11:50:19 +02:00
|
|
|
id int64
|
2022-10-06 18:46:41 +02:00
|
|
|
acct string
|
2018-01-10 02:39:00 +01:00
|
|
|
}
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2019-05-19 11:50:19 +02:00
|
|
|
func (m Message) getId() int64 {
|
2019-05-16 01:41:21 +02:00
|
|
|
return m.id
|
|
|
|
}
|
|
|
|
|
2019-06-02 19:20:02 +02:00
|
|
|
func (m *Message) setId(id int64) {
|
2019-05-16 01:41:21 +02:00
|
|
|
m.id = id
|
|
|
|
}
|
|
|
|
|
2022-10-06 18:46:41 +02:00
|
|
|
func (m *Message) Account() string {
|
|
|
|
return m.acct
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *Message) setAccount(name string) {
|
|
|
|
m.acct = name
|
|
|
|
}
|
|
|
|
|
2018-01-10 02:39:00 +01:00
|
|
|
// Meta-messages
|
2018-01-14 11:30:11 +01:00
|
|
|
|
2018-02-02 01:34:08 +01:00
|
|
|
type Done struct {
|
|
|
|
Message
|
|
|
|
}
|
|
|
|
|
2018-01-10 02:39:00 +01:00
|
|
|
type Error struct {
|
|
|
|
Message
|
|
|
|
Error error
|
|
|
|
}
|
|
|
|
|
2022-01-19 13:18:09 +01:00
|
|
|
type ConnError struct {
|
|
|
|
Message
|
|
|
|
Error error
|
|
|
|
}
|
|
|
|
|
2018-01-10 02:39:00 +01:00
|
|
|
type Unsupported struct {
|
|
|
|
Message
|
|
|
|
}
|
|
|
|
|
2018-02-01 03:54:52 +01:00
|
|
|
// Actions
|
2018-01-14 11:30:11 +01:00
|
|
|
|
2018-01-10 02:39:00 +01:00
|
|
|
type Configure struct {
|
|
|
|
Message
|
2018-01-11 15:04:18 +01:00
|
|
|
Config *config.AccountConfig
|
2018-01-10 02:39:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
type Connect struct {
|
|
|
|
Message
|
|
|
|
}
|
|
|
|
|
2022-01-19 13:18:10 +01:00
|
|
|
type Reconnect struct {
|
|
|
|
Message
|
|
|
|
}
|
|
|
|
|
2018-01-10 02:39:00 +01:00
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2019-03-11 04:45:00 +01:00
|
|
|
type FetchDirectoryContents struct {
|
|
|
|
Message
|
2022-07-05 21:48:40 +02:00
|
|
|
SortCriteria []*SortCriterion
|
|
|
|
FilterCriteria []string
|
2019-03-11 04:45:00 +01:00
|
|
|
}
|
|
|
|
|
2021-11-12 18:12:02 +01:00
|
|
|
type FetchDirectoryThreaded struct {
|
|
|
|
Message
|
2022-07-05 21:48:40 +02:00
|
|
|
SortCriteria []*SortCriterion
|
|
|
|
FilterCriteria []string
|
2021-11-12 18:12:02 +01:00
|
|
|
}
|
|
|
|
|
2019-06-24 22:29:13 +02:00
|
|
|
type SearchDirectory struct {
|
|
|
|
Message
|
2019-08-28 06:39:07 +02:00
|
|
|
Argv []string
|
2019-06-24 22:29:13 +02:00
|
|
|
}
|
|
|
|
|
2021-11-12 18:12:02 +01:00
|
|
|
type DirectoryThreaded struct {
|
|
|
|
Message
|
|
|
|
Threads []*Thread
|
|
|
|
}
|
|
|
|
|
2019-06-08 19:41:56 +02:00
|
|
|
type CreateDirectory struct {
|
|
|
|
Message
|
|
|
|
Directory string
|
2019-07-11 06:49:09 +02:00
|
|
|
Quiet bool
|
2019-06-08 19:41:56 +02:00
|
|
|
}
|
|
|
|
|
2020-08-18 22:27:23 +02:00
|
|
|
type RemoveDirectory struct {
|
|
|
|
Message
|
|
|
|
Directory string
|
|
|
|
Quiet bool
|
|
|
|
}
|
|
|
|
|
2019-03-11 04:45:00 +01:00
|
|
|
type FetchMessageHeaders struct {
|
|
|
|
Message
|
2019-07-08 04:43:57 +02:00
|
|
|
Uids []uint32
|
2019-03-11 04:45:00 +01:00
|
|
|
}
|
|
|
|
|
2019-03-31 18:17:57 +02:00
|
|
|
type FetchFullMessages struct {
|
2019-03-11 04:45:00 +01:00
|
|
|
Message
|
2019-07-08 04:43:57 +02:00
|
|
|
Uids []uint32
|
2019-03-11 04:45:00 +01:00
|
|
|
}
|
|
|
|
|
2019-03-31 17:10:10 +02:00
|
|
|
type FetchMessageBodyPart struct {
|
|
|
|
Message
|
2020-05-16 20:03:42 +02:00
|
|
|
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
|
2019-07-08 04:43:57 +02:00
|
|
|
Uids []uint32
|
2019-03-21 04:23:38 +01:00
|
|
|
}
|
|
|
|
|
2020-07-05 16:29:52 +02:00
|
|
|
// Flag messages with different mail types
|
|
|
|
type FlagMessages struct {
|
2019-06-09 20:55:34 +02:00
|
|
|
Message
|
2020-07-05 16:29:52 +02:00
|
|
|
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
|
2019-07-08 04:43:57 +02:00
|
|
|
Uids []uint32
|
2019-05-14 22:34:42 +02:00
|
|
|
}
|
|
|
|
|
2022-08-16 23:23:37 +02:00
|
|
|
type MoveMessages struct {
|
|
|
|
Message
|
|
|
|
Destination string
|
|
|
|
Uids []uint32
|
|
|
|
}
|
|
|
|
|
2019-05-16 01:41:21 +02:00
|
|
|
type AppendMessage struct {
|
|
|
|
Message
|
|
|
|
Destination string
|
2020-03-03 14:45:06 +01:00
|
|
|
Flags []models.Flag
|
2019-05-16 01:41:21 +02:00
|
|
|
Date time.Time
|
|
|
|
Reader io.Reader
|
|
|
|
Length int
|
|
|
|
}
|
|
|
|
|
2022-05-30 14:34:18 +02:00
|
|
|
type CheckMail struct {
|
|
|
|
Message
|
|
|
|
Directories []string
|
|
|
|
Command string
|
|
|
|
Timeout time.Duration
|
|
|
|
}
|
|
|
|
|
2018-02-01 03:54:52 +01:00
|
|
|
// Messages
|
2018-01-10 02:39:00 +01:00
|
|
|
|
2018-02-02 01:54:19 +01:00
|
|
|
type Directory struct {
|
2018-02-01 03:54:52 +01:00
|
|
|
Message
|
2019-07-08 04:43:56 +02:00
|
|
|
Dir *models.Directory
|
2018-01-10 02:39:00 +01:00
|
|
|
}
|
2019-01-13 22:18:10 +01:00
|
|
|
|
|
|
|
type DirectoryInfo struct {
|
|
|
|
Message
|
2022-05-30 14:34:18 +02:00
|
|
|
Info *models.DirectoryInfo
|
|
|
|
SkipSort bool
|
2019-01-13 22:18:10 +01:00
|
|
|
}
|
2019-03-11 04:45:00 +01:00
|
|
|
|
|
|
|
type DirectoryContents struct {
|
|
|
|
Message
|
2019-03-15 02:51:29 +01:00
|
|
|
Uids []uint32
|
2019-03-11 04:45:00 +01:00
|
|
|
}
|
|
|
|
|
2019-06-24 22:29:13 +02:00
|
|
|
type SearchResults struct {
|
|
|
|
Message
|
|
|
|
Uids []uint32
|
|
|
|
}
|
|
|
|
|
2019-03-11 04:45:00 +01:00
|
|
|
type MessageInfo struct {
|
|
|
|
Message
|
2022-09-20 02:49:15 +02:00
|
|
|
Info *models.MessageInfo
|
|
|
|
NeedsFlags bool
|
2019-03-11 04:45:00 +01:00
|
|
|
}
|
2019-03-21 04:23:38 +01:00
|
|
|
|
2019-03-31 18:17:57 +02:00
|
|
|
type FullMessage struct {
|
2019-03-30 03:35:53 +01:00
|
|
|
Message
|
2020-04-24 22:31:39 +02:00
|
|
|
Info *models.MessageInfo
|
2019-07-08 04:43:56 +02:00
|
|
|
Content *models.FullMessage
|
2019-03-30 03:35:53 +01:00
|
|
|
}
|
|
|
|
|
2019-03-31 17:10:10 +02:00
|
|
|
type MessageBodyPart struct {
|
|
|
|
Message
|
2019-07-08 04:43:56 +02:00
|
|
|
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
|
|
|
|
}
|
2019-09-11 21:01:05 +02:00
|
|
|
|
2022-06-02 02:24:53 +02:00
|
|
|
type MessagesCopied struct {
|
|
|
|
Message
|
|
|
|
Destination string
|
|
|
|
Uids []uint32
|
|
|
|
}
|
|
|
|
|
2022-08-16 23:23:37 +02:00
|
|
|
type MessagesMoved struct {
|
|
|
|
Message
|
|
|
|
Destination string
|
|
|
|
Uids []uint32
|
|
|
|
}
|
|
|
|
|
2019-09-11 21:01:05 +02:00
|
|
|
type ModifyLabels struct {
|
|
|
|
Message
|
|
|
|
Uids []uint32
|
|
|
|
Add []string
|
|
|
|
Remove []string
|
|
|
|
}
|
2019-12-21 16:21:25 +01:00
|
|
|
|
|
|
|
type LabelList struct {
|
|
|
|
Message
|
|
|
|
Labels []string
|
|
|
|
}
|
2022-09-25 03:55:21 +02:00
|
|
|
|
|
|
|
type CheckMailDirectories struct {
|
|
|
|
Message
|
|
|
|
Directories []string
|
|
|
|
}
|