package imap import ( "fmt" "log" "github.com/emersion/go-imap" imapbackend "github.com/emersion/go-imap/backend" "ur.gs/crockery/internal/store" ) var ( ErrNotImplemented = fmt.Errorf("Not yet implemented") ) // type Session implements the User interface for emersion/go-imap type Session struct { ID uint64 Account store.Account ServiceName string store store.Interface } func (s *Session) Username() string { return s.Account.Username } func (s *Session) ListMailboxes(subscribed bool) ([]imapbackend.Mailbox, error) { return []imapbackend.Mailbox{ // FIXME: hardcoded! &Mailbox{name: imap.InboxName, session: s}, }, nil } func (s *Session) GetMailbox(name string) (imapbackend.Mailbox, error) { if name == imap.InboxName { // FIXME: hardcoded! return &Mailbox{name: name, session: s}, nil } return nil, ErrNotImplemented } func (s *Session) CreateMailbox(name string) error { return ErrNotImplemented } func (s *Session) DeleteMailbox(name string) error { return ErrNotImplemented } func (s *Session) RenameMailbox(existingName, newName string) error { return ErrNotImplemented } func (s *Session) Logout() error { log.Printf("Ending %s session %d for %s", s.ServiceName, s.ID, s.Username()) return nil }