From 7782c9b438aeb1b5b5bbc797b4eea6171a4d8d49 Mon Sep 17 00:00:00 2001 From: Zdenek Prikryl Date: Mon, 24 Aug 2009 17:37:25 +0200 Subject: added check for cc-list and reporter. +1 is created iff reporter is somebody else and current user isn't in cc list. --- lib/Plugins/Bugzilla.cpp | 41 +++++++++++++++++++++++++++++++++++++++-- lib/Plugins/Bugzilla.h | 1 + 2 files changed, 40 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/Plugins/Bugzilla.cpp b/lib/Plugins/Bugzilla.cpp index c5cbbb9a..527a9bd6 100644 --- a/lib/Plugins/Bugzilla.cpp +++ b/lib/Plugins/Bugzilla.cpp @@ -104,6 +104,40 @@ void CReporterBugzilla::Logout() } } +bool CReporterBugzilla::CheckCCAndReporter(const std::string& pBugId) +{ + xmlrpc_c::paramList paramList; + map_xmlrpc_params_t ret; + + paramList.add(xmlrpc_c::value_string(pBugId)); + xmlrpc_c::rpcPtr rpc(new xmlrpc_c::rpc("bugzilla.getBug", paramList)); + try + { + rpc->call(m_pXmlrpcClient, m_pCarriageParm); + ret = xmlrpc_c::value_struct(rpc->getResult()); + } + catch (std::exception& e) + { + throw CABRTException(EXCEP_PLUGIN, std::string("CReporterBugzilla::CheckCCAndReporter(): ") + e.what()); + } + std::string reporter = xmlrpc_c::value_string(ret["reporter"]); + if (reporter == m_sLogin) + { + return true; + } + std::vector ccs = xmlrpc_c::value_array(ret["cc"]).vectorValueValue(); + int ii; + for (ii = 0; ii < ccs.size(); ii++) + { + std::string cc = xmlrpc_c::value_string(ccs[ii]); + if (cc == m_sLogin) + { + return true; + } + } + return false; +} + void CReporterBugzilla::AddPlusOneComment(const std::string& pBugId) { xmlrpc_c::paramList paramList; @@ -183,8 +217,11 @@ std::string CReporterBugzilla::CheckUUIDInBugzilla(const std::string& pComponent comm_layer_inner_debug("Bug is already reported: " + ss.str()); comm_layer_inner_status("Bug is already reported: " + ss.str()); - AddPlusOneComment(ss.str()); - AddPlusOneCC(ss.str()); + if (!CheckCCAndReporter(ss.str())) + { + AddPlusOneComment(ss.str()); + AddPlusOneCC(ss.str()); + } return ss.str(); } return ""; diff --git a/lib/Plugins/Bugzilla.h b/lib/Plugins/Bugzilla.h index ab4ec407..6c7bfa0d 100644 --- a/lib/Plugins/Bugzilla.h +++ b/lib/Plugins/Bugzilla.h @@ -17,6 +17,7 @@ class CReporterBugzilla : public CReporter static PRInt32 Base64Encode_cb(void *arg, const char *obuf, PRInt32 size); void Login(); void Logout(); + bool CheckCCAndReporter(const std::string& pBugId); void AddPlusOneComment(const std::string& pBugId); void AddPlusOneCC(const std::string& pBugId); std::string CheckUUIDInBugzilla(const std::string& pComponent, const std::string& pUUID); -- cgit