in src/main/scala/com/gu/salesforce/messageHandler/MessageHandlerLambda.scala [47:63]
def processNotifications(notifications: Seq[ContactNotification], outputStream: OutputStream) = {
val contactListStr = notifications.flatMap(_.sObject.Id).mkString(", ")
logger.info(s"contacts found in salesforce xml: [$contactListStr]")
val FutureResponses = notifications.map(sendToQueue)
val future = Future.sequence(FutureResponses).map { responses =>
val errors = responses collect { case Failure(error) => error }
if (errors.nonEmpty) {
errors.foreach(error => logger.error(s"error while trying to send message to queue", error))
logger.info(s"lambda execution failed. Contacts in request: [$contactListStr]")
outputForAPIGateway(outputStream, internalServerError)
} else {
logger.info(s"lambda execution successful. Enqueued contacts: [$contactListStr]")
outputForAPIGateway(outputStream, okResponse)
}
}
Await.ready(future, Duration.Inf)
}