From 20a456e33222ed31008db3c328f1e10c212acf00 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Tue, 12 Jun 2018 13:57:31 +0300 Subject: Make project url and email optional in package manifest --- mod/mod-build-result.cxx | 23 +++++++++++++---------- mod/mod-package-details.cxx | 12 ++++++++---- mod/mod-package-version-details.cxx | 20 +++++++++++++------- 3 files changed, 34 insertions(+), 21 deletions(-) (limited to 'mod') diff --git a/mod/mod-build-result.cxx b/mod/mod-build-result.cxx index 1253d14..7891fe1 100644 --- a/mod/mod-build-result.cxx +++ b/mod/mod-build-result.cxx @@ -379,6 +379,18 @@ handle (request& rq, response&) if (!notify || (build_email && build_email->empty ())) return true; + // If the package build address is not specified, then it is assumed to be + // the same as the package email address, if specified, otherwise as the + // project email address, if specified, otherwise the notification email is + // not sent. + // + const optional& to (build_email ? build_email + : p->package_email + ? p->package_email + : p->email); + if (!to) + return true; + assert (b != nullptr); // Send email to the package owner. @@ -391,15 +403,6 @@ handle (request& rq, response&) b->package_version.string () + '/' + b->configuration + '/' + b->toolchain_name + '-' + b->toolchain_version.string ()); - // If the package build address is not specified, then it is assumed to be - // the same as the package email address, if specified, otherwise as the - // project email address. - // - const string& to (build_email ? *build_email - : p->package_email - ? *p->package_email - : p->email); - // Redirect the diagnostics to webserver error log. // // Note: if using this somewhere else, then need to factor out all this @@ -409,7 +412,7 @@ handle (request& rq, response&) 2, options_->email (), subj, - {to}); + {*to}); if (b->results.empty ()) sm.out << "No operation results available." << endl; diff --git a/mod/mod-package-details.cxx b/mod/mod-package-details.cxx index c56d91a..a348d95 100644 --- a/mod/mod-package-details.cxx +++ b/mod/mod-package-details.cxx @@ -186,8 +186,10 @@ handle (request& rq, response& rs) s << TABLE(CLASS="proplist", ID="package") << TBODY - << TR_LICENSE (licenses) - << TR_URL (pkg->url); + << TR_LICENSE (licenses); + + if (pkg->url) + s << TR_URL (*pkg->url); if (pkg->doc_url) s << TR_URL (*pkg->doc_url, "doc-url"); @@ -195,8 +197,10 @@ handle (request& rq, response& rs) if (pkg->src_url) s << TR_URL (*pkg->src_url, "src-url"); - s << TR_EMAIL (pkg->email) - << TR_TAGS (pkg->tags, root) + if (pkg->email) + s << TR_EMAIL (*pkg->email); + + s << TR_TAGS (pkg->tags, root) << ~TBODY << ~TABLE; } diff --git a/mod/mod-package-version-details.cxx b/mod/mod-package-version-details.cxx index 2134cc6..cef9357 100644 --- a/mod/mod-package-version-details.cxx +++ b/mod/mod-package-version-details.cxx @@ -205,8 +205,12 @@ handle (request& rq, response& rs) << ~TABLE << TABLE(CLASS="proplist", ID="package") - << TBODY - << TR_URL (pkg->url); + << TBODY; + + const auto& u (pkg->url); + + if (u) + s << TR_URL (*u); if (pkg->doc_url) s << TR_URL (*pkg->doc_url, "doc-url"); @@ -215,18 +219,20 @@ handle (request& rq, response& rs) s << TR_URL (*pkg->src_url, "src-url"); const auto& pu (pkg->package_url); - if (pu && *pu != pkg->url) + if (pu && pu != u) s << TR_URL (*pu, "package-url"); - const email& em (pkg->email); - s << TR_EMAIL (em); + const auto& em (pkg->email); + + if (em) + s << TR_EMAIL (*em); const auto& pe (pkg->package_email); - if (pe && *pe != em) + if (pe && pe != em) s << TR_EMAIL (*pe, "package-email"); const auto& be (pkg->build_email); - if (be && ((pe && *be != *pe) || (!pe && *be != em))) + if (be && ((pe && be != pe) || (!pe && be != em))) s << TR_EMAIL (*be, "build-email"); s << TR_TAGS (pkg->tags, root) -- cgit v1.1