fix(imap): translate virtual label names to RFC 3501 IMAP flags#5
Open
benv666 wants to merge 1 commit intojgalea:mainfrom
Open
fix(imap): translate virtual label names to RFC 3501 IMAP flags#5benv666 wants to merge 1 commit intojgalea:mainfrom
benv666 wants to merge 1 commit intojgalea:mainfrom
Conversation
modify_email was passing caller-supplied strings (e.g. "UNREAD", "FLAGGED") directly as IMAP flags. These are not valid IMAP system flags — the correct RFC 3501 names are \Seen, \Flagged, etc. UNREAD requires special handling: it is the logical inverse of \Seen, so add_labels:["UNREAD"] must remove \Seen and remove_labels:["UNREAD"] must add it. Adds resolveImapFlags() which maps virtual names to system flags and handles the UNREAD inversion. Unknown labels pass through unchanged to allow custom IMAP keywords.
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.
Fixes #4
NOTE: PR claude-generated.
Problem
modify_emailpasses caller-supplied strings (UNREAD,FLAGGED, etc.) directly to imapflow'smessageFlagsAdd/messageFlagsRemove. These are not valid IMAP flags — RFC 3501 system flags use backslash-prefixed names (\Seen,\Flagged,\Answered,\Deleted,\Draft).As a result,
remove_labels: ["UNREAD"]sendsSTORE -FLAGS (UNREAD)to the server. Servers may silently accept an unknown keyword removal without error, but\Seenis never touched — the message stays unread.UNREADhas an additional wrinkle: it is the logical inverse of\Seen. Marking a message as unread means removing\Seen; marking it as read means adding\Seen. Simply renaming the flag is not enough.Fix
Adds
resolveImapFlags()which:UNREADto\Seenwith inversion (addingUNREAD→ remove\Seen, removingUNREAD→ add\Seen)FLAGGED→\Flagged,ANSWERED→\Answered,DELETED→\Deleted,DRAFT→\DraftmodifyLabelsnow resolves both theaddandremovearrays before calling imapflow, crossing the inverted flags to the opposite operation.Notes
modify_emailpasses label names as IMAP flags instead of RFC 3501 system flags #4 (UID vs sequence number). Both fixes are needed formodify_emailto work correctly on IMAP.batchModifyLabelspath callsmodifyLabelsso is fixed automatically.