2019-03-15 03:19:04 +01:00
|
|
|
package imap
|
|
|
|
|
|
|
|
import (
|
2019-06-07 10:26:14 +02:00
|
|
|
"bufio"
|
2020-01-04 21:13:52 +01:00
|
|
|
"fmt"
|
2019-06-07 10:26:14 +02:00
|
|
|
|
2019-03-15 03:19:04 +01:00
|
|
|
"github.com/emersion/go-imap"
|
2019-06-07 10:26:14 +02:00
|
|
|
"github.com/emersion/go-message"
|
2020-01-04 21:13:52 +01:00
|
|
|
_ "github.com/emersion/go-message/charset"
|
2019-06-07 10:26:14 +02:00
|
|
|
"github.com/emersion/go-message/mail"
|
|
|
|
"github.com/emersion/go-message/textproto"
|
2019-03-15 03:19:04 +01:00
|
|
|
|
2022-03-22 09:52:27 +01:00
|
|
|
"git.sr.ht/~rjarry/aerc/logging"
|
2021-11-05 10:19:46 +01:00
|
|
|
"git.sr.ht/~rjarry/aerc/models"
|
|
|
|
"git.sr.ht/~rjarry/aerc/worker/types"
|
2019-03-15 03:19:04 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
func (imapw *IMAPWorker) handleFetchMessageHeaders(
|
2022-07-31 22:16:40 +02:00
|
|
|
msg *types.FetchMessageHeaders,
|
|
|
|
) {
|
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
|
|
|
toFetch := msg.Uids
|
|
|
|
if imapw.config.cacheEnabled && imapw.cache != nil {
|
|
|
|
toFetch = imapw.getCachedHeaders(msg)
|
|
|
|
}
|
|
|
|
if len(toFetch) == 0 {
|
|
|
|
imapw.worker.PostMessage(&types.Done{Message: types.RespondTo(msg)},
|
|
|
|
nil)
|
|
|
|
return
|
|
|
|
}
|
2022-07-19 22:31:51 +02:00
|
|
|
logging.Infof("Fetching message headers: %v", toFetch)
|
2019-06-07 10:26:14 +02:00
|
|
|
section := &imap.BodySectionName{
|
|
|
|
BodyPartName: imap.BodyPartName{
|
|
|
|
Specifier: imap.HeaderSpecifier,
|
|
|
|
},
|
2019-06-08 07:22:41 +02:00
|
|
|
Peek: true,
|
2019-06-07 10:26:14 +02:00
|
|
|
}
|
|
|
|
|
2019-03-30 03:35:53 +01:00
|
|
|
items := []imap.FetchItem{
|
2019-03-31 17:10:10 +02:00
|
|
|
imap.FetchBodyStructure,
|
2019-03-30 03:35:53 +01:00
|
|
|
imap.FetchEnvelope,
|
|
|
|
imap.FetchInternalDate,
|
|
|
|
imap.FetchFlags,
|
|
|
|
imap.FetchUid,
|
2019-06-07 10:26:14 +02:00
|
|
|
section.FetchItem(),
|
2019-03-30 03:35:53 +01: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
|
|
|
imapw.handleFetchMessages(msg, toFetch, items,
|
2020-05-16 20:03:42 +02:00
|
|
|
func(_msg *imap.Message) error {
|
|
|
|
reader := _msg.GetBody(section)
|
|
|
|
textprotoHeader, err := textproto.ReadHeader(bufio.NewReader(reader))
|
|
|
|
if err != nil {
|
2022-07-19 22:31:51 +02:00
|
|
|
logging.Errorf(
|
|
|
|
"message %d: could not read header: %v", _msg.Uid, err)
|
2022-09-21 18:44:12 +02:00
|
|
|
imapw.worker.PostMessageInfoError(msg, _msg.Uid, err)
|
2022-02-04 09:14:53 +01:00
|
|
|
return nil
|
2020-05-16 20:03:42 +02:00
|
|
|
}
|
2022-03-18 09:53:02 +01:00
|
|
|
header := &mail.Header{Header: message.Header{Header: textprotoHeader}}
|
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
|
|
|
info := &models.MessageInfo{
|
|
|
|
BodyStructure: translateBodyStructure(_msg.BodyStructure),
|
|
|
|
Envelope: translateEnvelope(_msg.Envelope),
|
|
|
|
Flags: translateImapFlags(_msg.Flags),
|
|
|
|
InternalDate: _msg.InternalDate,
|
|
|
|
RFC822Headers: header,
|
|
|
|
Uid: _msg.Uid,
|
|
|
|
}
|
2020-05-16 20:03:42 +02:00
|
|
|
imapw.worker.PostMessage(&types.MessageInfo{
|
|
|
|
Message: types.RespondTo(msg),
|
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
|
|
|
Info: info,
|
2020-05-16 20:03:42 +02:00
|
|
|
}, nil)
|
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
|
|
|
if imapw.config.cacheEnabled && imapw.cache != nil {
|
|
|
|
imapw.cacheHeader(info)
|
|
|
|
}
|
2020-05-16 20:03:42 +02:00
|
|
|
return nil
|
|
|
|
})
|
2019-03-30 03:35:53 +01:00
|
|
|
}
|
|
|
|
|
2019-03-31 18:14:37 +02:00
|
|
|
func (imapw *IMAPWorker) handleFetchMessageBodyPart(
|
2022-07-31 22:16:40 +02:00
|
|
|
msg *types.FetchMessageBodyPart,
|
|
|
|
) {
|
2022-07-19 22:31:51 +02:00
|
|
|
logging.Infof("Fetching message %d part: %v", msg.Uid, msg.Part)
|
2020-05-16 20:03:42 +02:00
|
|
|
|
|
|
|
var partHeaderSection imap.BodySectionName
|
|
|
|
partHeaderSection.Peek = true
|
|
|
|
if len(msg.Part) > 0 {
|
|
|
|
partHeaderSection.Specifier = imap.MIMESpecifier
|
|
|
|
} else {
|
|
|
|
partHeaderSection.Specifier = imap.HeaderSpecifier
|
|
|
|
}
|
|
|
|
partHeaderSection.Path = msg.Part
|
|
|
|
|
|
|
|
var partBodySection imap.BodySectionName
|
|
|
|
if len(msg.Part) > 0 {
|
|
|
|
partBodySection.Specifier = imap.EntireSpecifier
|
|
|
|
} else {
|
|
|
|
partBodySection.Specifier = imap.TextSpecifier
|
|
|
|
}
|
|
|
|
partBodySection.Path = msg.Part
|
|
|
|
|
2019-06-09 20:55:04 +02:00
|
|
|
items := []imap.FetchItem{
|
2020-05-16 20:03:42 +02:00
|
|
|
imap.FetchEnvelope,
|
2019-06-09 20:55:04 +02:00
|
|
|
imap.FetchUid,
|
2020-05-16 20:03:42 +02:00
|
|
|
imap.FetchBodyStructure,
|
|
|
|
imap.FetchFlags,
|
|
|
|
partHeaderSection.FetchItem(),
|
|
|
|
partBodySection.FetchItem(),
|
2019-06-09 20:55:04 +02:00
|
|
|
}
|
2020-05-16 20:03:42 +02:00
|
|
|
imapw.handleFetchMessages(msg, []uint32{msg.Uid}, items,
|
|
|
|
func(_msg *imap.Message) error {
|
2022-04-28 09:39:47 +02:00
|
|
|
if len(_msg.Body) == 0 {
|
|
|
|
// ignore duplicate messages with only flag updates
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
body := _msg.GetBody(&partHeaderSection)
|
|
|
|
if body == nil {
|
|
|
|
return fmt.Errorf("failed to find part: %v", partHeaderSection)
|
|
|
|
}
|
|
|
|
h, err := textproto.ReadHeader(bufio.NewReader(body))
|
2020-05-16 20:03:42 +02:00
|
|
|
if err != nil {
|
2022-07-31 15:15:27 +02:00
|
|
|
return fmt.Errorf("failed to read part header: %w", err)
|
2020-05-16 20:03:42 +02:00
|
|
|
}
|
|
|
|
|
2022-03-18 09:53:02 +01:00
|
|
|
part, err := message.New(message.Header{Header: h},
|
2020-05-16 20:03:42 +02:00
|
|
|
_msg.GetBody(&partBodySection))
|
2022-09-21 00:27:58 +02:00
|
|
|
if message.IsUnknownCharset(err) {
|
|
|
|
logging.Warnf("unknown charset encountered "+
|
|
|
|
"for uid %d", _msg.Uid)
|
|
|
|
} else if err != nil {
|
2022-07-31 15:15:27 +02:00
|
|
|
return fmt.Errorf("failed to create message reader: %w", err)
|
2020-05-16 20:03:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
imapw.worker.PostMessage(&types.MessageBodyPart{
|
|
|
|
Message: types.RespondTo(msg),
|
|
|
|
Part: &models.MessageBodyPart{
|
|
|
|
Reader: part.Body,
|
|
|
|
Uid: _msg.Uid,
|
|
|
|
},
|
|
|
|
}, nil)
|
|
|
|
// Update flags (to mark message as read)
|
|
|
|
imapw.worker.PostMessage(&types.MessageInfo{
|
|
|
|
Message: types.RespondTo(msg),
|
|
|
|
Info: &models.MessageInfo{
|
|
|
|
Flags: translateImapFlags(_msg.Flags),
|
|
|
|
Uid: _msg.Uid,
|
|
|
|
},
|
|
|
|
}, nil)
|
|
|
|
return nil
|
|
|
|
})
|
2019-03-31 18:14:37 +02:00
|
|
|
}
|
|
|
|
|
2019-03-31 18:17:57 +02:00
|
|
|
func (imapw *IMAPWorker) handleFetchFullMessages(
|
2022-07-31 22:16:40 +02:00
|
|
|
msg *types.FetchFullMessages,
|
|
|
|
) {
|
2022-07-19 22:31:51 +02:00
|
|
|
logging.Infof("Fetching full messages: %v", msg.Uids)
|
2019-03-31 18:17:57 +02:00
|
|
|
section := &imap.BodySectionName{}
|
2019-06-09 20:55:04 +02:00
|
|
|
items := []imap.FetchItem{
|
2020-01-19 00:59:20 +01:00
|
|
|
imap.FetchEnvelope,
|
2019-06-09 20:55:04 +02:00
|
|
|
imap.FetchFlags,
|
|
|
|
imap.FetchUid,
|
|
|
|
section.FetchItem(),
|
|
|
|
}
|
2020-05-16 20:03:42 +02:00
|
|
|
imapw.handleFetchMessages(msg, msg.Uids, items,
|
|
|
|
func(_msg *imap.Message) error {
|
2022-07-21 11:47:30 +02:00
|
|
|
if len(_msg.Body) == 0 {
|
|
|
|
// ignore duplicate messages with only flag updates
|
|
|
|
return nil
|
|
|
|
}
|
2020-05-16 20:03:42 +02:00
|
|
|
r := _msg.GetBody(section)
|
|
|
|
if r == nil {
|
|
|
|
return fmt.Errorf("could not get section %#v", section)
|
|
|
|
}
|
|
|
|
imapw.worker.PostMessage(&types.FullMessage{
|
|
|
|
Message: types.RespondTo(msg),
|
|
|
|
Content: &models.FullMessage{
|
|
|
|
Reader: bufio.NewReader(r),
|
|
|
|
Uid: _msg.Uid,
|
|
|
|
},
|
|
|
|
}, nil)
|
|
|
|
// Update flags (to mark message as read)
|
|
|
|
imapw.worker.PostMessage(&types.MessageInfo{
|
|
|
|
Message: types.RespondTo(msg),
|
|
|
|
Info: &models.MessageInfo{
|
|
|
|
Flags: translateImapFlags(_msg.Flags),
|
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
|
|
|
Uid: _msg.Uid,
|
|
|
|
},
|
|
|
|
}, nil)
|
|
|
|
return nil
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
func (imapw *IMAPWorker) handleFetchMessageFlags(msg *types.FetchMessageFlags) {
|
|
|
|
items := []imap.FetchItem{
|
|
|
|
imap.FetchFlags,
|
|
|
|
imap.FetchUid,
|
|
|
|
}
|
|
|
|
imapw.handleFetchMessages(msg, msg.Uids, items,
|
|
|
|
func(_msg *imap.Message) error {
|
|
|
|
imapw.worker.PostMessage(&types.MessageInfo{
|
|
|
|
Message: types.RespondTo(msg),
|
|
|
|
Info: &models.MessageInfo{
|
|
|
|
Flags: translateImapFlags(_msg.Flags),
|
2020-05-16 20:03:42 +02:00
|
|
|
Uid: _msg.Uid,
|
|
|
|
},
|
|
|
|
}, nil)
|
|
|
|
return nil
|
|
|
|
})
|
2019-03-31 18:17:57 +02:00
|
|
|
}
|
|
|
|
|
2019-03-30 03:35:53 +01:00
|
|
|
func (imapw *IMAPWorker) handleFetchMessages(
|
2019-07-08 04:43:57 +02:00
|
|
|
msg types.WorkerMessage, uids []uint32, items []imap.FetchItem,
|
2022-07-31 22:16:40 +02:00
|
|
|
procFunc func(*imap.Message) error,
|
|
|
|
) {
|
2019-04-28 15:01:56 +02:00
|
|
|
messages := make(chan *imap.Message)
|
2020-01-04 21:13:52 +01:00
|
|
|
done := make(chan error)
|
2019-04-28 15:01:56 +02:00
|
|
|
|
2019-03-15 03:19:04 +01:00
|
|
|
go func() {
|
2022-03-22 09:52:27 +01:00
|
|
|
defer logging.PanicHandler()
|
|
|
|
|
2020-05-16 20:03:42 +02:00
|
|
|
var reterr error
|
2019-04-28 15:01:56 +02:00
|
|
|
for _msg := range messages {
|
2020-05-16 20:03:42 +02:00
|
|
|
err := procFunc(_msg)
|
|
|
|
if err != nil {
|
|
|
|
if reterr == nil {
|
|
|
|
reterr = err
|
2019-06-07 10:26:14 +02:00
|
|
|
}
|
2020-05-16 20:03:42 +02:00
|
|
|
// drain the channel upon error
|
|
|
|
for range messages {
|
2020-01-04 21:13:52 +01:00
|
|
|
}
|
2019-03-15 03:19:04 +01:00
|
|
|
}
|
2019-04-28 15:01:56 +02:00
|
|
|
}
|
2020-05-16 20:03:42 +02:00
|
|
|
done <- reterr
|
2019-03-15 03:19:04 +01:00
|
|
|
}()
|
2019-04-28 15:01:56 +02:00
|
|
|
|
2020-01-04 21:13:52 +01:00
|
|
|
emitErr := func(err error) {
|
2019-04-28 15:01:56 +02:00
|
|
|
imapw.worker.PostMessage(&types.Error{
|
|
|
|
Message: types.RespondTo(msg),
|
|
|
|
Error: err,
|
|
|
|
}, nil)
|
|
|
|
}
|
2020-01-04 21:13:52 +01:00
|
|
|
|
|
|
|
set := toSeqSet(uids)
|
|
|
|
if err := imapw.client.UidFetch(set, items, messages); err != nil {
|
|
|
|
emitErr(err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
if err := <-done; err != nil {
|
|
|
|
emitErr(err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
imapw.worker.PostMessage(
|
2022-03-18 09:53:02 +01:00
|
|
|
&types.Done{Message: types.RespondTo(msg)}, nil)
|
2020-01-04 21:13:52 +01:00
|
|
|
}
|