Add Fastmail polling support for real-time email processing#2
Open
marcodejongh wants to merge 2 commits intoclaude/add-fastmail-support-bu4nMfrom
Open
Add Fastmail polling support for real-time email processing#2marcodejongh wants to merge 2 commits intoclaude/add-fastmail-support-bu4nMfrom
marcodejongh wants to merge 2 commits intoclaude/add-fastmail-support-bu4nMfrom
Conversation
Since Fastmail doesn't support webhooks for third-party apps, this PR implements polling-based email sync as an alternative: Features: - Add JMAP Email/changes API support via getEmailChanges() method - Create /api/fastmail/poll cron endpoint for background polling - Add "Check for new mail" button for manual sync in settings - Update watch-manager to handle Fastmail accounts gracefully - Add lastPolledAt field to track polling state Technical details: - Uses JMAP state tokens (via lastSyncedHistoryId) for efficient sync - Processes new emails through existing rule engine - Skips recently polled accounts (<2 min) during cron - Returns far-future expiration to prevent watch-manager errors 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
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.
Summary
/api/fastmail/pollcron endpoint for background polling (every 5 minutes)Background
Fastmail doesn't support push notifications (webhooks/EventSource) for third-party applications. This means:
This PR adds polling as an alternative to achieve near-real-time email processing.
Changes
New Files
utils/fastmail/poll-sync.ts- Core polling logicapp/api/fastmail/poll/route.ts- Cron endpointutils/actions/fastmail-sync.ts- Server action for manual synccomponents/FastmailSyncButton.tsx- UI button componentassistant/settings/FastmailSyncSetting.tsx- Settings cardModified Files
utils/email/fastmail.ts- AddedgetEmailChanges()methodutils/email/watch-manager.ts- Handle Fastmail caseutils/email/provider-types.ts- Added helper functionsprisma/schema.prisma- AddedlastPolledAtfieldTest plan
curl -H "Authorization: Bearer $CRON_SECRET" /api/fastmail/poll🤖 Generated with Claude Code