Skip to content

Commit

Permalink
fix: dont get points for joining your own fissa
Browse files Browse the repository at this point in the history
  • Loading branch information
xiduzo committed Jun 22, 2024
1 parent 79f2d12 commit 7d1c346
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
12 changes: 11 additions & 1 deletion packages/api/src/service/BadgeService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,22 @@ export class BadgeService extends ServiceWithContext {
}
}

async joinedFissa() {
async joinedFissa(pin: string) {
const userId = this.session?.user.id
if (!userId) return

try {
await this.db.$transaction(async transaction => {
const fissa = await transaction.fissa.findUnique({
where: { pin },
select: { by: { select: { accounts: { select: { userId: true } } } } }
})

if (fissa?.by?.accounts[0]?.userId === userId) {
return
}


const point = await transaction.badges.findUnique({
where: { userId_name: { userId, name: BADGE.FISSAS_JOINED } }
})
Expand Down
2 changes: 1 addition & 1 deletion packages/api/src/service/FissaService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export class FissaService extends ServiceWithContext {
create: { pin, userId },
update: {},
});
await this.badgeService.joinedFissa()
await this.badgeService.joinedFissa(pin)
}

return fissa;
Expand Down

0 comments on commit 7d1c346

Please sign in to comment.