Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass selected mailbox to CreateMessage #1

Merged
merged 1 commit into from
Oct 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion backend/memory/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func (u *User) SetSubscribed(name string, subscribed bool) error {
return nil
}

func (u *User) CreateMessage(mboxName string, flags []string, date time.Time, body imap.Literal) error {
func (u *User) CreateMessage(mboxName string, flags []string, date time.Time, body imap.Literal, _ backend.Mailbox) error {
mbox, ok := u.mailboxes[mboxName]
if !ok {
return backend.ErrNoSuchMailbox
Expand Down
5 changes: 4 additions & 1 deletion backend/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@ type User interface {
//
// If the Backend implements Updater, it must notify the client immediately
// via a mailbox update.
CreateMessage(mbox string, flags []string, date time.Time, body imap.Literal) error
//
// If a mailbox is selected on the current connection, then it is passed as
// the selectedMailbox parameter. If none is selected, nil is passed
CreateMessage(mbox string, flags []string, date time.Time, body imap.Literal, selectedMailbox Mailbox) error

// ListMailboxes returns information about mailboxes belonging to this
// user. If subscribed is set to true, only returns subscribed mailboxes.
Expand Down
2 changes: 1 addition & 1 deletion server/cmd_auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ func (cmd *Append) Handle(conn Conn) error {
return ErrNotAuthenticated
}

if err := ctx.User.CreateMessage(cmd.Mailbox, cmd.Flags, cmd.Date, cmd.Message); err != nil {
if err := ctx.User.CreateMessage(cmd.Mailbox, cmd.Flags, cmd.Date, cmd.Message, ctx.Mailbox); err != nil {
if err == backend.ErrNoSuchMailbox {
return ErrStatusResp(&imap.StatusResp{
Type: imap.StatusRespNo,
Expand Down