Blame 0001-rhbz-Replace-nomail-flag-with-minor_update.patch

46d8661
From 569bf0e3fed698e93b8e098bf6a0bb2f773aed6a Mon Sep 17 00:00:00 2001
46d8661
From: Martin Kutlak <mkutlak@redhat.com>
46d8661
Date: Fri, 4 Jan 2019 12:26:28 +0100
46d8661
Subject: [PATCH] rhbz: Replace nomail flag with minor_update
46d8661
46d8661
In Bugzilla v5.0 nomail flag is replaced with minor_update. [1]
46d8661
Because we still use the old nomail flag emails are being sent for every added attachment/comment.
46d8661
46d8661
Related: rhbz#1660157
46d8661
Closes: abrt/abrt#1346
46d8661
46d8661
See also:
46d8661
- https://partner-bugzilla.redhat.com/docs/en/html/integrating/api/Bugzilla/WebService/Bug.html?highlight=minor_update
46d8661
46d8661
[1] https://bugzilla.redhat.com/show_bug.cgi?id=1655829
46d8661
46d8661
Signed-off-by: Martin Kutlak <mkutlak@redhat.com>
46d8661
---
46d8661
 src/plugins/reporter-bugzilla.c | 12 +++++-----
46d8661
 src/plugins/rhbz.c              | 41 ++++++++++++++++++---------------
46d8661
 src/plugins/rhbz.h              |  4 ++--
46d8661
 3 files changed, 30 insertions(+), 27 deletions(-)
46d8661
46d8661
diff --git a/src/plugins/reporter-bugzilla.c b/src/plugins/reporter-bugzilla.c
46d8661
index d4d03f8e..c12e00d1 100644
46d8661
--- a/src/plugins/reporter-bugzilla.c
46d8661
+++ b/src/plugins/reporter-bugzilla.c
46d8661
@@ -35,7 +35,7 @@ int attach_text_item(struct abrt_xmlrpc *ax, const char *bug_id,
46d8661
     log_debug("attaching '%s' as text", item_name);
46d8661
     int r = rhbz_attach_blob(ax, bug_id,
46d8661
                 item_name, item->content, strlen(item->content),
46d8661
-                RHBZ_NOMAIL_NOTIFY
46d8661
+                RHBZ_MINOR_UPDATE
46d8661
     );
46d8661
     return (r == 0);
46d8661
 }
46d8661
@@ -63,7 +63,7 @@ int attach_file_item(struct abrt_xmlrpc *ax, const char *bug_id,
46d8661
         return 0;
46d8661
     }
46d8661
     log_debug("attaching '%s' as file", item_name);
46d8661
-    int flag = RHBZ_NOMAIL_NOTIFY;
46d8661
+    int flag = RHBZ_MINOR_UPDATE;
46d8661
     if (!(item->flags & CD_FLAG_BIGTXT))
46d8661
         flag |= RHBZ_BINARY_ATTACHMENT;
46d8661
     int r = rhbz_attach_fd(ax, bug_id, item_name, fd, flag);
46d8661
@@ -793,7 +793,7 @@ int main(int argc, char **argv)
46d8661
                 if (reported_to && reported_to->url)
46d8661
                 {
46d8661
                     log_warning(_("Adding External URL to bug %i"), new_id);
46d8661
-                    rhbz_set_url(client, new_id, reported_to->url, RHBZ_NOMAIL_NOTIFY);
46d8661
+                    rhbz_set_url(client, new_id, reported_to->url, RHBZ_MINOR_UPDATE);
46d8661
                     free_report_result(reported_to);
46d8661
                 }
46d8661
             }
46d8661
@@ -821,7 +821,7 @@ int main(int argc, char **argv)
46d8661
             if (existing_id >= 0)
46d8661
             {
46d8661
                 log_warning(_("Closing bug %i as duplicate of bug %i"), new_id, existing_id);
46d8661
-                rhbz_close_as_duplicate(client, new_id, existing_id, RHBZ_NOMAIL_NOTIFY);
46d8661
+                rhbz_close_as_duplicate(client, new_id, existing_id, RHBZ_MINOR_UPDATE);
46d8661
             }
46d8661
 
46d8661
             goto log_out;
46d8661
@@ -876,7 +876,7 @@ int main(int argc, char **argv)
46d8661
      && !g_list_find_custom(bz->bi_cc_list, rhbz.b_login, (GCompareFunc)g_strcmp0)
46d8661
     ) {
46d8661
         log_warning(_("Adding %s to CC list"), rhbz.b_login);
46d8661
-        rhbz_mail_to_cc(client, bz->bi_id, rhbz.b_login, RHBZ_NOMAIL_NOTIFY);
46d8661
+        rhbz_mail_to_cc(client, bz->bi_id, rhbz.b_login, RHBZ_MINOR_UPDATE);
46d8661
     }
46d8661
 
46d8661
     /* Add comment and bt */
