Skip to content

Commit

Permalink
fix: Removing from inbox shouldn't remove from trash
Browse files Browse the repository at this point in the history
  • Loading branch information
jameshoulahan committed Feb 1, 2023
1 parent 4b05f1e commit 849493e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
11 changes: 9 additions & 2 deletions server/backend/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,14 @@ type message struct {
externalID string
addrID string
labelIDs []string
sysLabel *string
attIDs []string

// sysLabel is the system label for the message.
// If nil, the message's flags are used to determine the system label (inbox, sent, drafts).
// If "", the message has no system label (e.g. is in a custom folder or all mail).
// If non-nil and non-empty, the message has the system label with the given ID (e.g. spam, trash).
sysLabel *string

subject string
sender *mail.Address
toList []*mail.Address
Expand Down Expand Up @@ -303,7 +308,9 @@ func (msg *message) remLabel(labelID string, labels map[string]*label) {
}

func (msg *message) remFlagLabel(labelID string, labels map[string]*label) {
msg.sysLabel = pointer("")
if msg.sysLabel == nil {
msg.sysLabel = pointer("")
}
}

func (msg *message) remSystemLabel(labelID string, labels map[string]*label) {
Expand Down
6 changes: 6 additions & 0 deletions server/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -939,6 +939,12 @@ func TestServer_Labels(t *testing.T) {
actions: []any{add(proton.TrashLabel), rem(proton.TrashLabel)},
wantLabelIDs: []string{proton.AllMailLabel, proton.AllSentLabel},
},
{
name: "received flag, add inbox, add trash, remove inbox",
flags: proton.MessageFlagReceived,
actions: []any{add(proton.InboxLabel), add(proton.TrashLabel), rem(proton.InboxLabel)},
wantLabelIDs: []string{proton.AllMailLabel, proton.TrashLabel},
},
}

withServer(t, func(ctx context.Context, s *Server, m *proton.Manager) {
Expand Down

0 comments on commit 849493e

Please sign in to comment.