summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2022-03-19 19:34:22 +0100
committerCarl Hetherington <cth@carlh.net>2022-04-02 22:25:10 +0200
commit70e24a8fcbf3e99df85ac421414eee20c5f57a97 (patch)
tree31a14a4480919b35206c5cb483d3a489b52bafee /src/lib
parentb52db065d57ef1016611d368193e45e680f92225 (diff)
Cleanup: remove some duplicated code.
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/kdm_with_metadata.cc21
1 files changed, 10 insertions, 11 deletions
diff --git a/src/lib/kdm_with_metadata.cc b/src/lib/kdm_with_metadata.cc
index e3c0d9204..716d29d9c 100644
--- a/src/lib/kdm_with_metadata.cc
+++ b/src/lib/kdm_with_metadata.cc
@@ -220,17 +220,16 @@ send_emails (
zip_file /= container_name_format.get(i.front()->name_values(), ".zip");
make_zip_file (i, zip_file, filename_format);
- auto subject = config->kdm_subject();
- boost::algorithm::replace_all (subject, "$CPL_NAME", cpl_name);
- boost::algorithm::replace_all (subject, "$START_TIME", i.front()->get('b').get_value_or(""));
- boost::algorithm::replace_all (subject, "$END_TIME", i.front()->get('e').get_value_or(""));
- boost::algorithm::replace_all (subject, "$CINEMA_NAME", i.front()->get('c').get_value_or(""));
-
- auto body = config->kdm_email();
- boost::algorithm::replace_all (body, "$CPL_NAME", cpl_name);
- boost::algorithm::replace_all (body, "$START_TIME", i.front()->get('b').get_value_or(""));
- boost::algorithm::replace_all (body, "$END_TIME", i.front()->get('e').get_value_or(""));
- boost::algorithm::replace_all (body, "$CINEMA_NAME", i.front()->get('c').get_value_or(""));
+ auto substitute_variables = [cpl_name, i](string target) {
+ boost::algorithm::replace_all (target, "$CPL_NAME", cpl_name);
+ boost::algorithm::replace_all (target, "$START_TIME", i.front()->get('b').get_value_or(""));
+ boost::algorithm::replace_all (target, "$END_TIME", i.front()->get('e').get_value_or(""));
+ boost::algorithm::replace_all (target, "$CINEMA_NAME", i.front()->get('c').get_value_or(""));
+ return target;
+ };
+
+ auto subject = substitute_variables(config->kdm_subject());
+ auto body = substitute_variables(config->kdm_email());
string screens;
for (auto j: i) {