@@ -5,6 +5,7 @@ import { generateWithGemini } from "@/lib/gemini";
55import { uploadVideo , uploadShort , generateShortsMetadata } from "@/lib/youtube-upload" ;
66import { notifySubscribers } from "@/lib/resend-notify" ;
77import { postVideoAnnouncement } from "@/lib/x-social" ;
8+ import { getConfig } from "@/lib/config" ;
89
910const WEBHOOK_SECRET = process . env . SANITY_WEBHOOK_SECRET ;
1011
@@ -140,6 +141,9 @@ async function appendDistributionLog(docId: string, entries: DistributionLogEntr
140141async function runDistribution ( docId : string , doc : AutomatedVideoDoc ) : Promise < void > {
141142 const log : DistributionLogEntry [ ] = [ ] ;
142143
144+ // Fetch distribution config from Sanity singleton
145+ const distConfig = await getConfig ( "distribution_config" ) ;
146+
143147 try {
144148 await updateStatus ( docId , "uploading" ) ;
145149
@@ -197,7 +201,7 @@ async function runDistribution(docId: string, doc: AutomatedVideoDoc): Promise<v
197201 log . push ( logEntry ( "youtube-short" , "skipped" , { error : "No shortUrl" } ) ) ;
198202 }
199203
200- // Step 4: Email notification (non-fatal)
204+ // Step 4: Email notification (non-fatal) — uses distribution config
201205 console . log ( "[sanity-distribute] Step 4/6 - Sending email" ) ;
202206 const ytUrl = youtubeVideoId ? `https://www.youtube.com/watch?v=${ youtubeVideoId } ` : doc . videoUrl || "" ;
203207 try {
@@ -206,6 +210,8 @@ async function runDistribution(docId: string, doc: AutomatedVideoDoc): Promise<v
206210 videoTitle : metadata . title ,
207211 videoUrl : ytUrl ,
208212 description : metadata . description . slice ( 0 , 280 ) ,
213+ fromEmail : distConfig . resendFromEmail ,
214+ notificationEmails : distConfig . notificationEmails ,
209215 } ) ;
210216 log . push ( logEntry ( "email" , "success" ) ) ;
211217 } catch ( e ) {
0 commit comments