Skip to content

Commit

Permalink
fix(GODT-2170): Use draft attribute rather than mailbox name
Browse files Browse the repository at this point in the history
  • Loading branch information
LBeernaertProton committed Dec 1, 2022
1 parent 8b44e6d commit 75f4b97
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
8 changes: 7 additions & 1 deletion internal/state/mailbox.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,14 @@ func (m *Mailbox) GetMessagesWithoutFlagCount(flag string) int {

func (m *Mailbox) AppendRegular(ctx context.Context, literal []byte, flags imap.FlagSet, date time.Time) (imap.UID, error) {
var appendIntoDrafts bool

attr, err := m.Attributes(ctx)
if err != nil {
return 0, err
}

// Force create message when appending to drafts so that IMAP clients can create new draft messages.
if !strings.EqualFold(m.name, "Drafts") {
if !attr.Contains(imap.AttrDrafts) {
internalIDString, err := rfc822.GetHeaderValue(literal, ids.InternalIDKey)
if err != nil {
return 0, err
Expand Down
3 changes: 2 additions & 1 deletion tests/draft_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package tests

import (
"github.com/ProtonMail/gluon/imap"
"regexp"
"testing"
"time"
Expand Down Expand Up @@ -47,7 +48,7 @@ func TestDraftSavedAgain(t *testing.T) {
// Email client can save same message i.e.: it will delete old draft
// and append one with same content.
runOneToOneTestWithAuth(t, defaultServerOptions(t), func(c *testConnection, s *testSession) {
mailboxID := s.mailboxCreated("user", []string{"Drafts"})
mailboxID := s.mailboxCreatedWithAttributes("user", []string{"Drafts"}, imap.NewFlagSet(imap.AttrDrafts))

c.C("A002 SELECT Drafts").OK("A002")

Expand Down

0 comments on commit 75f4b97

Please sign in to comment.