Spaces:
Sleeping

File size: 3,396 Bytes
a87217c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
"""
One-off: send a correction/retraction note for the 18 June LGR report.
Internal only. Recipients passed as "Name:email" args.
"""

from __future__ import annotations

import sys
from pathlib import Path

REPO_ROOT = Path(__file__).resolve().parent.parent
sys.path.insert(0, str(REPO_ROOT))

try:
    from dotenv import load_dotenv
    load_dotenv(REPO_ROOT / ".env", override=False)
except ImportError:
    pass

import mailer
import weekly_digest

DRY_RUN = "--dry-run" in sys.argv

SUBJECT = "Correction — LGR report (18 June): decision dates were wrong"


def _html(name: str) -> str:
    try:
        fb = weekly_digest._feedback_prompt_html(recipient_name=name)
    except Exception:
        fb = ""
    return f"""
    <div style="font-family:Calibri,Arial,sans-serif;max-width:640px;margin:0 auto;">
      <h2 style="color:#b71c1c;border-bottom:2px solid #b71c1c;padding-bottom:6px;">
        ⚠️ Correction — LGR report (18 June)</h2>
      <p>Hi {name},</p>
      <p>Please <strong>disregard the decision-timing claims</strong> in the LGR
      landscape report I sent earlier today. It stated that several counties —
      including Oxfordshire — had ministerial decisions in March 2026.
      <strong>That is incorrect. No LGR decisions have been made yet.</strong></p>
      <p>The verified position (Oxfordshire County Council / GOV.UK):</p>
      <ul style="font-size:0.92em;color:#333;">
        <li>Proposals were submitted on <strong>27 November 2025</strong>.</li>
        <li>What happened in <strong>February–March 2026 was the statutory
        consultation</strong> — not a decision.</li>
        <li>The government decision is expected <strong>by mid-July 2026</strong>
        (before Parliament's summer recess on 16 July).</li>
        <li>Shadow elections would follow in May 2027, new unitaries April 2028.</li>
      </ul>
      <p style="font-size:0.92em;color:#333;">More broadly: please treat the
      <strong>specific named contacts, notice numbers and unitary counts</strong>
      in that report as <strong>unverified</strong> until checked against source.
      The warm-route mapping (Sandy Walkington, Peter Shakespear) and the overall
      opportunity framing stand; the dated specifics do not.</p>
      <p style="font-size:0.92em;color:#333;">We're reworking the report generator
      so every claim is tied to a citable source before it goes out. Apologies for
      the error.</p>
      <p>Best,<br>Curium Lead Intelligence</p>
      {fb}
    </div>"""


def main() -> int:
    recipients = []
    for arg in sys.argv[1:]:
        if arg.startswith("--") or ":" not in arg:
            continue
        name, email = arg.split(":", 1)
        recipients.append((name.strip(), email.strip()))
    if not recipients:
        print("No recipients. Pass 'Name:email' args.")
        return 1

    sent = []
    for name, email in recipients:
        if DRY_RUN:
            print(f"  [dry-run] correction → {name} <{email}>")
            sent.append(name)
            continue
        r = mailer.send(to_email=email, subject=SUBJECT, html=_html(name))
        if r.get("success"):
            print(f"  ✓ {name} → {email}")
            sent.append(name)
        else:
            print(f"  ✗ {name} → {r.get('message')}")
    print(f"\nSent to: {sent}")
    return 0


if __name__ == "__main__":
    raise SystemExit(main())