Skip to content

Commit

Permalink
feat: follow the person who invites the user
Browse files Browse the repository at this point in the history
  • Loading branch information
joannechen1223 committed Nov 12, 2024
1 parent 45c3a48 commit 2f213ae
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion apps/recnet-api/src/database/repository/user.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,14 +107,22 @@ export default class UserRepository {
select: user.select,
});

await prisma.inviteCode.update({
const inviteCode = await prisma.inviteCode.update({
where: { code: createUserInput.inviteCode },
data: {
usedById: userInTransaction.id,
usedAt: new Date(),
},
});

// follow the person who gave the invite code
await this.prisma.followingRecord.create({
data: {
followedById: userInTransaction.id,
followingId: inviteCode.ownerId,
},
});

return userInTransaction;
});
}
Expand Down

0 comments on commit 2f213ae

Please sign in to comment.