import { NextRequest, NextResponse } from 'next/server'; import nodemailer from 'nodemailer'; export async function POST(request: NextRequest) { try { const { companies, count, email } = await request.json(); const transport = nodemailer.createTransport({ host: process.env.SMTP_HOST, port: parseInt(process.env.SMTP_PORT || '587'), secure: false, auth: { user: process.env.SMTP_USER, pass: process.env.SMTP_PASS }, }); const companyList = (companies || []).slice(0, 10).map((c: string) => `
  • ${c}
  • `).join(''); const moreText = companies?.length > 10 ? `

    ...and ${companies.length - 10} more

    ` : ''; await transport.sendMail({ from: `"${process.env.SMTP_FROM_NAME || 'BroadcastBeat'}" <${process.env.SMTP_FROM_EMAIL}>`, to: email || 'ryan.salazar@relevantmediaproperties.com', subject: `[Relevant Media Properties] ${count} new company story suggestion${count !== 1 ? 's' : ''} queued`, html: `

    Relevant Media Properties

    Broadcast Beat · AV Beat — Company Story Engine

    New Company Stories Queued for Review

    The automated company story engine has queued ${count} new AI-drafted story suggestion${count !== 1 ? 's' : ''} based on company mentions in recently published articles.

    Companies Detected

    ${moreText}
    Review Story Queue →

    Manage settings at Company Tracker

    `, }); return NextResponse.json({ success: true }); } catch { return NextResponse.json({ success: false }); } }