@@ -4,9 +4,11 @@ import { NextResponse } from 'next/server'
44import { sanityWriteClient } from '@/lib/sanity-write-client'
55import { generateOutreachEmail } from '@/lib/sponsor/gemini-outreach'
66import { sendSponsorEmail } from '@/lib/sponsor/email-service'
7- import { getConfig } from '@/lib/config'
87import type { SponsorPoolEntry } from '@/lib/sponsor/gemini-outreach'
98
9+ const MAX_PER_RUN = 5
10+ const COOLDOWN_DAYS = 14
11+
1012export async function POST ( request : Request ) {
1113 // Auth: Bearer token check against CRON_SECRET
1214 const cronSecret = process . env . CRON_SECRET ;
@@ -23,24 +25,9 @@ export async function POST(request: Request) {
2325 try {
2426 console . log ( '[SPONSOR] Starting outbound sponsor outreach cron...' )
2527
26- // Fetch sponsor config from Sanity singleton
27- const sponsorCfg = await getConfig ( "sponsor_config" ) ;
28- const maxPerRun = sponsorCfg . maxOutreachPerRun ;
29- const cooldownDays = sponsorCfg . cooldownDays ;
30-
31- // Build rate card string from config tiers
32- const rateCard = [
33- 'CodingCat.dev Sponsorship Tiers:' ,
34- ...sponsorCfg . rateCardTiers . map (
35- ( t ) => `- ${ t . name } ($${ t . price . toLocaleString ( ) } ) — ${ t . description } `
36- ) ,
37- '' ,
38- 'Our audience: 50K+ developers interested in web development, JavaScript/TypeScript, React, Next.js, and modern dev tools.' ,
39- ] . join ( '\n' ) ;
40-
4128 // Calculate the cutoff date for cooldown
4229 const cutoffDate = new Date ( )
43- cutoffDate . setDate ( cutoffDate . getDate ( ) - cooldownDays )
30+ cutoffDate . setDate ( cutoffDate . getDate ( ) - COOLDOWN_DAYS )
4431 const cutoffISO = cutoffDate . toISOString ( )
4532
4633 // Query Sanity for eligible sponsor pool entries
@@ -51,7 +38,7 @@ export async function POST(request: Request) {
5138 !defined(lastContactedAt)
5239 || lastContactedAt < $cutoffDate
5340 )
54- ] | order(relevanceScore desc) [0...${ maxPerRun - 1 } ] {
41+ ] | order(relevanceScore desc) [0...${ MAX_PER_RUN - 1 } ] {
5542 _id,
5643 companyName,
5744 contactName,
@@ -81,7 +68,7 @@ export async function POST(request: Request) {
8168 for ( const sponsor of sponsors ) {
8269 try {
8370 // Generate personalized outreach email
84- const email = await generateOutreachEmail ( sponsor , rateCard )
71+ const email = await generateOutreachEmail ( sponsor )
8572
8673 // Send the email (stubbed)
8774 const sendResult = await sendSponsorEmail (
0 commit comments