diff --git a/migrations.py b/migrations.py
index 754a57f..e27af8a 100644
--- a/migrations.py
+++ b/migrations.py
@@ -139,3 +139,9 @@ async def m007_add_created_at_timestamp(db):
"ALTER TABLE withdraw.withdraw_link "
f"ADD COLUMN created_at TIMESTAMP DEFAULT {db.timestamp_column_default}"
)
+
+
+async def m008_add_enabled_column(db):
+ await db.execute(
+ "ALTER TABLE withdraw.withdraw_link ADD COLUMN enabled BOOLEAN DEFAULT true;"
+ )
diff --git a/models.py b/models.py
index 0b4b910..e888cdf 100644
--- a/models.py
+++ b/models.py
@@ -15,6 +15,7 @@ class CreateWithdrawData(BaseModel):
webhook_headers: str = Query(None)
webhook_body: str = Query(None)
custom_url: str = Query(None)
+ enabled: bool = Query(True)
class WithdrawLink(BaseModel):
@@ -37,6 +38,7 @@ class WithdrawLink(BaseModel):
webhook_body: str = Query(None)
custom_url: str = Query(None)
created_at: datetime
+ enabled: bool = Query(True)
lnurl: str | None = Field(
default=None,
no_database=True,
diff --git a/static/js/index.js b/static/js/index.js
index a5f4dbf..0b42b40 100644
--- a/static/js/index.js
+++ b/static/js/index.js
@@ -68,7 +68,8 @@ window.app = Vue.createApp({
data: {
is_unique: false,
use_custom: false,
- has_webhook: false
+ has_webhook: false,
+ enabled: true
}
},
simpleformDialog: {
@@ -78,7 +79,8 @@ window.app = Vue.createApp({
use_custom: false,
title: 'Vouchers',
min_withdrawable: 0,
- wait_time: 1
+ wait_time: 1,
+ enabled: true
}
},
qrCodeDialog: {
@@ -125,13 +127,15 @@ window.app = Vue.createApp({
this.formDialog.data = {
is_unique: false,
use_custom: false,
- has_webhook: false
+ has_webhook: false,
+ enabled: true
}
},
simplecloseFormDialog() {
this.simpleformDialog.data = {
is_unique: false,
- use_custom: false
+ use_custom: false,
+ enabled: true
}
},
openQrCodeDialog(linkId) {
diff --git a/templates/withdraw/display.html b/templates/withdraw/display.html
index f9fbd53..812c95f 100644
--- a/templates/withdraw/display.html
+++ b/templates/withdraw/display.html
@@ -7,6 +7,12 @@
Withdraw is spent.
+ Withdraw is spent.
+ Withdraw is disabled.
spent: {{ 'true' if spent else 'false' }},
url: '{{ lnurl_url }}',
lnurl: '',
- nfcTagWriting: false
+ nfcTagWriting: false,
+ enabled: {{ 'true' if enabled else 'false' }}
}
}
})
diff --git a/templates/withdraw/index.html b/templates/withdraw/index.html
index 3b75e11..f208ece 100644
--- a/templates/withdraw/index.html
+++ b/templates/withdraw/index.html
@@ -38,6 +38,7 @@ Withdraw links
>
+
Withdraw links
+
+
+
+
+
+
+
hint="Custom data as JSON string, will get posted along with webhook 'body' field."
>
+
+
+
+
+
+ Enable / Disable
+ You can enable or disable these vouchers
+
+
label="Number of vouchers"
>
+
+
+
+
+
+ Enable / Disable
+ You can enable or disable these vouchers
+
+
LnurlErrorResponse | LnurlSuccessResponse:
-
link = await get_withdraw_link_by_hash(unique_hash)
if not link:
return LnurlErrorResponse(reason="withdraw link not found.")
+ if not link.enabled:
+ return LnurlErrorResponse(reason="Withdraw link is disabled.")
+
if link.is_spent:
return LnurlErrorResponse(reason="withdraw is spent.")
@@ -194,6 +199,9 @@ async def api_lnurl_multi_response(
if not link:
return LnurlErrorResponse(reason="Withdraw link does not exist.")
+ if not link.enabled:
+ return LnurlErrorResponse(reason="Withdraw link is disabled.")
+
if link.is_spent:
return LnurlErrorResponse(reason="Withdraw is spent.")