8000 feat(sources): route a shared inbox's mail to namespaces with rules by adeelahmad · Pull Request #153 · adeelahmad/lense · GitHub
[go: up one dir, main page]

Skip to content

feat(sources): route a shared inbox's mail to namespaces with rules - #153

Merged
adeelahmad merged 1 commit into
mainfrom
claude/project-thread-gvg3ro
Oct 5, 2026
Merged

adeelahmad merged 1 commit into
mainfrom
claude/project-thread-gvg3ro

Conversation

@adeelahmad
Copy link
Copy Markdown
Owner

Requested by Adeel · project thread

Description

Before: a watch on an email account sent every new message to one namespace.

After: an email watch can carry routing rules. Each rule has conditions on from, to (To, Cc, and Delivered-To / X-Original-To, so mail sent to an alias of a shared inbox is told apart), subject, list (List-Id) or mailbox, and sends matching messages to another namespace or skips them. Rules are tried in order and the first match decides. A message no rule matches goes to the watch's own namespace, so with no rules nothing changes. POST /api/v1/watches/routes/preview shows where the latest messages would go before saving.

How: the IMAP listing now also reads From, To, Cc, Delivered-To, X-Original-To and List-Id (still headers only, read-only). The new mail_routes.py checks and matches rules. Rules are stored on the watch with namespace ids, so a renamed namespace keeps its mail. A rule must name a namespace that exists, because rules never create one. Mail for a namespace deleted later goes to the watch's namespace. Matching is plain string work with no model calls, so it stays light enough for a Raspberry Pi. The web editor comes in a follow-up PR.

Motivation and Context

This is the "routing rules from a shared inbox" backlog item.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change

Checklist:

  • The title is a Conventional Commit.
  • My code follows the code style of this project (ruff, ruff format, mypy clean).
  • I added or updated tests (tests/api/test_mail_routes.py, against the fake IMAP server).
  • My change requires documentation updates, and I have updated docs/ accordingly (docs/processing.md).
  • Users need more than the title to understand it.

🤖 Generated with Claude Code

https://claude.ai/code/session_01V3JT2ET8A1tXFMdidgek2S


Generated by Claude Code

An email watch can carry routing rules: conditions on sender, recipient
(To, Cc, Delivered-To), subject, list or mailbox send matching messages to
another namespace, or skip them. No rules: everything goes to the watch's
namespace, as before. A preview endpoint shows where the latest messages
would go before saving.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01V3JT2ET8A1tXFMdidgek2S
@adeelahmad adeelahmad self-assigned this Oct 5, 2026
Copy link
Copy Markdown
Owner Author

Local CI: green. The self-hosted runner is down, so I replayed every PR job from .github/workflows (ci.yml, pre-commit.yml, pr-title.yml) with ci/local-ci.sh --pr 153 (#181). It tests the head merged into the latest main, which is what GitHub's pull_request event tests.

Local CI on PR #153 head 5955265 merged into main f69d6af, 2026-10-05 08:42 UTC

Job Result Time
FastAPI (embedded SurrealDB) pass 319s
FastAPI (SurrealDB server) pass 225s
Next.js pass 191s
pre-commit pass 72s
PR title pass 0s

Generated by Claude Code

@adeelahmad
adeelahmad merged commit 73166e3 into main Oct 5, 2026
5 checks passed
@adeelahmad
adeelahmad deleted the claude/project-thread-gvg3ro branch October 5, 2026 09:57
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.

2 participants

0