feat: public relay page updates
This commit is contained in:
parent
ae68f210cd
commit
db3ad2e32f
4 changed files with 102 additions and 20 deletions
3
crud.py
3
crud.py
|
|
@ -2,7 +2,7 @@ import json
|
|||
from typing import Any, List, Optional, Tuple
|
||||
|
||||
from . import db
|
||||
from .models import NostrEvent, NostrFilter, NostrRelay, RelaySpec
|
||||
from .models import NostrEvent, NostrFilter, NostrRelay, RelayPublicSpec, RelaySpec
|
||||
|
||||
########################## RELAYS ####################
|
||||
|
||||
|
|
@ -100,6 +100,7 @@ async def get_public_relay(relay_id: str) -> Optional[dict]:
|
|||
"description": relay.description,
|
||||
"pubkey": relay.pubkey,
|
||||
"contact": relay.contact,
|
||||
"config": dict(RelayPublicSpec(**dict(relay.config)))
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
22
models.py
22
models.py
|
|
@ -8,11 +8,14 @@ from pydantic import BaseModel, Field
|
|||
from secp256k1 import PublicKey
|
||||
|
||||
|
||||
class FilterSpec(BaseModel):
|
||||
class Spec(BaseModel):
|
||||
class Config:
|
||||
allow_population_by_field_name = True
|
||||
class FilterSpec(Spec):
|
||||
max_client_filters = Field(0, alias="maxClientFilters")
|
||||
limit_per_filter = Field(1000, alias="limitPerFilter")
|
||||
|
||||
class EventSpec(BaseModel):
|
||||
class EventSpec(Spec):
|
||||
max_events_per_second = Field(0, alias="maxEventsPerSecond")
|
||||
|
||||
created_at_days_past = Field(0, alias="createdAtDaysPast")
|
||||
|
|
@ -44,7 +47,7 @@ class EventSpec(BaseModel):
|
|||
+ self.created_at_seconds_future
|
||||
)
|
||||
|
||||
class StorageSpec(BaseModel):
|
||||
class StorageSpec(Spec):
|
||||
free_storage_value = Field(1, alias="freeStorageValue")
|
||||
free_storage_unit = Field("MB", alias="freeStorageUnit")
|
||||
full_storage_action = Field("prune", alias="fullStorageAction")
|
||||
|
|
@ -56,7 +59,7 @@ class StorageSpec(BaseModel):
|
|||
value *= 1024
|
||||
return value
|
||||
|
||||
class AuthorSpec(BaseModel):
|
||||
class AuthorSpec(Spec):
|
||||
allowed_public_keys = Field([], alias="allowedPublicKeys")
|
||||
blocked_public_keys = Field([], alias="blockedPublicKeys")
|
||||
|
||||
|
|
@ -68,18 +71,21 @@ class AuthorSpec(BaseModel):
|
|||
# todo: check payment
|
||||
return p in self.allowed_public_keys
|
||||
|
||||
|
||||
class PaymentSpec(BaseModel):
|
||||
is_paid_relay = Field(False, alias="isPaidRelay")
|
||||
wallet = Field("")
|
||||
cost_to_join = Field(0, alias="costToJoin")
|
||||
|
||||
storage_cost_value = Field(0, alias="storageCostValue")
|
||||
storage_cost_unit = Field("MB", alias="storageCostUnit")
|
||||
class WalletSpec(Spec):
|
||||
wallet = Field("")
|
||||
|
||||
class RelaySpec(FilterSpec, EventSpec, StorageSpec, AuthorSpec, PaymentSpec):
|
||||
class Config:
|
||||
allow_population_by_field_name = True
|
||||
class RelaySpec(FilterSpec, EventSpec, StorageSpec, AuthorSpec, PaymentSpec, WalletSpec):
|
||||
pass
|
||||
|
||||
class RelayPublicSpec(FilterSpec, EventSpec, StorageSpec, PaymentSpec):
|
||||
pass
|
||||
|
||||
class NostrRelay(BaseModel):
|
||||
id: str
|
||||
|
|
|
|||
|
|
@ -1,16 +1,88 @@
|
|||
{% extends "public.html" %} {% block toolbar_title %} {{ relay.name }}
|
||||
<q-btn
|
||||
flat
|
||||
dense
|
||||
size="md"
|
||||
@click.prevent="urlDialog.show = true"
|
||||
icon="share"
|
||||
color="white"
|
||||
></q-btn>
|
||||
{% extends "public.html" %} {% block toolbar_title %} LNbits Relay
|
||||
<q-icon name="sensors" class="q-ml-lg" />
|
||||
{% endblock %} {% block footer %}{% endblock %} {% block page_container %}
|
||||
|
||||
<q-page-container>
|
||||
<q-page>
|
||||
<h3>Shareable public page on relay to go here!</h3>
|
||||
<div class="row q-col-gutter-md">
|
||||
<div class="col-12 col-md-2 q-gutter-y-md"></div>
|
||||
<div class="col-12 col-md-6 q-gutter-y-md q-pa-xl">
|
||||
<q-card>
|
||||
<q-card-section> </q-card-section>
|
||||
</q-card>
|
||||
</div>
|
||||
<div class="col-12 col-md-4 q-gutter-y-md q-pa-xl">
|
||||
<q-card>
|
||||
<q-card-section>
|
||||
<q-expansion-item
|
||||
group="extras"
|
||||
icon="sensors"
|
||||
:label="relay.name"
|
||||
:content-inset-level="0.5"
|
||||
>
|
||||
<q-separator class="q-mt-md"></q-separator>
|
||||
<span v-text="relay.description"></span>
|
||||
<q-separator class="q-mb-md"></q-separator>
|
||||
<q-expansion-item
|
||||
group="api"
|
||||
dense
|
||||
expand-separator
|
||||
label="Payment Spec"
|
||||
>
|
||||
<q-card>
|
||||
<q-card-section>
|
||||
<code
|
||||
><span class="text-blue">GET</span>
|
||||
/lnurlp/api/v1/links</code
|
||||
>
|
||||
<h5 class="text-caption q-mt-sm q-mb-none">Headers</h5>
|
||||
<code>{"X-Api-Key": <invoice_key>}</code><br />
|
||||
<h5 class="text-caption q-mt-sm q-mb-none">
|
||||
Body (application/json)
|
||||
</h5>
|
||||
<h5 class="text-caption q-mt-sm q-mb-none">
|
||||
Returns 200 OK (application/json)
|
||||
</h5>
|
||||
<code>[<pay_link_object>, ...]</code>
|
||||
<h5 class="text-caption q-mt-sm q-mb-none">Curl example</h5>
|
||||
</q-card-section>
|
||||
</q-card>
|
||||
</q-expansion-item>
|
||||
<q-expansion-item
|
||||
group="api"
|
||||
dense
|
||||
expand-separator
|
||||
label="Events Spec"
|
||||
>
|
||||
<q-card>
|
||||
<q-card-section> </q-card-section>
|
||||
</q-card>
|
||||
</q-expansion-item>
|
||||
<q-expansion-item
|
||||
group="api"
|
||||
dense
|
||||
expand-separator
|
||||
label="Filters Spec"
|
||||
>
|
||||
<q-card>
|
||||
<q-card-section> </q-card-section>
|
||||
</q-card>
|
||||
</q-expansion-item>
|
||||
<q-expansion-item
|
||||
group="api"
|
||||
dense
|
||||
expand-separator
|
||||
label="Storage Spec"
|
||||
>
|
||||
<q-card>
|
||||
<q-card-section> </q-card-section>
|
||||
</q-card>
|
||||
</q-expansion-item>
|
||||
</q-expansion-item>
|
||||
</q-card-section>
|
||||
</q-card>
|
||||
</div>
|
||||
</div>
|
||||
</q-page>
|
||||
</q-page-container>
|
||||
{% endblock %} {% block scripts %}
|
||||
|
|
@ -21,7 +93,9 @@
|
|||
el: '#vue',
|
||||
mixins: [windowMixin],
|
||||
data: function () {
|
||||
return {}
|
||||
return {
|
||||
relay: JSON.parse('{{relay | tojson | safe}}')
|
||||
}
|
||||
},
|
||||
methods: {}
|
||||
})
|
||||
|
|
|
|||
1
views.py
1
views.py
|
|
@ -24,6 +24,7 @@ async def index(request: Request, user: User = Depends(check_user_exists)):
|
|||
@nostrrelay_ext.get("/{relay_id}")
|
||||
async def nostrrelay(request: Request, relay_id: str):
|
||||
relay_public_data = await get_public_relay(relay_id)
|
||||
|
||||
if not relay_public_data:
|
||||
raise HTTPException(
|
||||
status_code=HTTPStatus.NOT_FOUND,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue