fix: Removing from inbox shouldn't remove from trash

This commit is contained in:
James Houlahan
2023-02-01 16:09:26 +01:00
committed by LBeernaertProton
parent 5110649c02
commit e2fc4deffe
2 changed files with 15 additions and 2 deletions

View File

@@ -17,10 +17,15 @@ type message struct {
externalID string
addrID string
labelIDs []string
sysLabel *string
attIDs []string
inReplyTo 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
@@ -334,7 +339,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) {

View File

@@ -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) {