/** * Correction email for Paul Wilson - the earlier "next steps" email wrongly said * "no action is required." His MCS-150 and UCR DO require him to complete the * intake form (and the MCS-150 needs his signature, since it's a perjury * certification we never auto-submit). This sends the correct intake links. * CC justin@performancewest.net. * * Run: docker exec performancewest-api-1 node /app/scripts/rescue-paul-correct.mjs */ import pg from "pg"; import nodemailer from "nodemailer"; const EMAIL = "synthetic@pipeline.com"; const CC = "justin@performancewest.net"; const NAME = "Paul Wilson"; const COMPANY = "Compound Technologies, Inc"; const SITE = process.env.DOMAIN ? `https://${process.env.DOMAIN}` : "https://performancewest.net"; const pool = new pg.Pool({ connectionString: process.env.DATABASE_URL }); const mailer = nodemailer.createTransport({ host: process.env.SMTP_HOST || "co.carrierone.com", port: parseInt(process.env.SMTP_PORT || "587", 10), secure: false, auth: { user: process.env.SMTP_USER, pass: process.env.SMTP_PASS }, }); const FROM = process.env.SMTP_FROM || "Performance West "; const firstName = NAME.split(" ")[0]; const { rows } = await pool.query( `SELECT order_number, service_name, service_slug, COALESCE(intake_data_validated,false) AS done FROM compliance_orders WHERE customer_email=$1 ORDER BY created_at`, [EMAIL], ); const items = rows.map(o => { const url = `${SITE}/order/${o.service_slug}?order=${o.order_number}`; const note = o.service_slug === "mcs150-update" ? " (we will prepare the filing from your intake, then send it to you to sign before we submit to FMCSA)" : ""; return `
  • ${o.service_name} (${o.order_number})${note}
  • `; }).join(""); await mailer.sendMail({ from: FROM, to: EMAIL, cc: CC, subject: "Correction: please complete your intake forms to start your filings", html: `

    Quick correction - one step needed from you

    Hi ${firstName}, apologies - my previous email said no action was needed. That was not correct. To begin your filings for ${COMPANY}, please complete the short intake form for each service below (about 2-5 minutes each). We cannot start a filing until its intake is done.

    For the MCS-150 Biennial Update, after you complete intake we prepare the update and send it to you to review and sign - we never submit a certification to FMCSA without your signature. The Drug & Alcohol program binder is delivered to you to review and adopt once its intake is complete.

    If you have not set your portal password yet, use the link in the separate "Set your password" email so you can log in and track everything. Questions? Reply here or call 1-888-411-0383.

    Performance West Inc. · performancewest.net · 1-888-411-0383

    `, text: `Hi ${firstName}, correction: my earlier email wrongly said no action was needed. Please complete the intake form for each service to start your filings:\n` + rows.map(o => `- ${o.service_name} (${o.order_number}): ${SITE}/order/${o.service_slug}?order=${o.order_number}`).join("\n") + `\nThe MCS-150 will be sent to you to sign before we submit to FMCSA. Questions? 1-888-411-0383.`, }); console.log(`[correct] sent correction with intake links to ${EMAIL} (cc ${CC}) for ${rows.length} orders`); await pool.end();