summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2023-04-20 21:49:57 +0200
committerCarl Hetherington <cth@carlh.net>2023-04-20 21:49:57 +0200
commit0c766528070eadd3d044255a3e4dfde5a85707b5 (patch)
tree9933cc343c1fbe2df09cf26250bdb55dab9aec65
parent22aa0dd620b6db93a64e1e171fb5ddb18693e56e (diff)
Fix lack of email sending if there are no cinema addresses (only extra ones) (#2514).
-rw-r--r--src/lib/kdm_with_metadata.cc24
1 files changed, 5 insertions, 19 deletions
diff --git a/src/lib/kdm_with_metadata.cc b/src/lib/kdm_with_metadata.cc
index e4aea1be7..5cbadc911 100644
--- a/src/lib/kdm_with_metadata.cc
+++ b/src/lib/kdm_with_metadata.cc
@@ -220,10 +220,6 @@ send_emails (
auto first = kdms_for_cinema.front();
- if (first->emails().empty()) {
- continue;
- }
-
auto zip_file = boost::filesystem::temp_directory_path() / boost::filesystem::unique_path();
boost::filesystem::create_directories (zip_file);
zip_file /= container_name_format.get(first->name_values(), ".zip");
@@ -251,6 +247,11 @@ send_emails (
boost::algorithm::replace_all (body, "$SCREENS", screens.substr (0, screens.length() - 2));
auto emails = first->emails();
+ std::copy(extra_addresses.begin(), extra_addresses.end(), std::back_inserter(emails));
+ if (emails.empty()) {
+ continue;
+ }
+
Emailer email (config->kdm_from(), { emails.front() }, subject, body);
/* Use CC for the second and subsequent email addresses, so we seem less spammy (#2310) */
@@ -284,21 +285,6 @@ send_emails (
log_details (email);
- for (auto extra: extra_addresses) {
- Emailer email (config->kdm_from(), { extra }, subject, body);
- email.add_attachment (zip_file, container_name_format.get(first->name_values(), ".zip"), "application/zip");
-
- try {
- email.send (config->mail_server(), config->mail_port(), config->mail_protocol(), config->mail_user(), config->mail_password());
- } catch (...) {
- boost::filesystem::remove (zip_file);
- log_details (email);
- throw;
- }
-
- log_details (email);
- }
-
boost::filesystem::remove (zip_file);
}
}