fix(launch-flow): send welcome email on free /accept-invite activation

Free invite acceptance previously created a Member and signed them in
without sending the welcome email — pre-registrants got nothing as the
join confirmation. Wire sendWelcomeEmail into the free branch matching
the pattern in members/create.post.js.

Paid /accept-invite activations continue to receive the welcome email
via /api/helcim/subscription on the pending_payment → active transition,
so this only changes the free path.
This commit is contained in:
Jennie Robinson Faber 2026-04-30 14:40:13 +01:00
parent 313b8598df
commit d4000c18cf

View file

@ -5,6 +5,7 @@ import { connectDB } from '../../utils/mongoose.js'
import { setAuthCookie } from '../../utils/auth.js'
import { assignMemberNumber } from '../../utils/memberNumber.js'
import { createHelcimCustomer } from '../../utils/helcim.js'
import { sendWelcomeEmail } from '../../utils/resend.js'
export default defineEventHandler(async (event) => {
const body = await validateBody(event, inviteAcceptSchema)
@ -88,6 +89,15 @@ export default defineEventHandler(async (event) => {
// For free tier, redirect to welcome
if (body.contributionAmount === 0) {
await autoFlagPreExistingSlackAccess(member)
try {
await sendWelcomeEmail(member)
logActivity(member._id, 'email_sent', {
emailType: 'welcome',
subject: 'Welcome to Ghost Guild'
})
} catch (emailError) {
console.error('Failed to send welcome email:', emailError)
}
return {
success: true,
requiresPayment: false,