feat: rename notifications command to emails (re-point to POST /api/emails)

Merged
SW
4mo ago
+49-34

Re-points the CLI notifications command from the soon-to-be-removed POST /api/notifications to POST /api/emails, as part of the chat#1815 cleanup.

Why

POST /api/notifications is being deleted (api#711 / docs#253). With to now optional on POST /api/emails — defaulting to the account's own email when omitted (api#710 / docs#252) — the notifications command keeps its exact self-send behavior by posting to /api/emails with no to.

What changed (src/commands/notifications.ts)

  • post("/api/notifications", body) → post("/api/emails", body).
  • --room-id flag → --chat-id; body key room_id → chat_id (matches the /api/emails contract).
  • No --to flag — omitting to triggers the account-own-email default, preserving "send to the account owner".

The command name (notifications) and all other flags (--subject, --text, --html, --cc, --account, --json) are unchanged.

Tests (TDD, RED→GREEN)

Updated __tests__/commands/notifications.test.ts to expect /api/emails + chat_id. pnpm test → 74 passed (12 files); pnpm build (tsup) succeeds; grep for room_id/api/notifications in src is clean.

Sequencing

Requires api#710 (to-optional) live, and should merge before/with api#711 (the /api/notifications deletion) so the command never breaks.

🤖 Generated with Claude Code


Summary by cubic

Renames the CLI command to emails and switches it from POST /api/notifications to POST /api/emails to keep self-send behavior. Also renames --room-id to --chat-id and makes --subject optional to match the emails API.

  • Migration
    • Use recoup emails instead of recoup notifications (no alias).
    • Replace --room-id with --chat-id in any scripts.
    • Requires the API change where POST /api/emails supports optional to.

Summary by CodeRabbit

  • New Features

    • Added an emails CLI command for sending emails.
    • Supports optional subject lines, HTML/text content, CC recipients, chat linking, and account selection.
    • Default success message now says “Email sent.”
  • Bug Fixes

    • Updated request handling so email-specific fields are only included when provided.
    • Switched command output and error handling to match the new email workflow.
  • Tests

    • Updated automated coverage to reflect the new emails command and its request behavior.