@@ -51,7 +51,11 @@ struct StoredWebhook {
51
51
_app_name : LSPS5AppName ,
52
52
url : LSPS5WebhookUrl ,
53
53
_counterparty_node_id : PublicKey ,
54
+ // Timestamp used for tracking when the webhook was created / updated, or when the last notification was sent.
55
+ // This is used to determine if the webhook is stale and should be pruned.
54
56
last_used : LSPSDateTime ,
57
+ // Map of last notification sent timestamps for each notification method.
58
+ // This is used to enforce notification cooldowns.
55
59
last_notification_sent : HashMap < WebhookNotificationMethod , LSPSDateTime > ,
56
60
}
57
61
@@ -60,8 +64,6 @@ struct StoredWebhook {
60
64
pub struct LSPS5ServiceConfig {
61
65
/// Maximum number of webhooks allowed per client.
62
66
pub max_webhooks_per_client : u32 ,
63
- /// Minimum time between sending the same notification type in hours (default: 24)
64
- pub notification_cooldown_hours : Duration ,
65
67
}
66
68
67
69
/// Default maximum number of webhooks allowed per client.
@@ -72,10 +74,7 @@ pub const DEFAULT_NOTIFICATION_COOLDOWN_HOURS: Duration = Duration::from_secs(60
72
74
// Default configuration for LSPS5 service.
73
75
impl Default for LSPS5ServiceConfig {
74
76
fn default ( ) -> Self {
75
- Self {
76
- max_webhooks_per_client : DEFAULT_MAX_WEBHOOKS_PER_CLIENT ,
77
- notification_cooldown_hours : DEFAULT_NOTIFICATION_COOLDOWN_HOURS ,
78
- }
77
+ Self { max_webhooks_per_client : DEFAULT_MAX_WEBHOOKS_PER_CLIENT }
79
78
}
80
79
}
81
80
@@ -408,9 +407,8 @@ where
408
407
. last_notification_sent
409
408
. get ( & notification. method )
410
409
. map ( |last_sent| now. clone ( ) . abs_diff ( & last_sent) )
411
- . map_or ( true , |last_sent| {
412
- last_sent >= self . config . notification_cooldown_hours . as_secs ( )
413
- } ) {
410
+ . map_or ( true , |duration| duration >= DEFAULT_NOTIFICATION_COOLDOWN_HOURS . as_secs ( ) )
411
+ {
414
412
webhook. last_notification_sent . insert ( notification. method . clone ( ) , now. clone ( ) ) ;
415
413
webhook. last_used = now. clone ( ) ;
416
414
self . send_notification (
0 commit comments