46d8661
@@ -911,7 +911,7 @@ int main(int argc, char **argv)
46d8661
                 sprintf(bug_id_str, "%i", bz->bi_id);
46d8661
                 log_warning(_("Attaching better backtrace"));
46d8661
                 rhbz_attach_blob(client, bug_id_str, FILENAME_BACKTRACE, bt, strlen(bt),
46d8661
-                                 RHBZ_NOMAIL_NOTIFY);
46d8661
+                                 RHBZ_MINOR_UPDATE);
46d8661
             }
46d8661
         }
46d8661
         else
46d8661
diff --git a/src/plugins/rhbz.c b/src/plugins/rhbz.c
46d8661
index 680527d7..cb6505ea 100644
46d8661
--- a/src/plugins/rhbz.c
46d8661
+++ b/src/plugins/rhbz.c
46d8661
@@ -605,7 +605,7 @@ int rhbz_new_bug(struct abrt_xmlrpc *ax,
46d8661
     return new_bug_id;
46d8661
 }
46d8661
 
46d8661
-/* suppress mail notify by {s:i} (nomail:1) (driven by flag) */
46d8661
+/* suppress mail notify by {s:i} (minor_update:1) (driven by flag) */
46d8661
 int rhbz_attach_blob(struct abrt_xmlrpc *ax, const char *bug_id,
46d8661
                 const char *filename, const char *data, int data_len, int flags)
