allowances: add mode=test to /admin/allowance to verify a reminder really sends
This commit is contained in:
1 parent
f68e4fb652
commit
5237e6352b
1 file changed
+10
-1
+10
-1
@@ -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=<address>` 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=<address>"}
|
||||
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' — "
|
||||
|
||||
Reference in new issue
Block a user