Skip to content

Commit

Permalink
Support multiple webhooks (#72)
Browse files Browse the repository at this point in the history
The `webhook` option can now be used multiple times.

Fixes #71.
  • Loading branch information
pm47 authored Jul 15, 2024
1 parent 4743a7e commit 867998a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/commonMain/kotlin/fr/acinq/lightning/bin/Api.kt
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class Api(
private val peer: Peer,
private val eventsFlow: SharedFlow<ApiEvent>,
private val password: String,
private val webhookUrl: Url?,
private val webhookUrls: List<Url>,
private val webhookSecret: String,
private val loggerFactory: LoggerFactory,
) {
Expand Down Expand Up @@ -372,7 +372,7 @@ class Api(
}
}

webhookUrl?.let { url ->
webhookUrls.forEach { url ->
val client = HttpClient {
install(io.ktor.client.plugins.contentnegotiation.ContentNegotiation) {
json(json = Json {
Expand Down
5 changes: 3 additions & 2 deletions src/commonMain/kotlin/fr/acinq/lightning/bin/Main.kt
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,9 @@ class Phoenixd : CliktCommand() {
terminal.println(white("done"))
value
}
private val webHookUrl by option("--webhook", help = "Webhook http endpoint for push notifications (alternative to websocket)")
private val webHookUrls by option("--webhook", help = "Webhook http endpoint for push notifications (alternative to websocket)")
.convert { Url(it) }
.multiple()
private val webHookSecret by option("--webhook-secret", help = "Secret used to authenticate webhook calls")
.defaultLazy {
// if we are here then no value is defined in phoenix.conf
Expand Down Expand Up @@ -364,7 +365,7 @@ class Phoenixd : CliktCommand() {
reuseAddress = true
},
module = {
Api(nodeParams, peer, eventsFlow, httpPassword, webHookUrl, webHookSecret, loggerFactory).run { module() }
Api(nodeParams, peer, eventsFlow, httpPassword, webHookUrls, webHookSecret, loggerFactory).run { module() }
}
)
val serverJob = scope.launch {
Expand Down

0 comments on commit 867998a

Please sign in to comment.