← back to Dw Signup Fulfillment

send-kelly-shipped-note.js.PARKED-2026-09-10-steve-stop-sending

68 lines

#!/usr/bin/env node
'use strict';
// TK-10836 — the ONE short, TRUE note to Kelly. Send only AFTER the draft order is
// Completed, so every sentence in it is already true at send time.
//
// Differs deliberately from the retired send-kelly-reply.js (moved to void-superseded):
//   • no code, no checkout instruction, no "you'll pay nothing" — nothing for her to do
//   • no re-marketing (compliance rail)
//   • no_source_tag:true → suppresses George's "From job:" banner that leaked into all
//     4 of the 2026-09-02 sends (TK-11365)
//
//   DRY RUN default:  node send-kelly-shipped-note.js
//   LIVE:             DRY_RUN=0 node send-kelly-shipped-note.js

const fs = require('fs');
const path = require('path');
const config = require('./lib/config');

const SENT_FLAG = path.join(__dirname, '.kelly-shipped-note.sent');
if (fs.existsSync(SENT_FLAG) && process.env.FORCE_RESEND !== '1') {
  console.error('ABORT: this note was already sent (.kelly-shipped-note.sent). FORCE_RESEND=1 to override.');
  process.exit(1);
}

const to = 'kyounge@umich.edu';
const subject = 'Re: Your Designer Wallcoverings samples — on their way';
const html = [
  '<p>Hi Kelly,</p>',
  '<p>Short version: your three swatches are on their way, and you owe nothing. ' +
  'There is nothing for you to do — no code, no checkout.</p>',
  '<p>You were right about the $25. That was our shipping charge, and my earlier note ' +
  'telling you it wouldn\'t apply was wrong. Rather than send you back to the checkout ' +
  'a third time, we\'ve simply sent the samples:</p>',
  '<ul><li>Brushed Finesse Pewter</li><li>Shimmer Polar White</li><li>Finesse Metallic Rose</li></ul>',
  '<p>They\'re going to 2300 Sun Valley Drive in Ann Arbor — just reply if that\'s no longer right ' +
  'and I\'ll redirect them.</p>',
  '<p>Sorry it took this long, and sorry for the repeated emails on our end.</p>',
  '<p>— Designer Wallcoverings<br>DesignerWallcoverings.com · (888) 373-4564</p>',
].join('\n');

(async () => {
  const dry = process.env.DRY_RUN !== '0';
  if (dry) {
    console.log('DRY RUN — nothing sent. Set DRY_RUN=0 to send.\n');
    console.log('to:', to, '\nsubject:', subject, '\n');
    console.log(html.replace(/<[^>]+>/g, ''));
    return;
  }
  const payload = {
    account: config.GEORGE_ACCOUNT,
    from: config.GEORGE_FROM,
    to, subject, body: html,
    source: 'kelly-shipped-note-tk10836',
    no_source_tag: true,          // TK-11365 — keep the internal job label out of customer mail
    message_class: 'transactional',
  };
  const r = await fetch(`${config.GEORGE_URL}/api/send`, {
    method: 'POST',
    headers: { 'Content-Type': 'application/json', 'Authorization': config.GEORGE_AUTH },
    body: JSON.stringify(payload),
  });
  const j = await r.json().catch(() => ({}));
  console.log('send result:', r.status, JSON.stringify(j).slice(0, 300));
  if (r.status !== 200) { console.error('SEND FAILED — not marking sent.'); process.exit(1); }
  fs.writeFileSync(SENT_FLAG, new Date().toISOString() + '\n');
  console.log('SENT to ' + to);
})().catch(e => { console.error('error:', e.message); process.exit(1); });