feat: add configurable threshold for balance delta notification (#3433)
Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: Vlad Stan <stan.v.vlad@gmail.com>
This commit is contained in:
parent
1e6e97c12d
commit
c89721223f
7 changed files with 14 additions and 12 deletions
|
|
@ -70,7 +70,8 @@ async def check_balance_delta_changed():
|
|||
if settings.latest_balance_delta_sats is None:
|
||||
settings.latest_balance_delta_sats = status.delta_sats
|
||||
return
|
||||
if status.delta_sats != settings.latest_balance_delta_sats:
|
||||
delta_change = abs(status.delta_sats - settings.latest_balance_delta_sats)
|
||||
if delta_change >= settings.notification_balance_delta_threshold_sats:
|
||||
enqueue_admin_notification(
|
||||
NotificationType.balance_delta,
|
||||
{
|
||||
|
|
|
|||
|
|
@ -392,7 +392,7 @@ def _is_message_type_enabled(message_type: NotificationType) -> bool:
|
|||
if message_type == NotificationType.watchdog_check:
|
||||
return settings.lnbits_notification_watchdog
|
||||
if message_type == NotificationType.balance_delta:
|
||||
return settings.notification_balance_delta_changed
|
||||
return settings.notification_balance_delta_threshold_sats > 0
|
||||
if message_type == NotificationType.server_start_stop:
|
||||
return settings.lnbits_notification_server_start_stop
|
||||
if message_type == NotificationType.server_status:
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ async def run_by_the_minute_tasks() -> None:
|
|||
while settings.lnbits_running:
|
||||
status_minutes = settings.lnbits_notification_server_status_hours * 60
|
||||
|
||||
if settings.notification_balance_delta_changed:
|
||||
if settings.notification_balance_delta_threshold_sats > 0:
|
||||
try:
|
||||
# runs by default every minute, the delta should not change that often
|
||||
await check_balance_delta_changed()
|
||||
|
|
|
|||
|
|
@ -429,7 +429,7 @@ class NotificationsSettings(LNbitsSettings):
|
|||
|
||||
lnbits_notification_settings_update: bool = Field(default=True)
|
||||
lnbits_notification_credit_debit: bool = Field(default=True)
|
||||
notification_balance_delta_changed: bool = Field(default=True)
|
||||
notification_balance_delta_threshold_sats: int = Field(default=1, ge=0)
|
||||
lnbits_notification_server_start_stop: bool = Field(default=True)
|
||||
lnbits_notification_watchdog: bool = Field(default=False)
|
||||
lnbits_notification_server_status_hours: int = Field(default=24, gt=0)
|
||||
|
|
|
|||
2
lnbits/static/bundle.min.js
vendored
2
lnbits/static/bundle.min.js
vendored
File diff suppressed because one or more lines are too long
|
|
@ -314,7 +314,7 @@ window.localisation.en = {
|
|||
|
||||
notification_balance_delta_changed: 'Balance Delta Changed',
|
||||
notification_balance_delta_changed_desc:
|
||||
'Notify when the diference between the node balance and the LNbits balance has changed even by 1 sat. This runs every minute.',
|
||||
'Notify when the difference between the node balance and the LNbits balance has changed by more than the specified amount (in sats). Set to 0 to disable. This runs every minute.',
|
||||
|
||||
enable_watchdog: 'Enable Watchdog Switch',
|
||||
enable_watchdog_desc:
|
||||
|
|
|
|||
|
|
@ -404,13 +404,14 @@
|
|||
v-text="$t('notification_balance_delta_changed_desc')"
|
||||
></q-item-label>
|
||||
</q-item-section>
|
||||
|
||||
<q-item-section avatar>
|
||||
<q-toggle
|
||||
size="md"
|
||||
v-model="formData.notification_balance_delta_changed"
|
||||
checked-icon="check"
|
||||
color="green"
|
||||
unchecked-icon="clear"
|
||||
<q-input
|
||||
class="flow-right"
|
||||
type="number"
|
||||
min="0"
|
||||
filled
|
||||
v-model="formData.notification_balance_delta_threshold_sats"
|
||||
/>
|
||||
</q-item-section>
|
||||
</q-item>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue