Skip to content

Commit

Permalink
fix: Do not send flag updates for recovered messages
Browse files Browse the repository at this point in the history
  • Loading branch information
LBeernaertProton committed Mar 6, 2023
1 parent 8f5272b commit 9ea4c68
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions internal/state/updates.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func (state *State) applyMessageFlagsAdded(ctx context.Context, tx *ent.Tx, mess
var messagesToApply []imap.MessageID

for _, msg := range curFlags {
if !msg.FlagSet.ContainsUnchecked(imap.FlagSeenLowerCase) {
if !msg.FlagSet.ContainsUnchecked(imap.FlagSeenLowerCase) && !ids.IsRecoveredRemoteMessageID(msg.RemoteID) {
messagesToApply = append(messagesToApply, msg.RemoteID)
}
}
Expand All @@ -102,7 +102,7 @@ func (state *State) applyMessageFlagsAdded(ctx context.Context, tx *ent.Tx, mess
var messagesToApply []imap.MessageID

for _, msg := range curFlags {
if !msg.FlagSet.ContainsUnchecked(imap.FlagFlaggedLowerCase) {
if !msg.FlagSet.ContainsUnchecked(imap.FlagFlaggedLowerCase) && !ids.IsRecoveredRemoteMessageID(msg.RemoteID) {
messagesToApply = append(messagesToApply, msg.RemoteID)
}
}
Expand Down Expand Up @@ -205,7 +205,7 @@ func (state *State) applyMessageFlagsRemoved(ctx context.Context, tx *ent.Tx, me
var messagesToApply []imap.MessageID

for _, msg := range curFlags {
if msg.FlagSet.ContainsUnchecked(imap.FlagSeenLowerCase) {
if msg.FlagSet.ContainsUnchecked(imap.FlagSeenLowerCase) && !ids.IsRecoveredRemoteMessageID(msg.RemoteID) {
messagesToApply = append(messagesToApply, msg.RemoteID)
}
}
Expand All @@ -222,7 +222,7 @@ func (state *State) applyMessageFlagsRemoved(ctx context.Context, tx *ent.Tx, me
var messagesToApply []imap.MessageID

for _, msg := range curFlags {
if msg.FlagSet.ContainsUnchecked(imap.FlagFlaggedLowerCase) {
if msg.FlagSet.ContainsUnchecked(imap.FlagFlaggedLowerCase) && !ids.IsRecoveredRemoteMessageID(msg.RemoteID) {
messagesToApply = append(messagesToApply, msg.RemoteID)
}
}
Expand Down Expand Up @@ -327,7 +327,7 @@ func (state *State) applyMessageFlagsSet(ctx context.Context, tx *ent.Tx, messag
setSeen := map[bool][]imap.MessageID{true: {}, false: {}}

for _, msg := range curFlags {
if seen := setFlags.ContainsUnchecked(imap.FlagSeenLowerCase); seen != msg.FlagSet.ContainsUnchecked(imap.FlagSeenLowerCase) {
if seen := setFlags.ContainsUnchecked(imap.FlagSeenLowerCase); seen != msg.FlagSet.ContainsUnchecked(imap.FlagSeenLowerCase) && !ids.IsRecoveredRemoteMessageID(msg.RemoteID) {
setSeen[seen] = append(setSeen[seen], msg.RemoteID)
}
}
Expand All @@ -342,7 +342,7 @@ func (state *State) applyMessageFlagsSet(ctx context.Context, tx *ent.Tx, messag
setFlagged := map[bool][]imap.MessageID{true: {}, false: {}}

for _, msg := range curFlags {
if flagged := setFlags.ContainsUnchecked(imap.FlagFlaggedLowerCase); flagged != msg.FlagSet.ContainsUnchecked(imap.FlagFlaggedLowerCase) {
if flagged := setFlags.ContainsUnchecked(imap.FlagFlaggedLowerCase); flagged != msg.FlagSet.ContainsUnchecked(imap.FlagFlaggedLowerCase) && !ids.IsRecoveredRemoteMessageID(msg.RemoteID) {
setFlagged[flagged] = append(setFlagged[flagged], msg.RemoteID)
}
}
Expand Down

0 comments on commit 9ea4c68

Please sign in to comment.