Skip to content

Commit

Permalink
pass currently selected mailbox to CreateMessage, to allow for correc…
Browse files Browse the repository at this point in the history
…t update handling
  • Loading branch information
patrick246 authored and foxcpp committed Oct 1, 2020
1 parent cf943ff commit 5a1d05e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
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

0 comments on commit 5a1d05e

Please sign in to comment.