From 5a1d05e53e2cf10e7c40a609022a878108ce8db3 Mon Sep 17 00:00:00 2001 From: Patrick Hahn Date: Thu, 1 Oct 2020 21:11:50 +0200 Subject: [PATCH] pass currently selected mailbox to CreateMessage, to allow for correct update handling --- backend/memory/user.go | 2 +- backend/user.go | 5 ++++- server/cmd_auth.go | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/backend/memory/user.go b/backend/memory/user.go index fb176998..5c6c02f1 100644 --- a/backend/memory/user.go +++ b/backend/memory/user.go @@ -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 diff --git a/backend/user.go b/backend/user.go index 1dc04f5e..8b024382 100644 --- a/backend/user.go +++ b/backend/user.go @@ -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. diff --git a/server/cmd_auth.go b/server/cmd_auth.go index c89a9fa5..b58a5abd 100644 --- a/server/cmd_auth.go +++ b/server/cmd_auth.go @@ -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,