Skip to content

Add admin email notification preferences - #276

Merged
neuromechanist merged 2 commits into
devfrom
worktree-admin-email-options
Mar 10, 2026
Merged

neuromechanist merged 2 commits into
devfrom
worktree-admin-email-options

Conversation

@neuromechanist

Copy link
Copy Markdown
Contributor

Summary

  • Add per-admin email notification preferences (opt-in/out per category)
  • Two categories: user_approval and publication_request
  • New D1 migration (0015) adds email_preferences JSON column to users table
  • Backend: getAdminEmailsForCategory() filters recipients; at least one admin always receives each category
  • API: GET/PUT /admin/email-preferences endpoints
  • CLI: nemar admin email-preferences show/update commands
  • Fix: TEST_API_URL env var no longer leaks into manifest tests

Test plan

  • All 589 tests pass (bun test)
  • Deploy migration 0015 to D1
  • Verify nemar admin email-preferences show returns defaults (all true)
  • Verify nemar admin email-preferences update --no-user-approval disables user approval emails
  • Trigger a user signup and confirm filtered admin receives notification
  • Trigger a publication request and confirm filtered admin receives notification

@github-actions

github-actions Bot commented Mar 10, 2026 •

Copy link
Copy Markdown

📦 Package Preview

Your package is ready to test!

bun install -g nemar-cli@PR276

Version: 0.7.16-PR276.5c8feba
Commit: 5c8feba


🤖 Updated on each push.

- Add email_preferences column to users table (migration 0015)
- Add getAdminEmailsForCategory() to filter admin recipients
- Add GET/PUT /admin/email-preferences API endpoints
- Add CLI commands: nemar admin email-preferences show/update
- Wire auth and dataset routes to use filtered email lists
- Fix TEST_API_URL env var leaking into manifest tests
- Add try/catch around email send in /publish/resend endpoint
- Log corrupt email_preferences JSON instead of silently defaulting
- Log safety fallback when all admins opted out of a category
- Reuse parseEmailPreferences() and DEFAULT_EMAIL_PREFERENCES in admin routes
- Derive EmailCategory from EmailPreferences with keyof
- Distinguish missing user from missing preferences in GET handler
@neuromechanist
neuromechanist force-pushed the worktree-admin-email-options branch from f9543e2 to 5c8feba Compare March 10, 2026 01:51
@neuromechanist
neuromechanist merged commit 41906f7 into dev Mar 10, 2026
8 checks passed
@neuromechanist
neuromechanist deleted the worktree-admin-email-options branch March 10, 2026 01:52
@neuromechanist neuromechanist mentioned this pull request Mar 10, 2026
2 tasks done

This branch was previously deployed

1 inactive deployment
npm — 5c8febad Deployed Mar 10, 2026 by neuromechanist via publish #472
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant