GODT-2223: Ensure apiLabels map is properly up to date

This commit is contained in:
James Houlahan
2023-01-18 11:41:51 +01:00
committed by Leander Beernaert
parent c8925cd270
commit 59745e6fb6
2 changed files with 39 additions and 20 deletions

View File

@ -366,7 +366,10 @@ func (user *User) handleUpdateLabelEvent(ctx context.Context, event proton.Label
"name": logging.Sensitive(event.Label.Name),
}).Info("Handling label updated event")
user.apiLabels[event.Label.ID] = event.Label
// Only update the label if it exists; we don't want to create it as a client may have just deleted it.
if _, ok := user.apiLabels[event.Label.ID]; ok {
user.apiLabels[event.Label.ID] = event.Label
}
for _, updateCh := range xslices.Unique(maps.Values(user.updateCh)) {
update := imap.NewMailboxUpdated(