fix: allow admin to view payments in deleted wallets (#3074)

This commit is contained in:
Vlad Stan
2025-03-31 17:18:32 +03:00
committed by GitHub
parent aa050eaf49
commit bafb4ddf75
3 changed files with 24 additions and 4 deletions

View File

@@ -1,5 +1,5 @@
from time import time from time import time
from typing import Optional, Tuple from typing import Any, Optional, Tuple
from lnbits.core.crud.wallets import get_total_balance, get_wallet from lnbits.core.crud.wallets import get_total_balance, get_wallet
from lnbits.core.db import db from lnbits.core.db import db
@@ -110,8 +110,7 @@ async def get_payments_paginated(
- complete | pending | failed | outgoing | incoming. - complete | pending | failed | outgoing | incoming.
""" """
values: dict = { values: dict[str, Any] = {
"wallet_id": wallet_id,
"time": since, "time": since,
} }
clause: list[str] = [] clause: list[str] = []
@@ -120,6 +119,7 @@ async def get_payments_paginated(
clause.append(f"time > {db.timestamp_placeholder('time')}") clause.append(f"time > {db.timestamp_placeholder('time')}")
if wallet_id: if wallet_id:
values["wallet_id"] = wallet_id
clause.append("wallet_id = :wallet_id") clause.append("wallet_id = :wallet_id")
if complete and pending: if complete and pending:

File diff suppressed because one or more lines are too long

View File

@@ -178,6 +178,26 @@ window.app.component('payment-list', {
return LNbits.map.payment(obj) return LNbits.map.payment(obj)
}) })
}) })
.catch(err => {
this.paymentsTable.loading = false
if (g.user.admin) {
this.fetchPaymentsAsAdmin(this.currentWallet.id, params)
} else {
LNbits.utils.notifyApiError(err)
}
})
},
fetchPaymentsAsAdmin(walletId, params) {
params = (params || '') + '&wallet_id=' + walletId
return LNbits.api
.request('GET', '/api/v1/payments/all/paginated?' + params)
.then(response => {
this.paymentsTable.loading = false
this.paymentsTable.pagination.rowsNumber = response.data.total
this.payments = response.data.data.map(obj => {
return LNbits.map.payment(obj)
})
})
.catch(err => { .catch(err => {
this.paymentsTable.loading = false this.paymentsTable.loading = false
LNbits.utils.notifyApiError(err) LNbits.utils.notifyApiError(err)