kin: BATON-008-backend_dev
This commit is contained in:
parent
36087c3d9e
commit
fde7f57a7a
5 changed files with 48 additions and 20 deletions
|
|
@ -22,7 +22,7 @@ WEBHOOK_ENABLED: bool = os.getenv("WEBHOOK_ENABLED", "true").lower() == "true"
|
|||
FRONTEND_ORIGIN: str = os.getenv("FRONTEND_ORIGIN", "http://localhost:3000")
|
||||
APP_URL: str | None = os.getenv("APP_URL") # Публичный URL приложения для keep-alive self-ping
|
||||
ADMIN_TOKEN: str = _require("ADMIN_TOKEN")
|
||||
ADMIN_CHAT_ID: str = os.getenv("ADMIN_CHAT_ID", "5694335584")
|
||||
ADMIN_CHAT_ID: str = _require("ADMIN_CHAT_ID")
|
||||
VAPID_PRIVATE_KEY: str = os.getenv("VAPID_PRIVATE_KEY", "")
|
||||
VAPID_PUBLIC_KEY: str = os.getenv("VAPID_PUBLIC_KEY", "")
|
||||
VAPID_CLAIMS_EMAIL: str = os.getenv("VAPID_CLAIMS_EMAIL", "")
|
||||
|
|
|
|||
|
|
@ -341,9 +341,10 @@ async def get_registration(reg_id: int) -> Optional[dict]:
|
|||
|
||||
|
||||
async def update_registration_status(reg_id: int, status: str) -> bool:
|
||||
"""Update registration status only if currently 'pending'. Returns False if already processed."""
|
||||
async with _get_conn() as conn:
|
||||
async with conn.execute(
|
||||
"UPDATE registrations SET status = ? WHERE id = ?",
|
||||
"UPDATE registrations SET status = ? WHERE id = ? AND status = 'pending'",
|
||||
(status, reg_id),
|
||||
) as cur:
|
||||
changed = cur.rowcount > 0
|
||||
|
|
|
|||
|
|
@ -240,7 +240,11 @@ async def _handle_callback_query(cb: dict) -> None:
|
|||
return
|
||||
|
||||
if action == "approve":
|
||||
await db.update_registration_status(reg_id, "approved")
|
||||
updated = await db.update_registration_status(reg_id, "approved")
|
||||
if not updated:
|
||||
# Already processed (not pending) — ack the callback and stop
|
||||
await telegram.answer_callback_query(callback_query_id)
|
||||
return
|
||||
if chat_id and message_id:
|
||||
await telegram.edit_message_text(
|
||||
chat_id, message_id, f"✅ Пользователь {reg['login']} одобрен"
|
||||
|
|
@ -254,7 +258,10 @@ async def _handle_callback_query(cb: dict) -> None:
|
|||
)
|
||||
)
|
||||
elif action == "reject":
|
||||
await db.update_registration_status(reg_id, "rejected")
|
||||
updated = await db.update_registration_status(reg_id, "rejected")
|
||||
if not updated:
|
||||
await telegram.answer_callback_query(callback_query_id)
|
||||
return
|
||||
if chat_id and message_id:
|
||||
await telegram.edit_message_text(
|
||||
chat_id, message_id, f"❌ Пользователь {reg['login']} отклонён"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue