feat: add basic block/allow actions
This commit is contained in:
parent
d8ca9f830a
commit
2c5dfbbf92
3 changed files with 20 additions and 17 deletions
|
|
@ -532,7 +532,7 @@
|
|||
<q-input
|
||||
filled
|
||||
dense
|
||||
v-model.trim="allowedPubkey"
|
||||
v-model.trim="accountPubkey"
|
||||
type="text"
|
||||
></q-input>
|
||||
</div>
|
||||
|
|
@ -541,7 +541,7 @@
|
|||
unelevated
|
||||
color="green"
|
||||
class="float-right"
|
||||
@click="allowPublicKey()"
|
||||
@click="allowPublicKey(true)"
|
||||
>Allow</q-btn
|
||||
>
|
||||
</div>
|
||||
|
|
@ -550,7 +550,7 @@
|
|||
unelevated
|
||||
color="pink"
|
||||
class="float-right"
|
||||
@click="blockPublicKey()"
|
||||
@click="blockPublicKey(true)"
|
||||
>Block</q-btn
|
||||
>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -9,8 +9,7 @@ async function relayDetails(path) {
|
|||
return {
|
||||
tab: 'info',
|
||||
relay: null,
|
||||
blockedPubkey: '',
|
||||
allowedPubkey: '',
|
||||
accountPubkey: '',
|
||||
formDialogItem: {
|
||||
show: false,
|
||||
data: {
|
||||
|
|
@ -114,33 +113,35 @@ async function relayDetails(path) {
|
|||
this.relay.config.wallet =
|
||||
this.relay.config.wallet || this.walletOptions[0].value
|
||||
},
|
||||
allowPublicKey: async function () {
|
||||
allowPublicKey: async function (allowed) {
|
||||
await this.updatePublicKey({allowed})
|
||||
},
|
||||
blockPublicKey: async function (blocked = true) {
|
||||
await this.updatePublicKey({blocked})
|
||||
},
|
||||
updatePublicKey: async function (ops) {
|
||||
try {
|
||||
const {data} = await LNbits.api.request(
|
||||
await LNbits.api.request(
|
||||
'PUT',
|
||||
'/nostrrelay/api/v1/account',
|
||||
this.adminkey,
|
||||
{
|
||||
pubkey: this.allowedPubkey,
|
||||
allowed: true
|
||||
relay_id: this.relay.id,
|
||||
pubkey: this.accountPubkey,
|
||||
allowed: ops.allowed,
|
||||
blocked: ops.blocked
|
||||
}
|
||||
)
|
||||
this.relay = data
|
||||
this.$emit('relay-updated', this.relay)
|
||||
this.$q.notify({
|
||||
type: 'positive',
|
||||
message: 'Account Updated',
|
||||
timeout: 5000
|
||||
})
|
||||
this.allowedPubkey = ''
|
||||
this.accountPubkey = ''
|
||||
} catch (error) {
|
||||
LNbits.utils.notifyApiError(error)
|
||||
}
|
||||
},
|
||||
blockPublicKey: function () {
|
||||
this.relay.config.blockedPublicKeys.push(this.blockedPubkey)
|
||||
this.blockedPubkey = ''
|
||||
},
|
||||
deleteAllowedPublicKey: function (pubKey) {
|
||||
this.relay.config.allowedPublicKeys =
|
||||
this.relay.config.allowedPublicKeys.filter(p => p !== pubKey)
|
||||
|
|
|
|||
|
|
@ -155,12 +155,14 @@ async def api_create_or_update_account(
|
|||
data.pubkey = normalize_public_key(data.pubkey)
|
||||
account = await get_account(data.relay_id, data.pubkey)
|
||||
if not account:
|
||||
return await create_account(data.relay_id, NostrAccount.parse_obj(data.dict()))
|
||||
account = NostrAccount(pubkey=data.pubkey, blocked = data.blocked or False, allowed = data.allowed or False)
|
||||
return await create_account(data.relay_id, account)
|
||||
|
||||
if data.blocked is not None:
|
||||
account.blocked = data.blocked
|
||||
if data.allowed is not None:
|
||||
account.allowed = data.allowed
|
||||
|
||||
return await update_account(data.relay_id, account)
|
||||
|
||||
except ValueError as ex:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue