imap: use builtin idle support

go-imap supports IDLE since 1.2.0. Remove dependency to go-imap-idle.

Link: https://github.com/emersion/go-imap/commit/ac3f8e195ef1b6d
Signed-off-by: Robin Jarry <robin@jarry.cc>
This commit is contained in:
Robin Jarry 2021-11-01 21:19:17 +01:00
parent 138977b2ce
commit 4cf0ea2a05
4 changed files with 2 additions and 12 deletions

1
go.mod
View file

@ -8,7 +8,6 @@ require (
github.com/danwakefield/fnmatch v0.0.0-20160403171240-cbb64ac3d964 github.com/danwakefield/fnmatch v0.0.0-20160403171240-cbb64ac3d964
github.com/ddevault/go-libvterm v0.0.0-20190526194226-b7d861da3810 github.com/ddevault/go-libvterm v0.0.0-20190526194226-b7d861da3810
github.com/emersion/go-imap v1.2.0 github.com/emersion/go-imap v1.2.0
github.com/emersion/go-imap-idle v0.0.0-20210907174914-db2568431445
github.com/emersion/go-imap-sortthread v1.2.0 github.com/emersion/go-imap-sortthread v1.2.0
github.com/emersion/go-maildir v0.2.0 github.com/emersion/go-maildir v0.2.0
github.com/emersion/go-message v0.15.0 github.com/emersion/go-message v0.15.0

4
go.sum
View file

@ -65,10 +65,6 @@ github.com/emersion/go-imap v1.0.6-0.20201014170015-5a03a09eba6d/go.mod h1:yKASt
github.com/emersion/go-imap v1.0.6/go.mod h1:yKASt+C3ZiDAiCSssxg9caIckWF/JG7ZQTO7GAmvicU= github.com/emersion/go-imap v1.0.6/go.mod h1:yKASt+C3ZiDAiCSssxg9caIckWF/JG7ZQTO7GAmvicU=
github.com/emersion/go-imap v1.2.0 h1:lyUQ3+EVM21/qbWE/4Ya5UG9r5+usDxlg4yfp3TgHFA= github.com/emersion/go-imap v1.2.0 h1:lyUQ3+EVM21/qbWE/4Ya5UG9r5+usDxlg4yfp3TgHFA=
github.com/emersion/go-imap v1.2.0/go.mod h1:Qlx1FSx2FTxjnjWpIlVNEuX+ylerZQNFE5NsmKFSejY= github.com/emersion/go-imap v1.2.0/go.mod h1:Qlx1FSx2FTxjnjWpIlVNEuX+ylerZQNFE5NsmKFSejY=
github.com/emersion/go-imap-idle v0.0.0-20190519112320-2704abd7050e h1:L7bswVJZcf2YHofgom49oFRwVqmBj/qZqDy9/SJpZMY=
github.com/emersion/go-imap-idle v0.0.0-20190519112320-2704abd7050e/go.mod h1:o14zPKCmEH5WC1vU5SdPoZGgNvQx7zzKSnxPQlobo78=
github.com/emersion/go-imap-idle v0.0.0-20210907174914-db2568431445 h1:dAGbaaU4LLupO7dnYZaELOoI3RoVDNi5DCGejLe8a7c=
github.com/emersion/go-imap-idle v0.0.0-20210907174914-db2568431445/go.mod h1:N/6S3dRTVt8xT867m+476C16+v/Fq4WZYvh2Chg0nmg=
github.com/emersion/go-imap-sortthread v1.1.1-0.20201009054724-d020d96306b3 h1:I9RUCEAsOl1Hpcq7KRUVYvs0y8WYCjDT3tCXBSuHKoo= github.com/emersion/go-imap-sortthread v1.1.1-0.20201009054724-d020d96306b3 h1:I9RUCEAsOl1Hpcq7KRUVYvs0y8WYCjDT3tCXBSuHKoo=
github.com/emersion/go-imap-sortthread v1.1.1-0.20201009054724-d020d96306b3/go.mod h1:opHOzblOHZKQM1JEy+GPk1217giNLa7kleyWTN06qnc= github.com/emersion/go-imap-sortthread v1.1.1-0.20201009054724-d020d96306b3/go.mod h1:opHOzblOHZKQM1JEy+GPk1217giNLa7kleyWTN06qnc=
github.com/emersion/go-imap-sortthread v1.2.0 h1:EMVEJXPWAhXMWECjR82Rn/tza6MddcvTwGAdTu1vJKU= github.com/emersion/go-imap-sortthread v1.2.0 h1:EMVEJXPWAhXMWECjR82Rn/tza6MddcvTwGAdTu1vJKU=

View file

@ -18,9 +18,6 @@ func (imapw *IMAPWorker) handleOpenDirectory(msg *types.OpenDirectory) {
}, nil) }, nil)
} else { } else {
imapw.worker.PostMessage(&types.Done{types.RespondTo(msg)}, nil) imapw.worker.PostMessage(&types.Done{types.RespondTo(msg)}, nil)
if imapw.idleStop == nil {
imapw.idleStop = make(chan struct{})
}
} }
} }

View file

@ -7,7 +7,6 @@ import (
"strings" "strings"
"github.com/emersion/go-imap" "github.com/emersion/go-imap"
idle "github.com/emersion/go-imap-idle"
sortthread "github.com/emersion/go-imap-sortthread" sortthread "github.com/emersion/go-imap-sortthread"
"github.com/emersion/go-imap/client" "github.com/emersion/go-imap/client"
"golang.org/x/oauth2" "golang.org/x/oauth2"
@ -27,7 +26,6 @@ var errUnsupported = fmt.Errorf("unsupported command")
type imapClient struct { type imapClient struct {
*client.Client *client.Client
idle *idle.IdleClient
sort *sortthread.SortClient sort *sortthread.SortClient
} }
@ -157,7 +155,7 @@ func (w *IMAPWorker) handleMessage(msg types.WorkerMessage) error {
} }
c.Updates = w.updates c.Updates = w.updates
w.client = &imapClient{c, idle.NewClient(c), sortthread.NewSortClient(c)} w.client = &imapClient{c, sortthread.NewSortClient(c)}
w.worker.PostMessage(&types.Done{types.RespondTo(msg)}, nil) w.worker.PostMessage(&types.Done{types.RespondTo(msg)}, nil)
case *types.ListDirectories: case *types.ListDirectories:
w.handleListDirectories(msg) w.handleListDirectories(msg)
@ -194,7 +192,7 @@ func (w *IMAPWorker) handleMessage(msg types.WorkerMessage) error {
if w.idleStop != nil { if w.idleStop != nil {
w.idleStop = make(chan struct{}) w.idleStop = make(chan struct{})
go func() { go func() {
w.idleDone <- w.client.idle.IdleWithFallback(w.idleStop, 0) w.idleDone <- w.client.Idle(w.idleStop, &client.IdleOptions{0, 0})
}() }()
} }
return reterr return reterr