Updates() needs to return imapBackend.Update instead of interface with go-imap v1

This commit is contained in:
Michal Horejsek
2020-04-24 09:12:46 +02:00
parent 313e803fdd
commit 1998d92432
6 changed files with 18 additions and 15 deletions

View File

@ -30,6 +30,7 @@ import (
"github.com/ProtonMail/proton-bridge/internal/store"
"github.com/ProtonMail/proton-bridge/pkg/listener"
"github.com/ProtonMail/proton-bridge/pkg/pmapi"
imapBackend "github.com/emersion/go-imap/backend"
"github.com/hashicorp/go-multierror"
"github.com/pkg/errors"
logrus "github.com/sirupsen/logrus"
@ -59,7 +60,7 @@ type Bridge struct {
// idleUpdates is a channel which the imap backend listens to and which it uses
// to send idle updates to the mail client (eg thunderbird).
// The user stores should send idle updates on this channel.
idleUpdates chan interface{}
idleUpdates chan imapBackend.Update
lock sync.RWMutex
@ -89,7 +90,7 @@ func New(
clientManager: clientManager,
credStorer: credStorer,
storeCache: store.NewCache(config.GetIMAPCachePath()),
idleUpdates: make(chan interface{}),
idleUpdates: make(chan imapBackend.Update),
lock: sync.RWMutex{},
stopAll: make(chan struct{}),
}
@ -541,7 +542,7 @@ func (b *Bridge) updateUserAgent() {
}
// GetIMAPUpdatesChannel sets the channel on which idle events should be sent.
func (b *Bridge) GetIMAPUpdatesChannel() chan interface{} {
func (b *Bridge) GetIMAPUpdatesChannel() chan imapBackend.Update {
if b.idleUpdates == nil {
log.Warn("Bridge updates channel is nil")
}

View File

@ -29,6 +29,7 @@ import (
"github.com/ProtonMail/proton-bridge/internal/store"
"github.com/ProtonMail/proton-bridge/pkg/listener"
"github.com/ProtonMail/proton-bridge/pkg/pmapi"
imapBackend "github.com/emersion/go-imap/backend"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
)
@ -44,7 +45,7 @@ type User struct {
clientManager ClientManager
credStorer CredentialsStorer
imapUpdatesChannel chan interface{}
imapUpdatesChannel chan imapBackend.Update
store *store.Store
storeCache *store.Cache
@ -102,7 +103,7 @@ func (u *User) client() pmapi.Client {
// have the apitoken and password), authorising the user against the api, loading the user store (creating a new one
// if necessary), and setting the imap idle updates channel (used to send imap idle updates to the imap backend if
// something in the store changed).
func (u *User) init(idleUpdates chan interface{}) (err error) {
func (u *User) init(idleUpdates chan imapBackend.Update) (err error) {
u.unlockingKeyringLock.Lock()
u.wasKeyringUnlocked = false
u.unlockingKeyringLock.Unlock()