mirror of
https://github.com/neilalexander/yggmail.git
synced 2026-05-07 04:16:28 +03:00
Onboarding, Sent box and Outbox (#45)
* main - Set * Working * Welcome - Added welcome message generation * Smtpsender - On successful SMTP send create the "Sent" box and then try move from "Outbox" to "Sent" * Sent box - Create the mailbox in `main.go` and not every time we try move from `Outbox` to `Sent` * Use logegr * USer - Added logger pointer (and made use of it) - Disallow renaming or deletion of 'Sent' * When creating a new user set it up with logger * Encoded message * Added tests * Send a welcome mail on startup (soon to mke it only happen once) * try set flags * Onboarding flag set * Sender - Removed testing code * Welcome - Moved welcomer code * Cleaned up * Added more * renamed package * Removed comment * welcome - FIxed variable names * welcome - Removed semi-colons - Fixed imports * welcome - Ran `gofmt` * welcome test - Fixed up * h * main - Ran `gofmt` * Main - Fxied * Welcome - Foxed name * Added `.gitignore` * Mailbox - Disabled print logging * Fixed * fixedg * fixe and use `%v`
This commit is contained in:
committed by
GitHub
parent
fa32249f2f
commit
8bf3ba5f47
@@ -48,6 +48,7 @@ func (b *Backend) Login(conn *imap.ConnInfo, username, password string) (backend
|
||||
backend: b,
|
||||
username: username,
|
||||
conn: conn,
|
||||
log: b.Log,
|
||||
}
|
||||
return user, nil
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ import (
|
||||
"encoding/hex"
|
||||
"errors"
|
||||
"fmt"
|
||||
"log"
|
||||
|
||||
"github.com/emersion/go-imap"
|
||||
"github.com/emersion/go-imap/backend"
|
||||
@@ -21,6 +22,7 @@ type User struct {
|
||||
backend *Backend
|
||||
username string
|
||||
conn *imap.ConnInfo
|
||||
log *log.Logger
|
||||
}
|
||||
|
||||
func (u *User) Username() string {
|
||||
@@ -64,21 +66,35 @@ func (u *User) GetMailbox(name string) (mailbox backend.Mailbox, err error) {
|
||||
}
|
||||
|
||||
func (u *User) CreateMailbox(name string) error {
|
||||
return u.backend.Storage.MailboxCreate(name)
|
||||
u.log.Printf("Creating mailbox '%s'...\n", name)
|
||||
|
||||
if e := u.backend.Storage.MailboxCreate(name); e != nil {
|
||||
u.log.Printf("Error creating mailbox '%s': %v\n", name, e);
|
||||
return e;
|
||||
}
|
||||
|
||||
u.log.Printf("Created mailbox '%s'\n", name);
|
||||
return nil;
|
||||
}
|
||||
|
||||
func (u *User) DeleteMailbox(name string) error {
|
||||
switch name {
|
||||
case "INBOX", "Outbox":
|
||||
case "INBOX", "Outbox", "Sent":
|
||||
return errors.New("Cannot delete " + name)
|
||||
default:
|
||||
return u.backend.Storage.MailboxDelete(name)
|
||||
if e := u.backend.Storage.MailboxDelete(name); e != nil {
|
||||
u.log.Printf("Error deleting mailbox '%s': %v\n", name, e)
|
||||
return e;
|
||||
} else {
|
||||
u.log.Printf("Deleted mailbox '%s'\n", name)
|
||||
return e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (u *User) RenameMailbox(existingName, newName string) error {
|
||||
switch existingName {
|
||||
case "INBOX", "Outbox":
|
||||
case "INBOX", "Outbox", "Sent":
|
||||
return errors.New("Cannot rename " + existingName)
|
||||
default:
|
||||
return u.backend.Storage.MailboxRename(existingName, newName)
|
||||
|
||||
Reference in New Issue
Block a user