X-GM-EXT-1 Gmail Label Extension for Proton Bridge#450
Open
bolausson wants to merge 6 commits intoProtonMail:devfrom
Open
X-GM-EXT-1 Gmail Label Extension for Proton Bridge#450bolausson wants to merge 6 commits intoProtonMail:devfrom
bolausson wants to merge 6 commits intoProtonMail:devfrom
Conversation
Implement the X-GM-EXT-1 IMAP extension to support Gmail-style label operations via STORE X-GM-LABELS commands. This allows IMAP clients like Paperless-NGX to apply/remove labels without moving messages between folders. Changes: - Advertise X-GM-EXT-1 capability in IMAP sessions - Extend STORE command parser to handle X-GM-LABELS data item - Add StoreGmailLabels method to state Mailbox - Add SetGmailLabels to connector interface - Route Gmail label STORE through connector to backend Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Extend the FETCH command to recognize X-GM-LABELS as a fetch attribute,
allowing IMAP clients to read Gmail-style labels on messages. This
complements the existing STORE X-GM-LABELS support.
Changes:
- Parse X-GM-LABELS in FETCH attribute handler
- Add GetGmailLabels to connector interface for label retrieval
- Format response as X-GM-LABELS ("Label1" "Label2")
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Python's imaplib sends CAPABILITY before LOGIN and never re-reads capabilities after authentication. Moving X-GM-EXT-1 to the pre-auth capability list so clients like paperless-ngx can detect Gmail label support. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Parse X-GM-LABELS as a search key so clients like paperless-ngx can filter messages by Gmail-style label (e.g. NOT X-GM-LABELS "Paperless"). The search operation calls GetGmailLabels on the connector for each candidate message. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace per-message Proton API calls with local DB queries. The search now resolves the label to a mailbox ID via the connector, queries the local DB for all messages in that mailbox, and builds an in-memory set for O(1) per-message lookups. This turns N API calls into 2 local queries. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Python's imaplib sends labels without wrapping in parentheses: UID STORE 123 +X-GM-LABELS Paperless The parser previously required parenthesized form only: UID STORE 123 +X-GM-LABELS (Paperless) Now both forms are accepted. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
@bolausson any plan to add QUOTA COMMAND |
Author
I don't see why paperless-ngx would need that. The sole purpose of this patch is to make the bride compatible with the way paperless-ngx tags (applies labels) to eMails. Cheers, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Just to be clear - This was entirly coded with a LLM!
X-GM-EXT-1 Gmail Label Extension for Proton Bridge
Paperless-NGX uses Gmail's
X-GM-LABELSIMAP extension to apply and query labels on emails after processing. Proton Bridge didn't support this, so we implemented it across Gluon and Bridge.Gluon (IMAP server library)
STORE +X-GM-LABELS ("Paperless")/-X-GM-LABELScommands, routes them through a newSetGmailLabelsconnector interface to the Bridge backend. AddedX-GM-EXT-1capability advertisement.FETCH (X-GM-LABELS)as a fetch attribute, callsGetGmailLabelson the connector, returns labels in Gmail format:X-GM-LABELS ("Paperless" "Notifications").X-GM-LABELSas a search key so clients can filter messages by label (e.g.NOT X-GM-LABELS "Paperless"). The search operation callsGetGmailLabelson the connector for each candidate message with case-insensitive matching.X-GM-EXT-1to the pre-auth capability list. Python'simaplibchecks capabilities beforeLOGINand never re-reads them, so clients like Paperless-NGX weren't detecting support.Proton Bridge
MarkMessagesWithGmailLabelsmaps label names to Proton label IDs (auto-creating if needed), then callsLabelMessages/UnlabelMessagesAPI. Messages stay in INBOX — labels are applied without moving.GetGmailLabelscallsGetMessageAPI to getLabelIDs, maps them back to names via the shared label cache, filtering forLabelTypeLabelonly. Used by both FETCH and SEARCH operations.Tests
Paperless-ngx logs:
paperless.log
mail.log
celery.log