From 5237e6352b5f822b1ea25bc4a3fa30e7f74bc768 Mon Sep 17 00:00:00 2001 From: Inferencebot Date: Wed, 4 Nov 2026 05:18:39 +0000 Subject: [PATCH] allowances: add mode=test to /admin/allowance to verify a reminder really sends --- app/main.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/app/main.py b/app/main.py index c264fcf..702cafa 100644 --- a/app/main.py +++ b/app/main.py @@ -4491,14 +4491,23 @@ async def reconcile_allowances(send: bool = False) -> dict: @app.post("/admin/allowance") @limiter.limit("10/minute") -async def admin_allowance(request: Request, mode: str = "report"): +async def admin_allowance(request: Request, mode: str = "report", to: str | None = None): """Reconcile member allowances against Open Collective payments. `mode=report` (default) changes nothing. `mode=send` performs renewals and sends the single reminder, and requires ALLOWANCE_POLICY=on on the app. Deactivation is separately gated by ALLOWANCE_DEACTIVATE=on. + `mode=test&to=
` emails one sample reminder so the copy and the + outbound path can be verified without touching the ledger. """ _verify_admin_token(request) + if mode == "test": + dest = (to or "").strip() + if not dest: + return {"refused": "mode=test needs &to=
"} + subject, text_body, html_body = payment_reminder_email("there", credit_pack_url()) + ok = send_email(dest, subject, text_body, html_body) + return {"mode": "test", "to": dest, "sent": bool(ok), "subject": subject} if mode == "send": if ALLOWANCE_POLICY != "on": return {"refused": f"ALLOWANCE_POLICY is '{ALLOWANCE_POLICY}', not 'on' — "