Merge commit '8b39ea4a'

create-reload-action
Lukasz Janyst 3 years ago
commit 1d443988e6
No known key found for this signature in database
GPG Key ID: 32DE641041F17A9A
  1. 3
      pkg/bridge/bridge.go
  2. 2
      pkg/config/settings/settings.go
  3. 46
      pkg/imap/backend.go
  4. 4
      pkg/imap/user.go

@ -128,7 +128,8 @@ func (b *Bridge) Run() error {
}
bccSelf := b.settings.GetBool(settings.BCCSelf)
imapBackend := imap.NewIMAPBackend(b.listener, b.settings, b.Users, bccSelf)
isAllMailVisible := b.settings.GetBool(settings.IsAllMailVisible)
imapBackend := imap.NewIMAPBackend(b.listener, b.settings, b.Users, bccSelf, isAllMailVisible)
smtpBackend := smtp.NewSMTPBackend(b.listener, b.Users, bccSelf)
serverAddress := b.settings.Get(settings.ServerAddress)

@ -44,6 +44,7 @@ const (
ServerAddress = "ServerAddress"
CredentialsStore = "CredentialsStore"
BCCSelf = "BCCSelf"
IsAllMailVisible = "IsAllMailVisible"
)
type Settings struct {
@ -81,6 +82,7 @@ func (s *Settings) setDefaultValues() {
s.setDefault(IMAPPortKey, DefaultIMAPPort)
s.setDefault(SMTPPortKey, DefaultSMTPPort)
s.setDefault(BCCSelf, "false")
s.setDefault(IsAllMailVisible, "true")
settingsDir := "/etc/peroxide"
s.setDefault(CacheDir, "/var/cache/peroxide/cache")

@ -24,10 +24,11 @@
// When IMAP clients request message literals (or parts thereof), we sometimes need to build RFC822 message literals.
// To do this, we pass build jobs to the message builder, which internally manages its own parallelism.
// Summary:
// - each IMAP fetch request is handled in parallel,
// - within each IMAP fetch request, individual items are handled by a pool of `fetchWorkers` workers,
// - within each worker, build jobs are posted to the message builder,
// - the message builder handles build jobs using its own, independent worker pool,
// - each IMAP fetch request is handled in parallel,
// - within each IMAP fetch request, individual items are handled by a pool of `fetchWorkers` workers,
// - within each worker, build jobs are posted to the message builder,
// - the message builder handles build jobs using its own, independent worker pool,
//
// The builder will handle jobs in parallel up to its own internal limit. This prevents it from overwhelming API.
package imap
@ -46,11 +47,12 @@ import (
)
type imapBackend struct {
usersMgr *users.Users
updates *imapUpdates
eventListener listener.Listener
listWorkers int
bccSelf bool
usersMgr *users.Users
updates *imapUpdates
eventListener listener.Listener
listWorkers int
bccSelf bool
isAllMailVisible bool
users map[string]*imapUser
usersLocker sync.Locker
@ -66,25 +68,13 @@ func NewIMAPBackend(
setting *settings.Settings,
users *users.Users,
bccSelf bool,
isAllMailVisible bool,
) *imapBackend { //nolint[golint]
imapWorkers := setting.GetInt(settings.IMAPWorkers)
cacheDir := setting.Get(settings.CacheDir)
backend := newIMAPBackend(cacheDir, users, eventListener, imapWorkers, bccSelf)
go backend.monitorDisconnectedUsers()
return backend
}
func newIMAPBackend(
cacheDir string,
users *users.Users,
eventListener listener.Listener,
listWorkers int,
bccSelf bool,
) *imapBackend {
return &imapBackend{
backend := &imapBackend{
usersMgr: users,
updates: newIMAPUpdates(),
eventListener: eventListener,
@ -94,9 +84,15 @@ func newIMAPBackend(
imapCachePath: filepath.Join(cacheDir, "imap_backend_cache.json"),
imapCacheLock: &sync.RWMutex{},
listWorkers: listWorkers,
bccSelf: bccSelf,
listWorkers: imapWorkers,
bccSelf: bccSelf,
isAllMailVisible: isAllMailVisible,
}
go backend.monitorDisconnectedUsers()
return backend
}
func (ib *imapBackend) getUser(address, slot, password string) (*imapUser, error) {

@ -121,6 +121,10 @@ func (iu *imapUser) Username() string {
func (iu *imapUser) ListMailboxes(showOnlySubcribed bool) ([]goIMAPBackend.Mailbox, error) {
mailboxes := []goIMAPBackend.Mailbox{}
for _, storeMailbox := range iu.storeAddress.ListMailboxes() {
if storeMailbox.LabelID() == pmapi.AllMailLabel && !iu.backend.isAllMailVisible {
continue
}
if showOnlySubcribed && !iu.isSubscribed(storeMailbox.LabelID()) {
continue
}

Loading…
Cancel
Save