Fix key renewal and expiry update function signatures

- Update `change_expiry_time` to pass session to `update_key_expiry`
- Adjust `complete_key_renewal` connection closing order
- Minor code structure improvements in key handling functions
This commit is contained in:
Zakhar Izmaylov
2025-01-31 06:44:36 +03:00
parent 8390775b6b
commit eb03b6014d
2 changed files with 3 additions and 3 deletions
+1 -1
View File
@@ -633,7 +633,7 @@ async def change_expiry_time(expiry_time: int, email: str, session: Any) -> Exce
await asyncio.gather(*tasks)
await update_key_on_all_servers()
await update_key_expiry(client_id, expiry_time)
await update_key_expiry(client_id, expiry_time, session)
async def get_user_balance(tg_id: int, session: Any) -> float:
+2 -2
View File
@@ -484,8 +484,6 @@ async def complete_key_renewal(tg_id, client_id, email, new_expiry_time, total_g
else:
cluster_id = server_id
await conn.close()
logger.info(f"[RENEW] Запуск продления ключа для пользователя {tg_id} на {plan} мес. в кластере {cluster_id}.")
async def renew_key_on_cluster():
@@ -500,5 +498,7 @@ async def complete_key_renewal(tg_id, client_id, email, new_expiry_time, total_g
await update_key_expiry(client_id, new_expiry_time, conn)
await update_balance(tg_id, -cost, conn)
logger.info(f"[RENEW] Ключ {client_id} успешно продлён на {plan} мес. для пользователя {tg_id}.")
await conn.close()
await renew_key_on_cluster()