Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions apps/web/app/(ee)/api/cron/partners/merge-accounts/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ export async function POST(req: Request) {
where: {
partnerId: sourcePartnerId,
fraudEventGroup: {
type: FraudRuleType.partnerDuplicatePayoutMethod,
type: FraudRuleType.partnerDuplicateAccount,
},
},
include: {
Expand Down Expand Up @@ -395,7 +395,7 @@ export async function POST(req: Request) {
]
: []),
],
type: FraudRuleType.partnerDuplicatePayoutMethod,
type: FraudRuleType.partnerDuplicateAccount,
},
resolutionReason:
"Automatically resolved because partners with duplicate payout methods were merged. No other partners share this payout method.",
Expand Down
12 changes: 1 addition & 11 deletions apps/web/lib/api/fraud/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,24 +48,14 @@ export const FRAUD_RULES: FraudRuleInfo[] = [
configurable: true,
},
{
type: "partnerDuplicatePayoutMethod",
type: "partnerDuplicateAccount",
name: "Duplicate account detected",
description:
"This partner was flagged by our system for having 2 or more Dub accounts. Please review to prevent abuse of program restrictions, caps, or bonuses.",
scope: "partner",
severity: "high",
configurable: true,
},
// Not visible in the UI
{
type: "partnerDuplicateAccount",
name: "Duplicate account detected",
description:
"This partner was flagged by our system for having 2 or more Dub accounts. Please review to prevent abuse of program restrictions, caps, or bonuses.",
scope: "partner",
severity: "low",
configurable: false,
},
{
type: "partnerEmailDomainMismatch",
name: "Email domain mismatch with website",
Expand Down
2 changes: 1 addition & 1 deletion apps/web/lib/api/fraud/detect-duplicate-identity-fraud.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export async function detectDuplicateIdentityFraud({
programEnrollments = programEnrollments.filter((enrollment) =>
isFraudRuleEnabled({
fraudRules: enrollment.program.fraudRules,
ruleType: FraudRuleType.partnerDuplicatePayoutMethod, // TODO: Change to partnerDuplicateAccount
ruleType: FraudRuleType.partnerDuplicateAccount,
}),
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ export async function detectDuplicatePayoutMethodFraud({
return;
}

// Filter out program enrollments where the partnerDuplicatePayoutMethod rule is disabled
// Filter out program enrollments where the partnerDuplicateAccount rule is disabled
programEnrollments = programEnrollments.filter((enrollment) =>
isFraudRuleEnabled({
fraudRules: enrollment.program.fraudRules,
ruleType: FraudRuleType.partnerDuplicatePayoutMethod,
ruleType: FraudRuleType.partnerDuplicateAccount,
}),
);

Expand Down Expand Up @@ -89,7 +89,7 @@ export async function detectDuplicatePayoutMethodFraud({
fraudEvents.push({
programId,
partnerId: sourcePartner.partnerId,
type: FraudRuleType.partnerDuplicatePayoutMethod,
type: FraudRuleType.partnerDuplicateAccount,
metadata: {
...(payoutMethodHash ? { payoutMethodHash } : {}),
...(cryptoWalletAddress ? { cryptoWalletAddress } : {}),
Expand Down
4 changes: 2 additions & 2 deletions apps/web/lib/api/fraud/detect-record-fraud-application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export async function detectAndRecordFraudApplication({
if (
isFraudRuleEnabled({
fraudRules,
ruleType: FraudRuleType.partnerDuplicatePayoutMethod,
ruleType: FraudRuleType.partnerDuplicateAccount,
})
) {
const { payoutMethodHash, cryptoWalletAddress } = partner;
Expand Down Expand Up @@ -81,7 +81,7 @@ export async function detectAndRecordFraudApplication({
fraudEvents.push({
programId: program.id,
partnerId: sourcePartner.id,
type: FraudRuleType.partnerDuplicatePayoutMethod,
type: FraudRuleType.partnerDuplicateAccount,
metadata: {
...(payoutMethodHash ? { payoutMethodHash } : {}),
...(cryptoWalletAddress ? { cryptoWalletAddress } : {}),
Expand Down
3 changes: 0 additions & 3 deletions apps/web/lib/api/fraud/execute-fraud-rule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ const FRAUD_RULES_REGISTRY: Record<
referralSourceBanned: checkReferralSourceBanned,
paidTrafficDetected: checkPaidTrafficDetected,
partnerCrossProgramBan: defineFraudRuleStub("partnerCrossProgramBan"),
partnerDuplicatePayoutMethod: defineFraudRuleStub(
"partnerDuplicatePayoutMethod",
),
partnerDuplicateAccount: defineFraudRuleStub("partnerDuplicateAccount"),
};

Expand Down
8 changes: 4 additions & 4 deletions apps/web/lib/api/fraud/get-partner-application-risks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export async function getPartnerApplicationRisks({
partnerId: partner.id,
status: "pending",
type: {
in: ["partnerCrossProgramBan", "partnerDuplicatePayoutMethod"],
in: ["partnerCrossProgramBan", "partnerDuplicateAccount"],
},
},
});
Expand All @@ -30,13 +30,13 @@ export async function getPartnerApplicationRisks({
(group) => group.type === "partnerCrossProgramBan",
);

const hasDuplicatePayoutMethod = fraudGroups.some(
(group) => group.type === "partnerDuplicatePayoutMethod",
const hasDuplicateAccounts = fraudGroups.some(
(group) => group.type === "partnerDuplicateAccount",
);

const risksDetected: Partial<Record<ExtendedFraudRuleType, boolean>> = {
partnerCrossProgramBan: hasCrossProgramBan,
partnerDuplicatePayoutMethod: hasDuplicatePayoutMethod,
partnerDuplicateAccount: hasDuplicateAccounts,
partnerEmailDomainMismatch: checkPartnerEmailDomainMismatch(partner),
partnerEmailMasked: checkPartnerEmailMasked(partner),
partnerNoSocialLinks: checkPartnerNoSocialLinks(partner),
Expand Down
9 changes: 4 additions & 5 deletions apps/web/lib/api/fraud/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ function getIdentityFieldsForFraudEvent({
customerId,
};

case "partnerDuplicatePayoutMethod":
case "partnerDuplicateAccount":
return {
duplicatePartnerId: eventMetadata?.duplicatePartnerId,
Expand All @@ -103,6 +102,9 @@ function getIdentityFieldsForFraudEvent({
return {
sourceProgramId,
};

default:
return {};
}
}

Expand Down Expand Up @@ -136,10 +138,7 @@ export function getPartnerIdForFraudEvent(
) {
const metadata = event.metadata as Record<string, string> | undefined;

if (
event.type === "partnerDuplicatePayoutMethod" ||
event.type === "partnerDuplicateAccount"
) {
if (event.type === "partnerDuplicateAccount") {
return metadata?.duplicatePartnerId ?? event.partnerId;
}

Expand Down
Loading
Loading