worker/imap: implement search
This commit is contained in:
parent
b15d1e52b3
commit
0e9c411751
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue