Skip to content

Commit

Permalink
#1743 Force close http client after use in webhook
Browse files Browse the repository at this point in the history
  • Loading branch information
To-om committed Feb 3, 2021
1 parent e2c0b7e commit a90edda
Showing 1 changed file with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -255,13 +255,14 @@ class Webhook(
Future.failed(BadConfigurationError(s"The organisation ${organisation.name} is not authorised to use the webhook ${config.name}"))
else if (user.isDefined)
Future.failed(BadConfigurationError("The notification webhook must not be applied on user"))
else
for {
else {
val ws = new ProxyWS(config.wsConfig, mat)
val async = for {
message <- Future.fromTry(buildMessage(config.version, audit))
_ = logger.debug(s"Request webhook with message $message")
resp <- new ProxyWS(config.wsConfig, mat)
.url(config.url)
.post(message)
resp <- ws.url(config.url).post(message)
} yield if (resp.status >= 400) logger.warn(s"Webhook call on ${config.url} returns ${resp.status} ${resp.statusText}") else ()
async.andThen { case _ => ws.close() }
}

}

0 comments on commit a90edda

Please sign in to comment.