feat: add basic block/allow actions

This commit is contained in:
Vlad Stan 2023-02-16 12:33:16 +02:00
parent d8ca9f830a
commit 2c5dfbbf92
3 changed files with 20 additions and 17 deletions

View file

@ -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>

View file

@ -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)