테스트 메일 수신자 제한
This commit is contained in:
parent
3bf38c50df
commit
1274ba9ccc
5 changed files with 35 additions and 8 deletions
|
|
@ -184,12 +184,12 @@ async def enqueue_admin_test_email(
|
|||
actor_user_id: str | None = None,
|
||||
actor_email: str = "",
|
||||
) -> int:
|
||||
"""Queue one explicit admin test email through the normal delivery path."""
|
||||
"""Queue one explicit super-admin test email through the normal delivery path."""
|
||||
payload = {
|
||||
"requested_by": actor_email,
|
||||
"notifications_url": _frontend_url("/admin"),
|
||||
}
|
||||
recipients = await _admin_approval_recipients()
|
||||
recipients = await _super_admin_recipients()
|
||||
await _enqueue_event(
|
||||
kind="admin_test_email",
|
||||
idempotency_key=f"admin_test_email:{uuid4()}",
|
||||
|
|
@ -349,6 +349,33 @@ async def _admin_approval_recipients() -> list[NotificationRecipient]:
|
|||
return [_recipient_from_row(row) for row in rows]
|
||||
|
||||
|
||||
async def _super_admin_recipients() -> list[NotificationRecipient]:
|
||||
super_admin_emails = sorted({_normalize_email(value) for value in settings.auth_super_admin_emails})
|
||||
if not super_admin_emails:
|
||||
return []
|
||||
async with acquire(role="admin") as conn:
|
||||
rows = await conn.fetch(
|
||||
"""
|
||||
SELECT DISTINCT
|
||||
u.user_id,
|
||||
u.email,
|
||||
COALESCE(NULLIF(u.display_name, ''), u.email) AS display_name,
|
||||
u.role
|
||||
FROM app.app_user u
|
||||
LEFT JOIN app.user_preferences p ON p.user_id = u.user_id
|
||||
WHERE u.is_active
|
||||
AND u.account_status = 'approved'
|
||||
AND u.email IS NOT NULL
|
||||
AND u.email <> ''
|
||||
AND lower(u.email) = ANY($1::text[])
|
||||
AND COALESCE((p.notifications->>'account_approval')::boolean, true)
|
||||
ORDER BY u.email
|
||||
""",
|
||||
super_admin_emails,
|
||||
)
|
||||
return [_recipient_from_row(row) for row in rows]
|
||||
|
||||
|
||||
async def _session_review_payload_and_recipients(
|
||||
session_id: str,
|
||||
) -> tuple[dict[str, Any] | None, list[NotificationRecipient]]:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue