diff options
author | Matěj Cepl <mcepl@redhat.com> | 2010-07-17 09:04:48 +0200 |
---|---|---|
committer | Matěj Cepl <mcepl@redhat.com> | 2010-07-17 09:13:52 +0200 |
commit | 34ae7055a0f01306be67dc00030af93190deca55 (patch) | |
tree | bec978682872324e92aa7ffdcdcab32e99113a49 | |
parent | 90ae10b0d1181cedb1c31a20e2194a59896223fd (diff) | |
download | bugzilla-triage-34ae7055a0f01306be67dc00030af93190deca55.tar.gz |
Make XMLRPC service independent of a bugzilla instance.
- activates password dialog only for bugzillas which actually need it
- XML-RPC URL is stored in data/XMLRPCdata.json
Fixes #23
-rw-r--r-- | data/XMLRPCdata.json | 8 | ||||
-rw-r--r-- | lib/bzpage.js | 9 | ||||
-rw-r--r-- | lib/main.js | 5 | ||||
-rw-r--r-- | lib/rhbzpage.js | 10 | ||||
-rw-r--r-- | lib/util.js | 2 |
5 files changed, 20 insertions, 14 deletions
diff --git a/data/XMLRPCdata.json b/data/XMLRPCdata.json new file mode 100644 index 0000000..4dab662 --- /dev/null +++ b/data/XMLRPCdata.json @@ -0,0 +1,8 @@ +{ + "bugzilla.redhat.com": { + "url": "https://bugzilla.redhat.com/xmlrpc.cgi" + }, + "bz-web2-test.devel.redhat.com": { + "url": "https://bz-web2-test.devel.redhat.com/xmlrpc.cgi" + } +}
\ No newline at end of file diff --git a/lib/bzpage.js b/lib/bzpage.js index 25c9498..9fa02c0 100644 --- a/lib/bzpage.js +++ b/lib/bzpage.js @@ -46,6 +46,7 @@ var BZPage = function BZPage(win, config) { var that = this; this.win = win; this.doc = win.document; + this.hostname = this.win.location.hostname; // First, preflight check ... if we are not logged in, there // is nothing we can do. @@ -132,14 +133,13 @@ BZPage.prototype.getBugId = function getBugId () { BZPage.prototype.getInstalledPackages = function getInstalledPackages(cfg) { var installedPackages = {}; var enabledPackages = []; - var hostname = this.win.location.hostname; // Collect enabled packages per hostname (plus default ones) if (cfg.gJSONData && ("commentPackages" in cfg.gJSONData)) { if ("enabledPackages" in cfg.gJSONData.configData) { var epObject = cfg.gJSONData.configData.enabledPackages; - if (hostname in epObject) { - enabledPackages = enabledPackages.concat(epObject[hostname].split(/[, ]/)); + if (this.hostname in epObject) { + enabledPackages = enabledPackages.concat(epObject[this.hostname].split(/[, ]/)); } if ("any" in epObject) { enabledPackages = enabledPackages.concat(epObject["any"].split(/[, ]/)); @@ -710,8 +710,7 @@ BZPage.prototype.getPassword = function getPassword (login) { var passPrompt = "Enter your Bugzilla password for fixing MIME attachment types"; var switchPrompt = "Do you want to switch off features requiring password completely?"; var prefName = BTSPrefNS+"withoutPassowrd"; - var loc = this.win.location; - var domain = loc.protocol + "//" + loc.hostname; + var domain = this.win.location.protocol + "//" + this.hostname; var pass = passUtils.getPassword(login, domain, BTSPassRealm); // pass === null means no appropriate password in the storage diff --git a/lib/main.js b/lib/main.js index 07ef3c6..66f90f9 100644 --- a/lib/main.js +++ b/lib/main.js @@ -15,7 +15,6 @@ var util = require("util"); var logger = require("logger"); var myStorage = require("simple-storage").storage; var browser = require("tab-browser"); -var urlMod = require("url"); var selfMod = require("self"); var Request = require("request").Request; var preferences = require("preferences-service"); @@ -24,8 +23,6 @@ var BTSPrefNS = require("bzpage").BTSPrefNS; var JSONURLDefault = "https://fedorahosted.org/released"+ "/bugzilla-triage-scripts/Config_data.json"; -var XMLRPCurl = "https://bugzilla.redhat.com/xmlrpc.cgi"; - var config = {}; (function (){ var matchesAll = JSON.parse(selfMod.data.load("matches.json")); @@ -49,7 +46,7 @@ function skipThisPage(doc) { var stemURL = "https://HOSTNAME/show_bug.cgi?id="; var titleStr = doc.getElementsByTagName("title")[0].textContent; var REArr = new RegExp("[bB]ug\\s+([0-9]+)").exec(titleStr); - var hostname = urlMod.URL(doc.location.href).host; + var hostname = doc.location.hostname; if (REArr) { var bugNo = REArr[1]; var emailsSent = doc. diff --git a/lib/rhbzpage.js b/lib/rhbzpage.js index 44b3265..1e6f52d 100644 --- a/lib/rhbzpage.js +++ b/lib/rhbzpage.js @@ -60,7 +60,7 @@ var RHBugzillaPage = function RHBugzillaPage(win, config) { frameNo: new RegExp("^\\s*#([0-9]*)\\s") }; - this.XMLRPCurl = "https://bugzilla.redhat.com/xmlrpc.cgi"; + this.constantData.XMLRPCData = JSON.parse(self.data.load("XMLRPCdata.json")); // END OF CONSTANTS var that = this; @@ -69,11 +69,15 @@ var RHBugzillaPage = function RHBugzillaPage(win, config) { this.chipMagicInterestingLine = ""; this.login = this.getLogin(); - this.password = this.getPassword(this.login); var ITbutton = this.doc.getElementById("cf_issuetracker"); this.its = ITbutton ? ITbutton.value.trim() : ""; + // XML-RPC password + if (this.hostname in this.constantData.XMLRPCData) { + this.password = this.getPassword(this.login); + } + // getBadAttachments this.XorgLogAttList = []; this.XorgLogAttListIndex = 0; @@ -785,7 +789,7 @@ RHBugzillaPage.prototype.fixAttachById = function(id, type, email) { // docs/en/html/api/extensions/compat_xmlrpc/code/webservice.html // test on https://bugzilla.redhat.com/show_bug.cgi?id=485145 Request({ - url: this.XMLRPCurl, + url: this.constantData.XMLRPCData[this.hostname], onComplete: function() { that.fixingMIMECallBack.call(that); }, diff --git a/lib/util.js b/lib/util.js index e3676ca..02e95bb 100644 --- a/lib/util.js +++ b/lib/util.js @@ -4,8 +4,6 @@ // http://www.opensource.org/licenses/mit-license.php "use strict"; // ============================================================== -var xhrMod = require("xhr"); -var urlMod = require("url"); var {Cc,Ci} = require("chrome"); /** |