Skip to content

Commit 1e8aca0

Browse files
B. Olaussonclaude
andcommitted
feat: implement GetGmailLabels for FETCH X-GM-LABELS support
Add GetGmailLabels to the Bridge connector, enabling IMAP clients to read which Proton labels (LabelTypeLabel) a message has via FETCH X-GM-LABELS. Retrieves label IDs from the Proton API and maps them to human-readable names through the shared labels cache. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent c30d469 commit 1e8aca0

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

internal/services/imapservice/connector.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -587,6 +587,27 @@ func (s *Connector) resolveGmailLabelID(ctx context.Context, labelName string, c
587587
return newLabel.ID, nil
588588
}
589589

590+
func (s *Connector) GetGmailLabels(ctx context.Context, messageID imap.MessageID) ([]string, error) {
591+
msg, err := s.client.GetMessage(ctx, string(messageID))
592+
if err != nil {
593+
return nil, fmt.Errorf("failed to get message %v: %w", messageID, err)
594+
}
595+
596+
rLabels := s.labels.Read()
597+
defer rLabels.Close()
598+
599+
var labels []string
600+
601+
for _, labelID := range msg.LabelIDs {
602+
label, ok := rLabels.GetLabel(labelID)
603+
if ok && label.Type == proton.LabelTypeLabel {
604+
labels = append(labels, label.Name)
605+
}
606+
}
607+
608+
return labels, nil
609+
}
610+
590611
func (s *Connector) GetUpdates() <-chan imap.Update {
591612
return s.updateCh.GetChannel()
592613
}

0 commit comments

Comments
 (0)