OpenStock icon indicating copy to clipboard operation
OpenStock copied to clipboard

Make email configuration optional

Open keshav-005 opened this issue 7 months ago β€’ 4 comments

Summary

  • stop initializing and verifying the Nodemailer transporter when email credentials are missing
  • keep welcome and news summary emails disabled until NODEMAILER_EMAIL and NODEMAILER_PASSWORD are set
  • clarify in the README that the email variables are optional for local and Docker setups

Test plan

  • npx eslint lib/nodemailer/index.ts
  • npx tsc --noEmit (currently fails on pre-existing errors in lib/inngest/functions.ts; not caused by this change)

Fixes Open-Dev-Society/OpenStock#37

Summary by CodeRabbit

  • Documentation

    • Marked email credentials as optional in configuration and Docker notes; example env entries commented out.
    • Clarified that welcome and news summary emails are disabled when credentials are omitted.
  • Bug Fixes

    • App now starts without email creds and logs clear warnings instead of erroring; email sends are skipped gracefully when not configured.
    • Email send operations and signup flow now return/propagate explicit "sent" vs "skipped" statuses so skipped emails are handled predictably.

keshav-005 avatar Apr 22 '26 14:04 keshav-005

@keshav-005 is attempting to deploy a commit to the ravixalgorithm's projects Team on Vercel.

A member of the Team first needs to authorize it.

vercel[bot] avatar Apr 22 '26 14:04 vercel[bot]

No actionable comments were generated in the recent review. πŸŽ‰

ℹ️ Recent review info
βš™οΈ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 43159aab-fe2b-4f85-9d55-2168ac016026

πŸ“₯ Commits

Reviewing files that changed from the base of the PR and between 04b5a27bf9ded2b74e2be0bb5e7a65425f1b7c22 and 101411d9d66a5f0e64ff03b6cfec419ec017ef7b.

πŸ“’ Files selected for processing (2)
  • lib/inngest/functions.ts
  • lib/nodemailer/index.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • lib/nodemailer/index.ts

πŸ“ Walkthrough

Walkthrough

The PR makes Nodemailer/Gmail credentials optional: the app can start without NODEMAILER_EMAIL/NODEMAILER_PASSWORD; when absent, transporter is null and welcome/news emails are skipped (returning a status), and README + Docker notes updated to document this behavior.

Changes

Cohort / File(s) Summary
Documentation
README.md
Clarified that NODEMAILER_EMAIL/NODEMAILER_PASSWORD are optional; commented out those vars in examples; added Docker note that omission won't prevent startup and will disable welcome/news emails.
Email Configuration
lib/nodemailer/index.ts
Introduced hasEmailConfig; export const transporter now `nodemailer.Transporter
Event Function
lib/inngest/functions.ts
sendSignUpEmail captures send-welcome-email result, logs/skips when status !== 'sent', and adjusts final return message based on emailResult.status.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant User
  participant Inngest as Inngest Function
  participant App as App/Server
  participant Nodemailer as Nodemailer/SMTP

  User->>App: POST /signup (create account)
  App->>Inngest: trigger send-welcome-email step
  Inngest->>Nodemailer: request sendWelcomeEmail
  alt transporter exists
    Nodemailer->>Nodemailer: send email via SMTP
    Nodemailer-->>Inngest: { status: "sent", messageId }
    Inngest-->>App: continue with "email sent" path
  else transporter missing
    Nodemailer-->>Inngest: { status: "skipped" }
    Inngest-->>App: continue with "email skipped" path (logged)
  end
  App-->>User: respond with signup result

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • Open-Dev-Society/OpenStock#32 β€” modifies lib/nodemailer/index.ts and sendWelcome/sendNews behavior; directly overlaps transporter/credentials handling.
  • Open-Dev-Society/OpenStock#8 β€” earlier change to lib/nodemailer/index.ts that introduced transporter behavior now adjusted here; relevant to return-shape and initialization differences.

Poem

🐰
I sniffed the env and twitch my nose,
If creds are gone, I tiptoe slow.
The app still hops, the logs can say,
"Emails paused β€” they’ll wake one day." βœ¨πŸ“§

πŸš₯ Pre-merge checks | βœ… 5
βœ… Passed checks (5 passed)
Check name Status Explanation
Description Check βœ… Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check βœ… Passed The title 'Make email configuration optional' directly and concisely describes the main change across all modified files.
Linked Issues check βœ… Passed The PR fully addresses issue #37 by making email initialization conditional, preventing errors when credentials are absent, and documenting email as optional.
Out of Scope Changes check βœ… Passed All changes directly support the objective of making email configuration optional with no unrelated modifications detected.
Docstring Coverage βœ… Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
πŸ§ͺ Generate unit tests (beta)
  • [ ] Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❀️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

coderabbitai[bot] avatar Apr 22 '26 14:04 coderabbitai[bot]

Thanks, updated. Missing email config now skips sends cleanly, and the optional .env examples are commented out so copy-paste preserves the disabled-email path.

keshav-005 avatar Apr 22 '26 15:04 keshav-005

Thanks, updated. The mailer now returns an explicit skipped/sent result, and the signup flow only logs and reports success when a welcome email is actually sent.

keshav-005 avatar Apr 22 '26 15:04 keshav-005