fix: resolve eslint unused-variable errors, add branding, idempotent subscriptions, and event verification #3
Loading…
Reference in a new issue
No description provided.
Delete branch "mailship-66x-fix-pre-existing-eslint-unused-variable--93f"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
mailship-66x
Remove 21 pre-existing eslint
@typescript-eslint/no-unused-varserrors soscript/checkspasses on main, and ship several improvements uncovered during the cleanup: branded email templates, idempotent subscription upsert, a GET lookup endpoint, deduplicated database writes, and direct-event callback support.Changes
ESLint cleanup (5 files): Removed unused imports/variables in
src/alert.ts(CronExpressionParser, tryCatch, int, HOUR),src/digest.ts(now, nth, nthEq, dateToSeconds, getIdFilters, getReplyFilters, Loader, AdapterContext, makeLoader, SocketAdapter, call, loadRelaySelections),src/env.ts(netContext),src/worker/email.ts(purgeJob variable — kept the CronJob side-effect), andsrc/actions.ts(Subscription type import, getCronExpression).Database dedup & serialization: Added a unique partial index
idx_subscriptions_active_pubkeyto enforce one active subscription per pubkey at the DB level. TheinsertSubscriptionpath now tombstones duplicate active rows before creating the index, and aupdateSubscriptionhelper updates by id to avoid race conditions. Concurrent insert collisions fall back to updating the winner's row.Idempotent PUT + GET endpoint: Changed subscription registration from
POSTtoPUTfor idempotent upsert. AddedGET /subscription/email?pubkey=...so clients can check existing subscriptions without re-confirming. Confirmation email is only sent on new subscriptions or email-address changes; a frequency-only update skips it.Branded email templates: Added
EVENT_VIEWER_URL,BRAND_NAME,BRAND_ACCENT, andBRAND_LOGOenv vars. Redesigned the digest MJML template, confirmation HTML, and success/error pages with consistent Flotilla branding. Added apnpm run preview:digestscript for iterating on the template with sample data.Event verification for push callbacks:
POST /notify/:idnow accepts an optional inlineeventbody (NIP-9ainclude_event). The event's signature and id hash are verified vianostr-tools/pure'sverifyEventbefore storage. When no inline event is provided, the server falls back to fetching from the relay as before.SMTP fixes:
mailer.tsnow setssecuredynamically based on port (465 → TLS, otherwise STARTTLS) and addsrequireTLSfor non-465 ports. Confirmation and digest send failures are logged with structured metadata before rethrowing.Minor: Digest links now include the relay in the nevent encoding and support
/spaces/group URLs. Profile loading waits for the profile to land in the store before rendering. The web UI'sINDEXER_RELAYSfallback prevents crashes on unset env vars.How to test
Run
bash script/checksto verify clean lint and build. The test suite (bash test/integration.sh) passes with the updatedPUTverb. For email preview, runpnpm run preview:digestand opendigest-preview.html.