Test

Merged
SW
4mo ago
+254-15

Summary by cubic

Make POST /api/emails easier to use by making to and subject optional. When omitted, recipients default to the account’s email(s) and the subject is derived from the body or falls back to "Message from Recoup".

  • New Features
    • to optional: resolves to the authenticated account’s email(s) via account_emails; 400 if none found.
    • subject optional: uses provided value, else first heading/line from text (or html with tags stripped), else "Message from Recoup" (capped at 120 chars).
    • Added resolveEmailSubject, firstMeaningfulLine, and stripHtml helpers; expanded validator to return resolved to and subject.
    • Unit tests for subject resolution, HTML stripping, first-line extraction, and validator paths (defaulting and errors).