Skip to content

Commit db1fbf2

Browse files
committed
Add sms pumping check
1 parent 8c57167 commit db1fbf2

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

src/app/api/kioskOrder/route.ts

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,21 +48,32 @@ export async function POST(request: Request) {
4848

4949
// 1. Validate user input
5050
const lookupService = await getLookupService();
51-
const lookupResult = await lookupService.phoneNumbers(data.phone).fetch();
51+
const lookupResult = await lookupService
52+
.phoneNumbers(data.phone)
53+
.fetch({ fields: "sms_pumping_risk" });
5254
if (!data.phone || !data?.item?.title || !data.event) {
5355
return new Response("Missing required fields", {
5456
status: 400,
5557
statusText: "Missing required fields",
5658
});
5759
}
5860

59-
// TODO potentially check sms_pumping_risk here
6061
if (!lookupResult.valid) {
6162
return new Response("Phone number is invalid", {
6263
status: 400,
6364
statusText: "Phone number is invalid",
6465
});
6566
}
67+
if (lookupResult?.smsPumpingRisk?.sms_pumping_risk_score >= 60) {
68+
return new Response(
69+
"Phone number is at high risk of SMS pumping. Please try again later.",
70+
{
71+
status: 400,
72+
statusText:
73+
"Phone number is at high risk of SMS pumping. Please try again later.",
74+
},
75+
);
76+
}
6677

6778
// 2. Fetch event data
6879
const syncService = await getSyncService();
@@ -80,7 +91,9 @@ export async function POST(request: Request) {
8091
}
8192

8293
// 3. Create new conversation
83-
const sender = data.whatsapp ? `whatsapp:${lookupResult.phoneNumber}` : lookupResult.phoneNumber;
94+
const sender = data.whatsapp
95+
? `whatsapp:${lookupResult.phoneNumber}`
96+
: lookupResult.phoneNumber;
8497
const participantConversations = await getConversationsOfSender(sender);
8598
const activeConversations = participantConversations.filter(
8699
(conv) => conv.conversationState === "active",

0 commit comments

Comments
 (0)