@@ -35,11 +35,11 @@ export async function POST(request: Request) {
3535 )
3636 ] | order(relevanceScore desc) [0...${ MAX_PER_RUN - 1 } ] {
3737 _id,
38- company ,
38+ companyName ,
3939 contactName,
4040 contactEmail,
4141 website,
42- industry ,
42+ category ,
4343 relevanceScore,
4444 optOutToken
4545 }`
@@ -58,7 +58,7 @@ export async function POST(request: Request) {
5858 } )
5959 }
6060
61- const results : Array < { company : string ; success : boolean ; error ?: string } > = [ ]
61+ const results : Array < { companyName : string ; success : boolean ; error ?: string } > = [ ]
6262
6363 for ( const sponsor of sponsors ) {
6464 try {
@@ -82,36 +82,28 @@ export async function POST(request: Request) {
8282 // Create a sponsorLead with source='outbound'
8383 await sanityWriteClient . create ( {
8484 _type : 'sponsorLead' ,
85- company : sponsor . company ,
85+ companyName : sponsor . companyName ,
8686 contactName : sponsor . contactName ,
8787 contactEmail : sponsor . contactEmail ,
8888 source : 'outbound' ,
8989 status : 'contacted' ,
90- threadHistory : [
91- {
92- _key : crypto . randomUUID ( ) ,
93- date : new Date ( ) . toISOString ( ) ,
94- direction : 'outbound' ,
95- subject : email . subject ,
96- body : email . body ,
97- } ,
98- ] ,
99- lastContactedAt : new Date ( ) . toISOString ( ) ,
90+ threadId : crypto . randomUUID ( ) ,
91+ lastEmailAt : new Date ( ) . toISOString ( ) ,
10092 } )
10193
102- results . push ( { company : sponsor . company , success : true } )
103- console . log ( `[SPONSOR] Outreach sent to: ${ sponsor . company } ` )
94+ results . push ( { companyName : sponsor . companyName , success : true } )
95+ console . log ( `[SPONSOR] Outreach sent to: ${ sponsor . companyName } ` )
10496 } else {
10597 results . push ( {
106- company : sponsor . company ,
98+ companyName : sponsor . companyName ,
10799 success : false ,
108100 error : 'Email send failed' ,
109101 } )
110102 }
111103 } catch ( error ) {
112104 const errorMsg = error instanceof Error ? error . message : String ( error )
113- console . error ( `[SPONSOR] Outreach failed for ${ sponsor . company } :` , errorMsg )
114- results . push ( { company : sponsor . company , success : false , error : errorMsg } )
105+ console . error ( `[SPONSOR] Outreach failed for ${ sponsor . companyName } :` , errorMsg )
106+ results . push ( { companyName : sponsor . companyName , success : false , error : errorMsg } )
115107 }
116108 }
117109
0 commit comments