@@ -209,21 +209,23 @@ where
209
209
} ) ;
210
210
}
211
211
212
+ let ( last_used, last_notification_sent) = if no_change {
213
+ let existing_webhook = client_webhooks. get ( & params. app_name ) . unwrap ( ) ;
214
+ ( existing_webhook. last_used . clone ( ) , existing_webhook. last_notification_sent . clone ( ) )
215
+ } else {
216
+ ( now, new_hash_map ( ) )
217
+ } ;
218
+
212
219
let stored_webhook = StoredWebhook {
213
220
_app_name : params. app_name . clone ( ) ,
214
221
url : params. webhook . clone ( ) ,
215
222
_counterparty_node_id : counterparty_node_id,
216
- last_used : now ,
217
- last_notification_sent : new_hash_map ( ) ,
223
+ last_used,
224
+ last_notification_sent,
218
225
} ;
219
226
220
227
client_webhooks. insert ( params. app_name . clone ( ) , stored_webhook) ;
221
228
222
- let response = SetWebhookResponse {
223
- num_webhooks : client_webhooks. len ( ) as u32 ,
224
- max_webhooks : self . config . max_webhooks_per_client ,
225
- no_change,
226
- } ;
227
229
event_queue_notifier. enqueue ( LSPS5ServiceEvent :: WebhookRegistered {
228
230
counterparty_node_id,
229
231
app_name : params. app_name . clone ( ) ,
@@ -232,9 +234,6 @@ where
232
234
no_change,
233
235
} ) ;
234
236
235
- // Send webhook_registered notification if needed
236
- // According to spec:
237
- // "The LSP MUST send this notification to this webhook before sending any other notifications to this webhook."
238
237
if !no_change {
239
238
self . send_webhook_registered_notification (
240
239
counterparty_node_id,
@@ -243,7 +242,15 @@ where
243
242
) ;
244
243
}
245
244
246
- let msg = LSPS5Message :: Response ( request_id, LSPS5Response :: SetWebhook ( response) ) . into ( ) ;
245
+ let msg = LSPS5Message :: Response (
246
+ request_id,
247
+ LSPS5Response :: SetWebhook ( SetWebhookResponse {
248
+ num_webhooks : client_webhooks. len ( ) as u32 ,
249
+ max_webhooks : self . config . max_webhooks_per_client ,
250
+ no_change,
251
+ } ) ,
252
+ )
253
+ . into ( ) ;
247
254
self . pending_messages . enqueue ( & counterparty_node_id, msg) ;
248
255
Ok ( ( ) )
249
256
}
0 commit comments