mirror of
https://github.com/lnbits/lnbits.git
synced 2025-09-29 05:12:39 +02:00
fix: allow admin to view payments in deleted wallets (#3074)
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
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.db import db
|
||||
@@ -110,8 +110,7 @@ async def get_payments_paginated(
|
||||
- complete | pending | failed | outgoing | incoming.
|
||||
"""
|
||||
|
||||
values: dict = {
|
||||
"wallet_id": wallet_id,
|
||||
values: dict[str, Any] = {
|
||||
"time": since,
|
||||
}
|
||||
clause: list[str] = []
|
||||
@@ -120,6 +119,7 @@ async def get_payments_paginated(
|
||||
clause.append(f"time > {db.timestamp_placeholder('time')}")
|
||||
|
||||
if wallet_id:
|
||||
values["wallet_id"] = wallet_id
|
||||
clause.append("wallet_id = :wallet_id")
|
||||
|
||||
if complete and pending:
|
||||
|
2
lnbits/static/bundle-components.min.js
vendored
2
lnbits/static/bundle-components.min.js
vendored
File diff suppressed because one or more lines are too long
@@ -178,6 +178,26 @@ window.app.component('payment-list', {
|
||||
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 => {
|
||||
this.paymentsTable.loading = false
|
||||
LNbits.utils.notifyApiError(err)
|
||||
|
Reference in New Issue
Block a user