portal: stale-invite sweep skips addresses emailed in the last hour
ci/woodpecker/push/woodpecker Pipeline was canceled

An explicit resend followed by the sweep sent the same guest two identical invites.
This commit is contained in:
inference-admin committed 2026-11-17 16:13:49 +00:00
1 parent cddab4d759
commit e4d9d7bf49
1 file changed
+5
+5
View File
@@ -4738,9 +4738,14 @@ async def admin_guest_resend_stale(request: Request):
body = await request.json() if request.headers.get("content-type", "").startswith("application/json") else {} body = await request.json() if request.headers.get("content-type", "").startswith("application/json") else {}
days = int(body.get("days") or 7) days = int(body.get("days") or 7)
conn = get_db() conn = get_db()
# Skip anyone we emailed in the last hour: a single invite can otherwise be
# resent twice (an explicit resend followed by the sweep — violet@hypha.coop,
# 2026-11-17).
emails = [r[0] for r in conn.execute( emails = [r[0] for r in conn.execute(
"SELECT DISTINCT lower(g.recipient_email) FROM guests g " "SELECT DISTINCT lower(g.recipient_email) FROM guests g "
"LEFT JOIN members m ON lower(m.email) = lower(g.recipient_email) "
"WHERE g.status = 'active' AND g.created_at <= datetime('now', ?) " "WHERE g.status = 'active' AND g.created_at <= datetime('now', ?) "
"AND (m.welcome_sent_at IS NULL OR m.welcome_sent_at <= datetime('now', '-1 hour')) "
"ORDER BY g.created_at", (f"-{days} days",)).fetchall()] "ORDER BY g.created_at", (f"-{days} days",)).fetchall()]
conn.close() conn.close()
results = [] results = []