fix(GODT-2805): Ignore Contact Group Labels

This commit is contained in:
Leander Beernaert
2023-08-28 14:31:52 +02:00
parent 8aee732fe8
commit 06d7fdf26f
3 changed files with 11 additions and 2 deletions

View File

@ -133,7 +133,7 @@ func toIMAPMessage(message proton.MessageMetadata) imap.Message {
func WantLabel(label proton.Label) bool { func WantLabel(label proton.Label) bool {
if label.Type != proton.LabelTypeSystem { if label.Type != proton.LabelTypeSystem {
return true return label.Type != proton.LabelTypeContactGroup
} }
// nolint:exhaustive // nolint:exhaustive

View File

@ -38,6 +38,10 @@ func (s *Service) HandleLabelEvents(ctx context.Context, events []proton.LabelEv
for _, event := range events { for _, event := range events {
switch event.Action { switch event.Action {
case proton.EventCreate: case proton.EventCreate:
if !WantLabel(event.Label) {
continue
}
updates := onLabelCreated(ctx, s, event) updates := onLabelCreated(ctx, s, event)
if err := waitOnIMAPUpdates(ctx, updates); err != nil { if err := waitOnIMAPUpdates(ctx, updates); err != nil {
@ -45,6 +49,10 @@ func (s *Service) HandleLabelEvents(ctx context.Context, events []proton.LabelEv
} }
case proton.EventUpdateFlags, proton.EventUpdate: case proton.EventUpdateFlags, proton.EventUpdate:
if !WantLabel(event.Label) {
continue
}
updates, err := onLabelUpdated(ctx, s, event) updates, err := onLabelUpdated(ctx, s, event)
if err != nil { if err != nil {
return fmt.Errorf("failed to handle update label event: %w", err) return fmt.Errorf("failed to handle update label event: %w", err)

View File

@ -191,7 +191,8 @@ func syncLabels(ctx context.Context, labels map[string]proton.Label, connectors
} }
default: default:
return nil, fmt.Errorf("unknown label type: %d", label.Type) logrus.Errorf("Unknown label type: %d", label.Type)
continue
} }
} }