Skip to content

Commit 701673d

Browse files
B. Olaussonclaude
andcommitted
feat: implement GetGmailLabelMailboxID for SEARCH optimization
Returns the IMAP mailbox ID for a Gmail label name by looking up the in-memory label cache. Used by Gluon's optimized SEARCH X-GM-LABELS to avoid per-message API calls. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 1e8aca0 commit 701673d

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

internal/services/imapservice/connector.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -608,6 +608,18 @@ func (s *Connector) GetGmailLabels(ctx context.Context, messageID imap.MessageID
608608
return labels, nil
609609
}
610610

611+
func (s *Connector) GetGmailLabelMailboxID(_ context.Context, label string) (imap.MailboxID, bool) {
612+
rLabels := s.labels.Read()
613+
defer rLabels.Close()
614+
615+
l, ok := rLabels.GetLabelByName(label)
616+
if !ok {
617+
return "", false
618+
}
619+
620+
return imap.MailboxID(l.ID), true
621+
}
622+
611623
func (s *Connector) GetUpdates() <-chan imap.Update {
612624
return s.updateCh.GetChannel()
613625
}

0 commit comments

Comments
 (0)