Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 8 additions & 21 deletions templates/nostrclient/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -476,11 +476,7 @@ <h6 class="text-subtitle1 q-my-none">Nostrclient Extension</h6>
getRelays: function () {
var self = this
LNbits.api
.request(
'GET',
'/nostrclient/api/v1/relays?usr=' + this.g.user.id,
this.g.user.wallets[0].adminkey
)
.request('GET', '/nostrclient/api/v1/relays')
.then(function (response) {
if (response.data) {
response.data.map(maplrelays)
Expand Down Expand Up @@ -508,12 +504,9 @@ <h6 class="text-subtitle1 q-my-none">Nostrclient Extension</h6>
console.log('ADD RELAY ' + this.relayToAdd)
let that = this
LNbits.api
.request(
'POST',
'/nostrclient/api/v1/relay?usr=' + this.g.user.id,
this.g.user.wallets[0].adminkey,
{url: this.relayToAdd}
)
.request('POST', '/nostrclient/api/v1/relay', null, {
url: this.relayToAdd
})
.then(function (response) {
console.log('response:', response)
if (response.data) {
Expand All @@ -540,12 +533,7 @@ <h6 class="text-subtitle1 q-my-none">Nostrclient Extension</h6>
},
deleteRelay(url) {
LNbits.api
.request(
'DELETE',
'/nostrclient/api/v1/relay?usr=' + this.g.user.id,
this.g.user.wallets[0].adminkey,
{url: url}
)
.request('DELETE', '/nostrclient/api/v1/relay', null, {url: url})
.then(response => {
const relayIndex = this.nostrrelayLinks.indexOf(r => r.url === url)
if (relayIndex !== -1) {
Expand All @@ -561,8 +549,7 @@ <h6 class="text-subtitle1 q-my-none">Nostrclient Extension</h6>
try {
const {data} = await LNbits.api.request(
'GET',
'/nostrclient/api/v1/config',
this.g.user.wallets[0].adminkey
'/nostrclient/api/v1/config'
)
this.config.data = data
} catch (error) {
Expand All @@ -574,7 +561,7 @@ <h6 class="text-subtitle1 q-my-none">Nostrclient Extension</h6>
const {data} = await LNbits.api.request(
'PUT',
'/nostrclient/api/v1/config',
this.g.user.wallets[0].adminkey,
null,
this.config.data
)
this.config.data = data
Expand Down Expand Up @@ -623,7 +610,7 @@ <h6 class="text-subtitle1 q-my-none">Nostrclient Extension</h6>
const {data} = await LNbits.api.request(
'PUT',
'/nostrclient/api/v1/relay/test',
this.g.user.wallets[0].adminkey,
null,
{
sender_private_key: this.testData.senderPrivateKey,
reciever_public_key: this.testData.recieverPublicKey,
Expand Down
8 changes: 6 additions & 2 deletions views.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from fastapi import APIRouter, Depends, Request
from fastapi.responses import HTMLResponse
from lnbits.core.models import User
from lnbits.core.crud.users import get_user_from_account
from lnbits.core.models.users import Account
from lnbits.decorators import check_admin
from lnbits.helpers import template_renderer

Expand All @@ -12,7 +13,10 @@ def nostr_renderer():


@nostrclient_generic_router.get("/", response_class=HTMLResponse)
async def index(request: Request, user: User = Depends(check_admin)):
async def index(request: Request, account: Account = Depends(check_admin)):
user = await get_user_from_account(account)
if not user:
return HTMLResponse("No user found", status_code=404)
return nostr_renderer().TemplateResponse(
"nostrclient/index.html", {"request": request, "user": user.json()}
)