46d8661
 {
46d8661
@@ -620,7 +620,7 @@ int rhbz_attach_blob(struct abrt_xmlrpc *ax, const char *bug_id,
46d8661
 
46d8661
     char *fn = xasprintf("File: %s", filename);
46d8661
     xmlrpc_value* result;
46d8661
-    int nomail_notify = !!IS_NOMAIL_NOTIFY(flags);
46d8661
+    int minor_update = !!IS_MINOR_UPDATE(flags);
46d8661
 
46d8661
     /* http://www.bugzilla.org/docs/4.2/en/html/api/Bugzilla/WebService/Bug.html#add_attachment
46d8661
      *
46d8661
@@ -640,10 +640,11 @@ int rhbz_attach_blob(struct abrt_xmlrpc *ax, const char *bug_id,
46d8661
                  */
46d8661
                 "data", data, (size_t)data_len,
46d8661
 
46d8661
-                /* Undocumented argument but it works with Red Hat Bugzilla version 4.2.4-7
46d8661
-                 * and version 4.4.rc1.b02
46d8661
+                /* If set to true, this is considered a minor update and no mail is sent to users who do not want
46d8661
+                 * minor update emails. If current user is not in the minor_update_group, this parameter is simply
46d8661
+                 * ignored.
46d8661
                  */
46d8661
-                "nomail", nomail_notify
46d8661
+                "minor_update", minor_update
46d8661
     );
46d8661
 
46d8661
     free(fn);
46d8661
@@ -737,25 +738,25 @@ struct bug_info *rhbz_find_origin_bug_closed_duplicate(struct abrt_xmlrpc *ax,
46d8661
     return bi_tmp;
46d8661
 }
46d8661
 
46d8661
-/* suppress mail notify by {s:i} (nomail:1) */
46d8661
+/* suppress mail notify by {s:i} (minor_update:1) */
46d8661
 void rhbz_mail_to_cc(struct abrt_xmlrpc *ax, int bug_id, const char *mail, int flags)
46d8661
 {
46d8661
     func_entry();
46d8661
 
46d8661
     xmlrpc_value *result;
46d8661
-    int nomail_notify = !!IS_NOMAIL_NOTIFY(flags);
46d8661
+    int minor_update = !!IS_MINOR_UPDATE(flags);
46d8661
 #if 0 /* Obsolete API */
46d8661
     result = abrt_xmlrpc_call(ax, "Bug.update", "({s:i,s:{s:(s),s:i}})",
46d8661
                               "ids", bug_id,
46d8661
                               "updates", "add_cc", mail,
46d8661
-                                         "nomail", nomail_notify
46d8661
+                                         "minor_update", minor_update
46d8661
     );
46d8661
 #endif
46d8661
     /* Bugzilla 4.0+ uses this API: */
46d8661
     result = abrt_xmlrpc_call(ax, "Bug.update", "{s:i,s:{s:(s),s:i}}",
46d8661
                               "ids", bug_id,
46d8661
                               "cc", "add", mail,
46d8661
-                                    "nomail", nomail_notify
46d8661
+                                    "minor_update", minor_update
46d8661
     );
46d8661
     if (result)
46d8661
         xmlrpc_DECREF(result);
46d8661
@@ -786,12 +787,12 @@ void rhbz_add_comment(struct abrt_xmlrpc *ax, int bug_id, const char *comment,
46d8661
     func_entry();
46d8661
 
46d8661
     int private = !!IS_PRIVATE(flags);
46d8661
-    int nomail_notify = !!IS_NOMAIL_NOTIFY(flags);
46d8661
+    int minor_update = !!IS_MINOR_UPDATE(flags);
46d8661
 
46d8661
     xmlrpc_value *result;
46d8661
     result = abrt_xmlrpc_call(ax, "Bug.add_comment", "{s:i,s:s,s:b,s:i}",
46d8661
                               "id", bug_id, "comment", comment,
46d8661
-                              "private", private, "nomail", nomail_notify);
46d8661
+                              "private", private, "minor_update", minor_update);
46d8661
 
46d8661
     if (result)
46d8661
         xmlrpc_DECREF(result);
46d8661
@@ -801,15 +802,16 @@ void rhbz_set_url(struct abrt_xmlrpc *ax, int bug_id, const char *url, int flags
46d8661
 {
46d8661
     func_entry();
46d8661
 
46d8661
-    const int nomail_notify = !!IS_NOMAIL_NOTIFY(flags);
46d8661
+    const int minor_update = !!IS_MINOR_UPDATE(flags);
46d8661
     xmlrpc_value *result = abrt_xmlrpc_call(ax, "Bug.update", "{s:i,s:s,s:i}",
46d8661
                               "ids", bug_id,
46d8661
                               "url", url,
46d8661
 
46d8661
-                /* Undocumented argument but it works with Red Hat Bugzilla version 4.2.4-7
46d8661
-                 * and version 4.4.rc1.b02
46d8661
+                /* If set to true, this is considered a minor update and no mail is sent to users who do not want
46d8661
+                 * minor update emails. If current user is not in the minor_update_group, this parameter is simply
46d8661
+                 * ignored.
46d8661
                  */
46d8661
-                              "nomail", nomail_notify
46d8661
+                              "minor_update", minor_update
46d8661
     );
46d8661
 
46d8661
     if (result)
46d8661
@@ -822,17 +824,18 @@ void rhbz_close_as_duplicate(struct abrt_xmlrpc *ax, int bug_id,
46d8661
 {
46d8661
     func_entry();
46d8661
 
46d8661
-    const int nomail_notify = !!IS_NOMAIL_NOTIFY(flags);
46d8661
+    const int minor_update = !!IS_MINOR_UPDATE(flags);
46d8661
     xmlrpc_value *result = abrt_xmlrpc_call(ax, "Bug.update", "{s:i,s:s,s:s,s:i,s:i}",
46d8661
                               "ids", bug_id,
46d8661
                               "status", "CLOSED",
46d8661
                               "resolution", "DUPLICATE",
46d8661
                               "dupe_of", duplicate_bug,
46d8661
 
46d8661
-                /* Undocumented argument but it works with Red Hat Bugzilla version 4.2.4-7
46d8661
-                 * and version 4.4.rc1.b02
46d8661
+                /* If set to true, this is considered a minor update and no mail is sent to users who do not want
46d8661
+                 * minor update emails. If current user is not in the minor_update_group, this parameter is simply
46d8661
+                 * ignored.
46d8661
                  */
46d8661
-                              "nomail", nomail_notify
46d8661
+                              "minor_update", minor_update
46d8661
     );
46d8661
 
46d8661
     if (result)
46d8661
diff --git a/src/plugins/rhbz.h b/src/plugins/rhbz.h
46d8661
index 86632a35..3990eda0 100644
46d8661
--- a/src/plugins/rhbz.h
46d8661
+++ b/src/plugins/rhbz.h
46d8661
@@ -36,7 +36,7 @@ enum {
46d8661
     RHBZ_MANDATORY_MEMB      = (1 << 0),
46d8661
     RHBZ_READ_STR            = (1 << 1),
46d8661
     RHBZ_READ_INT            = (1 << 2),
46d8661
-    RHBZ_NOMAIL_NOTIFY       = (1 << 3),
46d8661
+    RHBZ_MINOR_UPDATE        = (1 << 3),
46d8661
     RHBZ_PRIVATE             = (1 << 4),
46d8661
     RHBZ_BINARY_ATTACHMENT   = (1 << 5),
46d8661
 };
46d8661
@@ -44,7 +44,7 @@ enum {
46d8661
 #define IS_MANDATORY(flags) ((flags) & RHBZ_MANDATORY_MEMB)
46d8661
 #define IS_READ_STR(flags) ((flags) & RHBZ_READ_STR)
46d8661
 #define IS_READ_INT(flags) ((flags) & RHBZ_READ_INT)
46d8661
-#define IS_NOMAIL_NOTIFY(flags) ((flags) & RHBZ_NOMAIL_NOTIFY)
46d8661
+#define IS_MINOR_UPDATE(flags) ((flags) & RHBZ_MINOR_UPDATE)
46d8661
 #define IS_PRIVATE(flags) ((flags) & RHBZ_PRIVATE)
46d8661
 
46d8661
 struct bug_info {
46d8661
-- 
46d8661
2.17.2
46d8661