Skip to content

Expose X-GM-THRID via Fetch::gmail_thread_id()#138

Open
benchub wants to merge 1 commit into
chatmail:mainfrom
benchub:expose-gmail-thread-id
Open

Expose X-GM-THRID via Fetch::gmail_thread_id()#138
benchub wants to merge 1 commit into
chatmail:mainfrom
benchub:expose-gmail-thread-id

Conversation

@benchub

@benchub benchub commented Jul 17, 2026

Copy link
Copy Markdown

Summary

imap-proto already parses the Gmail thread id (X-GM-THRID) into AttributeValue::GmailThrId, but Fetch provided no getter for it — unlike its siblings gmail_msg_id() (X-GM-MSGID) and gmail_labels() (X-GM-LABELS). This adds the missing accessor:

/// Get the Gmail thread id (X-GM-THRID). Only present if the server
/// returned it (Gmail's X-GM-EXT-1).
pub fn gmail_thread_id(&self) -> Option<&u64>

It mirrors gmail_msg_id() exactly, just matching AttributeValue::GmailThrId instead of AttributeValue::GmailMsgId.

Motivation: X-GM-THRID lets clients group messages into Gmail conversations/threads without re-implementing Gmail's threading heuristics. Since gmail_msg_id/gmail_labels are already exposed, this fills the gap for the one remaining Gmail extension attribute imap-proto parses.

Test plan

  • Added parse_fetches_gmail_thread_id in src/parse.rs, following the existing parse_fetches_test convention: feeds a * 24 FETCH (... X-GM-THRID 1278455344230334865) response through parse_fetches and asserts gmail_thread_id() returns the parsed value, and None for a FETCH response without it.
  • cargo fmt --check and cargo test --features runtime-async-std pass (70 unit tests, including the new one).

🤖 Generated with Claude Code

imap-proto already parses the Gmail thread id (X-GM-THRID) into
AttributeValue::GmailThrId, but Fetch had no accessor for it, unlike
its siblings gmail_msg_id() and gmail_labels(). Add gmail_thread_id()
mirroring gmail_msg_id(), plus a unit test in parse.rs covering both
the present and absent cases.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@benchub

benchub commented Jul 17, 2026

Copy link
Copy Markdown
Author

One thing worth flagging for the record: AttributeValue::GmailThrId was introduced in imap-proto 0.16.6 (0.16.4/0.16.5 only have GmailMsgId/GmailLabels). That's newer than the imap-proto = "0.16.4" floor this crate currently declares in Cargo.toml.

In practice this isn't a problem under normal dependency resolution — Cargo will happily pick 0.16.6+ within that ^0.16.4 range, and that's exactly what cargo build/cargo test did in my testing. But a strict minimal-versions build (cargo +nightly build -Z minimal-versions) pinned to exactly imap-proto 0.16.4 would fail to compile against this new accessor.

I left the Cargo.toml floor alone to keep this diff minimal and not second-guess your dependency-floor policy, but happy to bump imap-proto to "0.16.6" here (or in a follow-up) if you'd prefer that be explicit. Just let me know!

@benchub

benchub commented Jul 17, 2026

Copy link
Copy Markdown
Author

Oh hey, this duplicates #133 and #129.... but this time with tests. I guess there's a desire.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant