Skip to content

Commit 431d27c

Browse files
committed
Avoid banned users from participating in the distribution of creator program cash
1 parent 49daf7d commit 431d27c

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/server/services/creator-program.service.ts

+14-1
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ import { Flags } from '~/shared/utils';
5151
import { CashWithdrawalMethod, CashWithdrawalStatus } from '~/shared/utils/prisma/enums';
5252
import { withRetries } from '~/utils/errorHandling';
5353
import { signalClient } from '~/utils/signal-client';
54+
import { Prisma } from '@prisma/client';
5455

5556
type UserCapCacheItem = {
5657
id: number;
@@ -663,7 +664,19 @@ export async function getPoolParticipants(month?: Date) {
663664
GROUP BY userId
664665
HAVING amount > 0;
665666
`;
666-
return participants;
667+
668+
let bannedParticipants: { userId: number }[] = [];
669+
670+
if (participants.length > 0) {
671+
bannedParticipants = await dbWrite.$queryRaw<{ userId: number }[]>`
672+
SELECT "id" as "userId"
673+
FROM "User"
674+
WHERE id IN (${Prisma.join(participants.map((p) => p.userId))})
675+
AND ("bannedAt" IS NOT NULL OR onboarding & ${OnboardingSteps.BannedCreatorProgram} != 0);
676+
`;
677+
}
678+
679+
return participants.filter((p) => !bannedParticipants.some((b) => b.userId === p.userId));
667680
}
668681

669682
export const updateCashWithdrawal = async ({

0 commit comments

Comments
 (0)