Files
warmbly/internal/app/worker/mailmanager/manager.go
T
Matthew Meszaros 59b515cad4 callers: migrate blob access from raw *s3 inputs to storage.Store
Seven call sites stop reaching through the embedded *s3.Client and
instead use the high-level storage.Store methods. Same runtime behavior
on the AWS path; opens the door to the Filesystem backend for
self-hosters.

avatar.go retains an S3-specific path for public-ACL + cache-control
on uploaded avatars and falls back to ServiceUnavailable on non-S3
backends. A future PublicStore interface could clean that up.

unibox/storage.go GetBody now propagates the emsg.DecodeBinary error
that the original code dropped on the floor.
2026-05-27 14:41:53 +00:00

56 lines
1.6 KiB
Go

package mailmanager
import (
"sync"
"github.com/google/uuid"
"github.com/warmbly/warmbly/internal/app/cipher"
"github.com/warmbly/warmbly/internal/app/worker/wmail"
"github.com/warmbly/warmbly/internal/infrastructure/cache"
"github.com/warmbly/warmbly/internal/infrastructure/storage"
"github.com/warmbly/warmbly/internal/models"
"github.com/warmbly/warmbly/internal/repository"
)
type MailManager struct {
sync.RWMutex
Emails map[uuid.UUID]*wmail.WMail
OnEvent func(eventType models.JobEventType, key string, body any) error
cache *cache.Cache
storage storage.Store
emailMessageMapRepository repository.EmailMessageMapRepository
cipherService cipher.CipherService
}
func NewMailManager(
onEvent func(eventType models.JobEventType, key string, body any) error,
cache *cache.Cache,
storage storage.Store,
emailMessageMapRepository repository.EmailMessageMapRepository,
cipherService cipher.CipherService,
) *MailManager {
return &MailManager{
Emails: make(map[uuid.UUID]*wmail.WMail),
OnEvent: onEvent,
cache: cache,
storage: storage,
emailMessageMapRepository: emailMessageMapRepository,
cipherService: cipherService,
}
}
// Get returns a WMail by ID, or nil if not present
func (m *MailManager) Get(id uuid.UUID) *wmail.WMail {
m.RLock()
defer m.RUnlock()
return m.Emails[id]
}
// Has returns true if the manager already has this email account
func (m *MailManager) Has(id uuid.UUID) bool {
m.RLock()
defer m.RUnlock()
_, ok := m.Emails[id]
return ok
}