Skip to content

feat(help): add mentor assignment email notification#202

Open
asthasinghcs wants to merge 3 commits into
Coder-s-OG-s:mainfrom
asthasinghcs:feat/help-dispatch-email
Open

feat(help): add mentor assignment email notification#202
asthasinghcs wants to merge 3 commits into
Coder-s-OG-s:mainfrom
asthasinghcs:feat/help-dispatch-email

Conversation

@asthasinghcs
Copy link
Copy Markdown
Contributor

@asthasinghcs asthasinghcs commented May 22, 2026

Summary

  • add reusable Resend email utility
  • send mentor notification email after help request assignment
  • add RESEND_API_KEY to .env.example
  • add tests for email utility
  • gracefully handle email delivery failures without breaking help dispatch flow

Testing

  • npm run lint
  • npm run build

Closes #54

@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented May 22, 2026

@asthasinghcs is attempting to deploy a commit to the codersogs-3057's projects Team on Vercel.

A member of the Team first needs to authorize it.

@Soumya-codr
Copy link
Copy Markdown
Collaborator

@asthasinghcs Your tests are failing please revisit it and pass all the checks please

@Piyush-Thakkarr
Copy link
Copy Markdown
Collaborator

hey @asthasinghcs, thanks for picking this up. ran through the diff and there are a few blockers that'll stop this from working end-to-end. flagging them so you can fix in one pass.

1. resend package isn't in package.json. import { Resend } from 'resend' in src/lib/email.ts will fail to build. you need npm install resend (or pnpm/yarn equivalent) and commit the lockfile change. that's why local lint/build may have passed for you but CI build will explode.

2. profiles.email column doesn't exist. in src/inngest/functions/help-dispatch.ts:46 you do .select('id, level, primary_language, github_handle, email') , but email isn't a column on profiles in src/lib/db/schema.ts. PostgREST will return a 400 at runtime and mentor?.email will always be undefined, so the email branch is dead code. options:

  • add an email text column on profiles via a new migration, populate from auth.users.email at signup
  • or fetch via the service-role auth admin API: sb.auth.admin.getUserById(target.userId) per target

go with whichever fits the broader plan, but the column path is simpler if profiles already mirror auth identity.

3. unescaped user input in the email HTML. ${helpReason} in src/lib/email.ts:48 is interpolated raw. helpReason comes from help_requests.reason which is contributor-typed free text. if someone writes <script> or <img onerror=...> it ships verbatim. minor since most email clients sandbox, but trivial to fix , escape &<>"' before interpolation, or use a small template helper. same logic should apply to mentorHandle, menteeHandle, prUrl defensively even though GitHub handles can't contain those chars today.

4. test coverage is thin. src/lib/email.test.ts only asserts the skip-when-unconfigured branch. once 1+2 are fixed, add at least:

  • a test that asserts the html escapes a <script> reason
  • a test that asserts from and subject are set
  • mock the resend client so the send-path is actually exercised

once 1 and 2 are sorted the feature will actually run. happy to look again once you push.

@asthasinghcs
Copy link
Copy Markdown
Contributor Author

hi @Piyush-Thakkarr and @Soumya-codr apologies for the delay, i will fix the issues right away!

@asthasinghcs
Copy link
Copy Markdown
Contributor Author

@Piyush-Thakkarr Thanks for the review.

You're right, I checked the schema and profiles.email does not exist. The original issue mentions sending an email notification after mentor assignment, but I don't see a persisted mentor email field or an existing Supabase admin-auth lookup pattern in the repository.

Before I update the implementation, could you confirm the preferred source for mentor emails?

  • add a profile email field via migration
  • fetch from Supabase auth users
  • another existing source I may have missed

I'll update the implementation accordingly and address the escaping/tests feedback in the same pass.

@Ayush-Patel-56
Copy link
Copy Markdown
Collaborator

CI failing, can you please fix it

@asthasinghcs
Copy link
Copy Markdown
Contributor Author

@Piyush-Thakkarr @Ayush-Patel-56

CI issue has been addressed by adding the missing resend dependency and resolving the package-lock conflict with the latest main.

Regarding the review feedback, I verified that profiles.email does not currently exist in the schema and I could not find an existing auth-admin lookup pattern in the repository.

Before making schema/auth changes, could you please confirm the preferred source for mentor emails?

  • add a profile email field via migration
  • fetch from Supabase auth users
  • another existing source in the project

I'd like to align with the intended architecture and address the remaining review feedback in the same update.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add email notification when a contributor is assigned a help request

4 participants