File tree Expand file tree Collapse file tree
app/(ee)/api/cron/partners/ban Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import { deleteDiscountCodes } from "@/lib/api/discounts/delete-discount-code" ;
2- import { reportCrossProgramBanToNetwork } from "@/lib/api/fraud/report-cross-program-ban-to-network" ;
32import { linkCache } from "@/lib/api/links/cache" ;
43import { includeTags } from "@/lib/api/links/include-tags" ;
54import { syncTotalCommissions } from "@/lib/api/partners/sync-total-commissions" ;
@@ -136,13 +135,6 @@ export const POST = withCron(async ({ rawBody }) => {
136135 deleteDiscountCodes ( links . map ( ( link ) => link . discountCode ) ) ,
137136 ] ) ;
138137
139- await reportCrossProgramBanToNetwork ( {
140- partnerId,
141- programId,
142- bannedReason : programEnrollment . bannedReason ,
143- bannedAt : programEnrollment . bannedAt ,
144- } ) ;
145-
146138 // Send email
147139 if ( partner . email ) {
148140 const program = await prisma . program . findUniqueOrThrow ( {
Original file line number Diff line number Diff line change @@ -28,46 +28,6 @@ export async function detectAndRecordFraudApplication({
2828 } ,
2929 } ) ;
3030
31- // Check if partner has been banned in other programs
32- // indicates cross-program fraud risk
33- if (
34- isFraudRuleEnabled ( {
35- fraudRules,
36- ruleType : FraudRuleType . partnerCrossProgramBan ,
37- } )
38- ) {
39- const bannedProgramEnrollments = await prisma . programEnrollment . findMany ( {
40- where : {
41- partnerId : partner . id ,
42- programId : {
43- not : program . id ,
44- } ,
45- status : "banned" ,
46- } ,
47- select : {
48- programId : true ,
49- bannedReason : true ,
50- bannedAt : true ,
51- } ,
52- } ) ;
53-
54- // Create a fraud event for each program that banned the partner
55- if ( bannedProgramEnrollments . length > 0 ) {
56- for ( const bannedEnrollment of bannedProgramEnrollments ) {
57- fraudEvents . push ( {
58- programId : program . id ,
59- partnerId : partner . id ,
60- type : FraudRuleType . partnerCrossProgramBan ,
61- sourceProgramId : bannedEnrollment . programId ,
62- metadata : {
63- bannedReason : bannedEnrollment . bannedReason ,
64- bannedAt : bannedEnrollment . bannedAt ,
65- } ,
66- } ) ;
67- }
68- }
69- }
70-
7131 // Check if partner shares the same payoutMethodHash or cryptoWalletAddress with other partners
7232 // indicates potential duplicate account fraud
7333 if (
File renamed without changes.
Original file line number Diff line number Diff line change 1+ import { prisma } from "@dub/prisma" ;
2+ import "dotenv-flow/config" ;
3+
4+ // script to remove fraud events for certain campaign ids
5+ async function main ( ) {
6+ const fraudEventsToRemove = await prisma . fraudEvent . findMany ( {
7+ where : {
8+ fraudEventGroup : {
9+ type : "partnerCrossProgramBan" ,
10+ status : "pending" ,
11+ } ,
12+ } ,
13+ } ) ;
14+
15+ console . log ( `Found ${ fraudEventsToRemove . length } fraud events to remove` ) ;
16+
17+ const deleted = await prisma . fraudEvent . deleteMany ( {
18+ where : {
19+ id : {
20+ in : fraudEventsToRemove . map ( ( event ) => event . id ) ,
21+ } ,
22+ } ,
23+ } ) ;
24+
25+ console . log ( `Removed ${ deleted . count } fraud events` ) ;
26+
27+ const fraudEventGroupsWithNoEvents = await prisma . fraudEventGroup . findMany ( {
28+ where : {
29+ type : "partnerCrossProgramBan" ,
30+ status : "pending" ,
31+ fraudEvents : {
32+ none : { } ,
33+ } ,
34+ } ,
35+ } ) ;
36+
37+ console . log (
38+ `Found ${ fraudEventGroupsWithNoEvents . length } fraud event groups with no events` ,
39+ ) ;
40+
41+ const deletedGroups = await prisma . fraudEventGroup . deleteMany ( {
42+ where : {
43+ id : {
44+ in : fraudEventGroupsWithNoEvents . map ( ( group ) => group . id ) ,
45+ } ,
46+ } ,
47+ } ) ;
48+
49+ console . log ( `Removed ${ deletedGroups . count } fraud event groups` ) ;
50+ }
51+
52+ main ( ) ;
You can’t perform that action at this time.
0 commit comments