Blame SOURCES/0097-rhtsupport-attach-the-contact-email-to-bthash.patch

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