Prevented sending of empty emails

This commit is contained in:
neviyn 2020-09-11 10:37:14 +01:00
parent 9a0d73ec97
commit 71e4b3399d

View File

@ -285,8 +285,10 @@ class ObservationsController {
logger.info("Sending Observation data by email") logger.info("Sending Observation data by email")
if (::mailer.isInitialized) { if (::mailer.isInitialized) {
val data = getObservations(observationsRequest) val data = getObservations(observationsRequest)
if (data.isEmpty()) if (data.isEmpty()) {
logger.warn("Email not send, would contain no data")
throw ResponseStatusException(HttpStatus.BAD_REQUEST, "Request would send no data.") throw ResponseStatusException(HttpStatus.BAD_REQUEST, "Request would send no data.")
}
mailer.sendObservationData(data) mailer.sendObservationData(data)
return true return true
} else { } else {