Compare commits
2
Commits
604fb38937
...
a04bd8dedb
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a04bd8dedb | ||
|
|
eee315fe3d |
@@ -0,0 +1,43 @@
|
||||
name: CI
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
pull_request:
|
||||
branches: [main]
|
||||
|
||||
jobs:
|
||||
lint:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: "3.13"
|
||||
- run: pip install ruff
|
||||
- run: ruff check src/
|
||||
- run: ruff format --check src/
|
||||
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: "3.13"
|
||||
cache: pip
|
||||
- run: pip install -r requirements.txt
|
||||
- name: Verify imports
|
||||
run: python -c "from src.server import mcp; print('OK:', mcp.name)"
|
||||
|
||||
docker:
|
||||
runs-on: ubuntu-latest
|
||||
needs: [lint, build]
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: docker/setup-buildx-action@v3
|
||||
- uses: docker/build-push-action@v6
|
||||
with:
|
||||
context: .
|
||||
push: false
|
||||
tags: poke-mail:test
|
||||
@@ -0,0 +1,45 @@
|
||||
name: Build & Push Container Image
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
tags: ["v*"]
|
||||
|
||||
env:
|
||||
REGISTRY: git.soconnor.dev
|
||||
IMAGE_NAME: soconnor/poke-mail
|
||||
|
||||
jobs:
|
||||
build-and-push:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
packages: write
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- uses: docker/setup-buildx-action@v3
|
||||
|
||||
- uses: docker/login-action@v3
|
||||
with:
|
||||
registry: ${{ env.REGISTRY }}
|
||||
username: ${{ gitea.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- uses: docker/metadata-action@v5
|
||||
id: meta
|
||||
with:
|
||||
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
||||
tags: |
|
||||
type=raw,value=latest,enable={{is_default_branch}}
|
||||
type=semver,pattern={{version}}
|
||||
type=semver,pattern={{major}}.{{minor}}
|
||||
type=semver,pattern={{major}}
|
||||
|
||||
- uses: docker/build-push-action@v6
|
||||
with:
|
||||
context: .
|
||||
push: true
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
+14
-4
@@ -225,6 +225,12 @@ def parse_accounts(config: dict) -> list[dict]:
|
||||
|
||||
|
||||
def resolve_account(accounts: list[dict], account_id: str) -> dict:
|
||||
# No ambiguity possible with a single configured account — use it
|
||||
# even if the caller passed an account_id that doesn't match (e.g. a
|
||||
# hallucinated or stale id), rather than hard-failing.
|
||||
if len(accounts) == 1:
|
||||
return accounts[0]
|
||||
|
||||
if not account_id or not account_id.strip():
|
||||
raise ValueError(
|
||||
f"account_id is required. Available accounts: {[a['id'] for a in accounts]}. "
|
||||
@@ -479,10 +485,14 @@ async def _forward_uid_batch(
|
||||
len(uids),
|
||||
_format_uid_list(uids),
|
||||
)
|
||||
raw_messages = await asyncio.to_thread(client.fetch, uids, ["RFC822"])
|
||||
# BODY.PEEK[] (not RFC822/BODY[]) so the fetch never implicitly sets
|
||||
# \Seen — some servers (e.g. iCloud) apply \Seen on a plain RFC822
|
||||
# fetch even when the folder was SELECTed read-only, which then queues
|
||||
# an unsolicited FETCH FLAGS response that breaks the next IDLE call.
|
||||
raw_messages = await asyncio.to_thread(client.fetch, uids, ["BODY.PEEK[]"])
|
||||
for uid in uids:
|
||||
data = raw_messages.get(uid, {})
|
||||
raw = data.get(b"RFC822", b"")
|
||||
raw = data.get(b"BODY[]", b"")
|
||||
if not raw:
|
||||
logger.debug(
|
||||
"[%s/%s] Skipping UID %s because RFC822 payload was empty",
|
||||
@@ -912,10 +922,10 @@ async def read_email(
|
||||
client = get_imap_client(acc)
|
||||
try:
|
||||
client.select_folder(folder, readonly=True)
|
||||
data = client.fetch([uid], ["RFC822"])
|
||||
data = client.fetch([uid], ["BODY.PEEK[]"])
|
||||
if uid not in data:
|
||||
return {"error": f"Email UID {uid} not found in {folder}"}
|
||||
return parse_email_message(data[uid][b"RFC822"])
|
||||
return parse_email_message(data[uid][b"BODY[]"])
|
||||
finally:
|
||||
client.logout()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user