refactor: code cleanup
This commit is contained in:
@@ -38,24 +38,6 @@ async def update_account(account: Account, conn: Connection | None = None) -> Ac
|
||||
return account
|
||||
|
||||
|
||||
async def update_account_activation(
|
||||
user_id: str, activated: bool, conn: Connection | None = None
|
||||
) -> None:
|
||||
await (conn or db).execute(
|
||||
f"""
|
||||
UPDATE accounts
|
||||
SET activated = :activated, updated_at = {db.timestamp_placeholder('now')}
|
||||
WHERE id = :user_id
|
||||
""", # noqa: S608
|
||||
{
|
||||
"activated": activated,
|
||||
"now": int(time()),
|
||||
"user_id": user_id,
|
||||
},
|
||||
)
|
||||
await clear_user_id_cache(user_id)
|
||||
|
||||
|
||||
async def delete_account(user_id: str, conn: Connection | None = None) -> None:
|
||||
await (conn or db).execute(
|
||||
"DELETE from accounts WHERE id = :user",
|
||||
|
||||
@@ -20,7 +20,7 @@ from lnbits.core.crud import (
|
||||
update_admin_settings,
|
||||
update_wallet,
|
||||
)
|
||||
from lnbits.core.crud.users import get_account, update_account
|
||||
from lnbits.core.crud.users import clear_user_id_cache, get_account, update_account
|
||||
from lnbits.core.crud.wallets import delete_wallet_by_id
|
||||
from lnbits.core.models import (
|
||||
AccountFilters,
|
||||
@@ -250,6 +250,7 @@ async def api_users_toggle_activated(
|
||||
)
|
||||
user_account.activated = not user_account.activated
|
||||
await update_account(user_account)
|
||||
await clear_user_id_cache(user_id)
|
||||
|
||||
return SimpleStatus(
|
||||
success=True,
|
||||
|
||||
Reference in New Issue
Block a user