Skip to content

Commit

Permalink
Refactor referral URL generation and implement redirection on click c…
Browse files Browse the repository at this point in the history
…ount increment

Update referral URL generation to exclude eventId parameter
Redirect to a YouTube video upon incrementing referral click count
  • Loading branch information
lui7henrique committed Oct 16, 2024
1 parent df59a1b commit 00937e9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/app/functions/generate-referral.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export async function generateReferral({
}

const token = randomBytes(16).toString('hex')
const url = `${process.env.BASE_URL}/referral?token=${token}&eventId=${eventId}`
const url = `${process.env.BASE_URL}/referral?token=${token}`

const [subscription] = await db
.select()
Expand Down
6 changes: 4 additions & 2 deletions src/http/routes/increment-referral-click-count.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const responseSchema = {
export async function incrementReferralClickCountRoute(app: FastifyInstance) {
app.withTypeProvider<ZodTypeProvider>().route({
method: 'GET',
url: '/increment-referral-click-count',
url: '/referral',
schema: {
description: 'Increment referral click count',
tags: ['Referral'],
Expand All @@ -55,7 +55,9 @@ export async function incrementReferralClickCountRoute(app: FastifyInstance) {
}
}

return reply.status(200).send({ referral: result.right.referral })
return reply
.status(302)
.redirect('https://www.youtube.com/watch?v=dQw4w9WgXcQ')
},
})
}

0 comments on commit 00937e9

Please sign in to comment.