Skip to content

Commit f71aab8

Browse files
author
Miriad
committed
fix: revert changes to files outside my ownership scope
Revert sponsor-outreach, sanity-distribute, resend-notify, gemini-outreach back to dev state. These belong to @content's Phase B scope.
1 parent d75e973 commit f71aab8

File tree

4 files changed

+11
-34
lines changed

4 files changed

+11
-34
lines changed

app/api/cron/sponsor-outreach/route.ts

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@ import { NextResponse } from 'next/server'
44
import { sanityWriteClient } from '@/lib/sanity-write-client'
55
import { generateOutreachEmail } from '@/lib/sponsor/gemini-outreach'
66
import { sendSponsorEmail } from '@/lib/sponsor/email-service'
7-
import { getConfig } from '@/lib/config'
87
import type { SponsorPoolEntry } from '@/lib/sponsor/gemini-outreach'
98

9+
const MAX_PER_RUN = 5
10+
const COOLDOWN_DAYS = 14
11+
1012
export 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(

app/api/webhooks/sanity-distribute/route.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import { generateWithGemini } from "@/lib/gemini";
55
import { uploadVideo, uploadShort, generateShortsMetadata } from "@/lib/youtube-upload";
66
import { notifySubscribers } from "@/lib/resend-notify";
77
import { postVideoAnnouncement } from "@/lib/x-social";
8-
import { getConfig } from "@/lib/config";
98

109
const WEBHOOK_SECRET = process.env.SANITY_WEBHOOK_SECRET;
1110

@@ -141,9 +140,6 @@ async function appendDistributionLog(docId: string, entries: DistributionLogEntr
141140
async function runDistribution(docId: string, doc: AutomatedVideoDoc): Promise<void> {
142141
const log: DistributionLogEntry[] = [];
143142

144-
// Fetch distribution config from Sanity singleton
145-
const distConfig = await getConfig("distribution_config");
146-
147143
try {
148144
await updateStatus(docId, "uploading");
149145

@@ -210,8 +206,6 @@ async function runDistribution(docId: string, doc: AutomatedVideoDoc): Promise<v
210206
videoTitle: metadata.title,
211207
videoUrl: ytUrl,
212208
description: metadata.description.slice(0, 280),
213-
fromEmail: distConfig.resendFromEmail,
214-
notificationEmails: distConfig.notificationEmails,
215209
});
216210
log.push(logEntry("email", "success"));
217211
} catch (e) {

lib/resend-notify.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ export async function notifySubscribers(opts: {
77
videoTitle: string;
88
videoUrl: string;
99
description: string;
10-
fromEmail?: string;
11-
notificationEmails?: string[];
1210
}): Promise<{ sent: boolean; error?: string }> {
1311
const apiKey = process.env.RESEND_API_KEY;
1412
if (!apiKey) {
@@ -21,8 +19,8 @@ export async function notifySubscribers(opts: {
2119
const resend = new Resend(apiKey);
2220

2321
await resend.emails.send({
24-
from: `CodingCat.dev <${opts.fromEmail || "noreply@codingcat.dev"}>`,
25-
to: opts.notificationEmails || ["subscribers@codingcat.dev"],
22+
from: "CodingCat.dev <noreply@codingcat.dev>",
23+
to: ["subscribers@codingcat.dev"], // TODO: fetch subscriber list
2624
subject: opts.subject,
2725
html: `
2826
<h1>${opts.videoTitle}</h1>

lib/sponsor/gemini-outreach.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { GoogleGenerativeAI } from '@google/generative-ai'
2-
import { getConfigValue } from '@/lib/config'
32

43
export interface SponsorPoolEntry {
54
_id: string
@@ -17,7 +16,7 @@ export interface OutreachEmail {
1716
body: string
1817
}
1918

20-
const DEFAULT_RATE_CARD = `
19+
const RATE_CARD = `
2120
CodingCat.dev Sponsorship Tiers:
2221
- Dedicated Video ($4,000) — Full dedicated video about your product
2322
- Integrated Mid-Roll Ad ($1,800) — Mid-roll advertisement in our videos
@@ -34,7 +33,7 @@ Our audience: 50K+ developers interested in web development, JavaScript/TypeScri
3433
*/
3534
export async function generateOutreachEmail(
3635
sponsor: SponsorPoolEntry,
37-
rateCard: string = DEFAULT_RATE_CARD
36+
rateCard: string = RATE_CARD
3837
): Promise<OutreachEmail> {
3938
const apiKey = process.env.GEMINI_API_KEY
4039
if (!apiKey) {
@@ -43,8 +42,7 @@ export async function generateOutreachEmail(
4342
}
4443

4544
const genAI = new GoogleGenerativeAI(apiKey)
46-
const geminiModel = await getConfigValue("pipeline_config", "geminiModel", "gemini-2.0-flash");
47-
const model = genAI.getGenerativeModel({ model: geminiModel })
45+
const model = genAI.getGenerativeModel({ model: process.env.GEMINI_MODEL || 'gemini-2.5-flash' })
4846

4947
const optOutUrl = sponsor.optOutToken
5048
? `${process.env.NEXT_PUBLIC_URL || 'https://codingcat.dev'}/api/sponsor/opt-out?token=${sponsor.optOutToken}`

0 commit comments

Comments
 (0)