From e71aebba83efe673bfb554a9fbf1533b7a96bde8 Mon Sep 17 00:00:00 2001 From: Jakub Filak Date: Wed, 8 Oct 2014 12:10:10 +0200 Subject: [PATCH] rhtsupport: attach the contact email to bthash Related to rhbz#1150388 Signed-off-by: Jakub Filak --- src/plugins/reporter-rhtsupport.c | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/src/plugins/reporter-rhtsupport.c b/src/plugins/reporter-rhtsupport.c index 9704c3c..9e463a8 100644 --- a/src/plugins/reporter-rhtsupport.c +++ b/src/plugins/reporter-rhtsupport.c @@ -263,6 +263,16 @@ char *submit_ureport(const char *dump_dir_name, struct ureport_server_config *co } static +void attach_to_ureport(struct ureport_server_config *conf, + const char *bthash, const char *attach_id, const char *data) +{ + char *json = ureport_json_attachment_new(bthash, attach_id, data); + struct ureport_server_response *resp = ureport_do_post_credentials(json, conf, UREPORT_ATTACH_ACTION); + ureport_server_response_free(resp); + free(json); +} + +static bool check_for_hints(const char *url, char **login, char **password, bool ssl_verify, const char *tempfile) { rhts_result_t *result = NULL; @@ -741,11 +751,17 @@ int main(int argc, char **argv) /* Make sure we use the current credentials */ ureport_server_config_set_basic_auth(&urconf, login, password); - /* Do attach */ - char *json = ureport_json_attachment_new(bthash, "RHCID", result->url); - struct ureport_server_response *resp = ureport_do_post_credentials(json, &urconf, UREPORT_ATTACH_ACTION); - ureport_server_response_free(resp); - free(json); + /* Attach Customer Case ID*/ + attach_to_ureport(&urconf, bthash, "RHCID", result->url); + + /* Attach Contact e-mail if configured */ + const char *email = NULL; + UREPORT_OPTION_VALUE_FROM_CONF(ursettings, "ContactEmail", email, (const char *)); + if (email != NULL) + { + log(_("Linking ABRT crash statistics record with contact email: '%s'"), email); + attach_to_ureport(&urconf, bthash, "email", email); + } /* Update the credentials */ STRCPY_IF_NOT_EQUAL(login, urconf.ur_username); -- 2.1.0