worker/imap: implement search
This commit is contained in:
parent
b15d1e52b3
commit
0e9c411751
2 changed files with 26 additions and 0 deletions
|
@ -60,3 +60,19 @@ func canOpen(mbox *imap.MailboxInfo) bool {
|
||||||
}
|
}
|
||||||
return true
|
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
|
Message
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type SearchDirectory struct {
|
||||||
|
Message
|
||||||
|
Criteria *imap.SearchCriteria
|
||||||
|
}
|
||||||
|
|
||||||
type CreateDirectory struct {
|
type CreateDirectory struct {
|
||||||
Message
|
Message
|
||||||
Directory string
|
Directory string
|
||||||
|
@ -152,6 +157,11 @@ type DirectoryContents struct {
|
||||||
Uids []uint32
|
Uids []uint32
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type SearchResults struct {
|
||||||
|
Message
|
||||||
|
Uids []uint32
|
||||||
|
}
|
||||||
|
|
||||||
type MessageInfo struct {
|
type MessageInfo struct {
|
||||||
Message
|
Message
|
||||||
BodyStructure *imap.BodyStructure
|
BodyStructure *imap.BodyStructure
|
||||||
|
|
Loading…
Reference in a new issue