worker/imap: implement search

This commit is contained in:
Drew DeVault 2019-06-24 16:29:13 -04:00
parent b15d1e52b3
commit 0e9c411751
2 changed files with 26 additions and 0 deletions

View File

@ -60,3 +60,19 @@ func canOpen(mbox *imap.MailboxInfo) bool {
}
return true
}
func (imapw *IMAPWorker) handleSearchDirectory(msg *types.SearchDirectory) {
imapw.worker.Logger.Println("Executing search")
if uids, err := imapw.client.UidSearch(msg.Criteria); err != nil {
imapw.worker.PostMessage(&types.Error{
Message: types.RespondTo(msg),
Error: err,
}, nil)
} else {
imapw.worker.PostMessage(&types.SearchResults{
Message: types.RespondTo(msg),
Uids: uids,
}, nil)
}
}

View File

@ -82,6 +82,11 @@ type FetchDirectoryContents struct {
Message
}
type SearchDirectory struct {
Message
Criteria *imap.SearchCriteria
}
type CreateDirectory struct {
Message
Directory string
@ -152,6 +157,11 @@ type DirectoryContents struct {
Uids []uint32
}
type SearchResults struct {
Message
Uids []uint32
}
type MessageInfo struct {
Message
BodyStructure *imap.BodyStructure