From 00937e973968bfd9add8a11ed0518f77a1bee837 Mon Sep 17 00:00:00 2001 From: Luiz Henrique <7henrique18@gmail.com> Date: Wed, 16 Oct 2024 17:40:18 -0300 Subject: [PATCH] Refactor referral URL generation and implement redirection on click count increment Update referral URL generation to exclude eventId parameter Redirect to a YouTube video upon incrementing referral click count --- src/app/functions/generate-referral.ts | 2 +- src/http/routes/increment-referral-click-count.ts | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/app/functions/generate-referral.ts b/src/app/functions/generate-referral.ts index 83017b4..dcf75ab 100644 --- a/src/app/functions/generate-referral.ts +++ b/src/app/functions/generate-referral.ts @@ -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() diff --git a/src/http/routes/increment-referral-click-count.ts b/src/http/routes/increment-referral-click-count.ts index e74ee28..b12d435 100644 --- a/src/http/routes/increment-referral-click-count.ts +++ b/src/http/routes/increment-referral-click-count.ts @@ -33,7 +33,7 @@ const responseSchema = { export async function incrementReferralClickCountRoute(app: FastifyInstance) { app.withTypeProvider().route({ method: 'GET', - url: '/increment-referral-click-count', + url: '/referral', schema: { description: 'Increment referral click count', tags: ['Referral'], @@ -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') }, }) }