@@ -48,7 +48,7 @@ export async function POST(request: Request) {
48
48
49
49
// 1. Validate user input
50
50
const lookupService = await getLookupService ( ) ;
51
- const phoneNumber = await lookupService . phoneNumbers ( data . phone ) . fetch ( ) ;
51
+ const lookupResult = await lookupService . phoneNumbers ( data . phone ) . fetch ( ) ;
52
52
if ( ! data . phone || ! data ?. item ?. title || ! data . event ) {
53
53
return new Response ( "Missing required fields" , {
54
54
status : 400 ,
@@ -57,7 +57,7 @@ export async function POST(request: Request) {
57
57
}
58
58
59
59
// TODO potentially check sms_pumping_risk here
60
- if ( ! phoneNumber . valid ) {
60
+ if ( ! lookupResult . valid ) {
61
61
return new Response ( "Phone number is invalid" , {
62
62
status : 400 ,
63
63
statusText : "Phone number is invalid" ,
@@ -80,7 +80,7 @@ export async function POST(request: Request) {
80
80
}
81
81
82
82
// 3. Create new conversation
83
- const sender = data . whatsapp ? `whatsapp:${ data . phone } ` : data . phone ;
83
+ const sender = data . whatsapp ? `whatsapp:${ lookupResult . phoneNumber } ` : lookupResult . phoneNumber ;
84
84
const participantConversations = await getConversationsOfSender ( sender ) ;
85
85
const activeConversations = participantConversations . filter (
86
86
( conv ) => conv . conversationState === "active" ,
@@ -108,7 +108,7 @@ export async function POST(request: Request) {
108
108
// 4. Add attendee to sync list
109
109
// incorrect but doesn't matter for this single-use event, should check if attendee is already in list
110
110
try {
111
- const country = getCountryFromPhone ( data . phone ) ;
111
+ const country = getCountryFromPhone ( lookupResult . phoneNumber ) ;
112
112
await updateOrCreateSyncMapItem (
113
113
NEXT_PUBLIC_ACTIVE_CUSTOMERS_MAP ,
114
114
conversationSid ,
0 commit comments