C1: build_ping_embed set sender_id field value="" whenever sender_id was
None, which manual_share.py always passes -- Discord rejects empty embed
field values (min length 1), so every manual-share ping failed to send.
Fixed by using a zero-width space sentinel that round-trips back to ""
(raw_content) or None (sender_id) in parse_ping_embed. Added regression
tests asserting no field value is ever empty after build_ping_embed runs.
C2: raw_content over 1024 chars (Discord's embed field cap) caused
inbox.send() to raise before the UID was marked seen, so oversized emails
were retried forever and never ingested. Added a defensive hard truncation
in build_ping_embed itself, plus an explicit truncation in email_ingest.py
before the embed is built (lossy for very long emails, acceptable for MVP).
stagesForType() returned OTHER_STAGES (including 'done') for the unset
type case, but backend stages.py::valid_stages_for(None) only allows
['new'] when type is unset. This let the UI offer 'Done' as a stage
option with no type selected, which the backend rejects with 422.
Also add a watch on type that resets stage to 'new' when the current
stage is no longer valid for the newly selected type, preventing a
stale invalid stage from being silently submitted.
_extract_body previously discarded real HTML content, replacing it with
a placeholder whenever a multipart email had no text/plain part. Now
falls back to the raw text/html payload before giving up, only using
the placeholder when a message has no text-bearing part at all.
poll_mailboxes also had no error isolation: an unhandled IMAP exception
from any one mailbox would stop the discord.ext.tasks.Loop permanently,
silently killing ingestion for all three mailboxes. Each mailbox's poll
is now wrapped in try/except so one failure doesn't block the others.
Separate display snippet from raw_content: use actual message.content
for raw_content (which may be empty string) and only use the placeholder
string for the display snippet. This matches the precedent from Task 5's
ping.py where build_ping_embed must never substitute raw_content with a
placeholder, preserving the factual state of whether content was present.
- Remove 'or (empty)' fallback in build_ping_embed to preserve empty strings in raw_content
- Fix parse_ping_embed to use direct indexing for all required fields (modality, raw_content, captured_at)
- Remove unused timezone import
- Add test case for empty raw_content round-trip to catch future regressions
Fixes code review findings: empty raw_content was being converted to literal "(empty)" string,
breaking lossless round-trip requirement needed by Task 7's thread-open handler.
Wraps the Task 2 CRUD layer in a FastAPI app (schemas.py + main.py) with
POST/GET/GET-by-id/PATCH routes for items, matching the exact paths and
status codes the Discord bot's HTTP client will depend on.
Also fixes a latent bug in db.get_engine: sqlite:///:memory: without a
StaticPool gives each new session a fresh, empty database, which broke
as soon as more than one session shared an engine (the API's per-request
session pattern). Tasks 1-2 never hit this because their tests used a
single session per engine.