aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/bzpage.js68
-rw-r--r--lib/logger.js6
-rw-r--r--lib/rhbzpage.js20
-rw-r--r--lib/util.js7
4 files changed, 77 insertions, 24 deletions
diff --git a/lib/bzpage.js b/lib/bzpage.js
index 2f4436f..998e64d 100644
--- a/lib/bzpage.js
+++ b/lib/bzpage.js
@@ -12,6 +12,8 @@ var simpleStorage = require("simple-storage");
var preferences = require("preferences-service");
var selection = require("selection");
var prompts = require("prompts");
+var xrpc = require("xmlrpc");
+var Request = require("request").Request;
var tabs = require("tabs");
var Color = require("color").Color;
@@ -44,6 +46,7 @@ var BZPage = function BZPage(win, config) {
// 85
this.ReporterColor = new Color(255, 255, 166); // RGB 255, 255, 166; HSL 60, 2,
// 83
+
// initialize dynamic properties
var that = this;
this.win = win;
@@ -72,6 +75,8 @@ var BZPage = function BZPage(win, config) {
this.constantData = config.gJSONData.constantData;
this.constantData.queryUpstreamBug = JSON.parse(
selfMod.data.load("queryUpstreamBug.json"));
+ this.constantData.XMLRPCData = JSON.parse(
+ selfMod.data.load("XMLRPCdata.json"));
}
if ("CCmaintainer" in this.constantData) {
@@ -100,7 +105,19 @@ var BZPage = function BZPage(win, config) {
this.setConfigurationButton();
this.submitHandlerInstalled = false;
+
+ this.login = this.getLogin();
+ // XML-RPC password
+ if (this.hostname in this.constantData.XMLRPCData) {
+ this.password = this.getPassword(this.login);
+ }
+
this.bugNo = util.getBugNo(this.doc.location.toString());
+
+ // deal with aliases
+ if (isNaN(parseInt(this.bugNo, 10)) && this.password) {
+ this.bugNo = this.getRealBugNo();
+ }
this.title = this.doc.getElementById("short_desc_nonedit_display").textContent;
this.CCList = this.getCCList();
@@ -134,6 +151,45 @@ BZPage.prototype.getBugId = function getBugId () {
return util.getBugNo(this.doc.location.href);
};
+BZPage.prototype.getRealBugNo = function () {
+ console.log("we have to deal with bug aliased as " + this.bugNo);
+ var that = this;
+
+ // https://bugzilla.redhat.com/show_bug.cgi?ctype=xml&id=serialWacom
+
+ var xmlrpcMsg = new xrpc.XMLRPCMessage("User.login");
+ xmlrpcMsg.addParameter({
+ login: this.login,
+ password: this.password,
+ remember: 1
+ });
+ Request({
+ url: this.constantData.XMLRPCData[this.hostname].url,
+ onComplete: function() {
+ if (this.response.status == 200) {
+ xmlrpcMsg = new xrpc.XMLRPCMessage("Bug.get");
+ xmlrpcMsg.addParameter({
+ ids: util.getParamsFromURL(that.win.location.href)['id']
+ });
+ console.log("XML-RPC message:\n" + xmlrpcMsg.xml());
+ Request({
+ url: that.constantData.XMLRPCData[that.hostname].url,
+ onComplete: function() {
+ if (this.response.status === 200) {
+ console.log("response = " + this.response.text);
+ //if
+ }
+ },
+ content: xmlrpcMsg.xml(),
+ contentType: "text/xml"
+ }).post();
+ }
+ },
+ content: xmlrpcMsg.xml(),
+ contentType: "text/xml"
+ }).post();
+};
+
/**
*
*/
@@ -761,6 +817,18 @@ BZPage.prototype.getAttachments = function getAttachments () {
};
/**
+ * Get login of the currently logged-in user.
+ *
+ * @return String with the login name of the currently logged-in user
+ */
+BZPage.prototype.getLogin = function getLogin () {
+ var lastLIElement = this.doc.querySelector("#header ul.links li:last-of-type");
+ var loginArr = lastLIElement.textContent.split("\n");
+ var loginStr = loginArr[loginArr.length - 1].trim();
+ return loginStr;
+};
+
+/**
* returns password from the current storage, or if there isn't
* one, then it will ask user for it.
*
diff --git a/lib/logger.js b/lib/logger.js
index 71514c9..1175bf8 100644
--- a/lib/logger.js
+++ b/lib/logger.js
@@ -7,6 +7,7 @@ var Color = require("color").Color;
var tabs = require("tabs");
var prompts = require("prompts");
var apiUtils = require("api-utils");
+var xrpc = require("xmlrpc");
function Logger(store, abbsMap) {
this.EmptyLogsColor = new Color(0, 255, 0);
@@ -83,7 +84,8 @@ Logger.prototype.timeSheetRecordsPrinter = function(body, records) {
var bugNo = utilMod.getBugNo(x.url);
// protection against misbehaving URLs
if (!bugNo) {
- throw new Error("wrong record:\n" + rec.toSource() + "\n");
+ console.error("wrong record:\n" + rec.toSource() + "\n");
+ return false;
}
if (dayStr != currentDay) {
currentDay = dayStr;
@@ -126,4 +128,4 @@ Logger.prototype.createBlankPage = function (ttl, bodyBuildCB) {
Logger.prototype.generateTimeSheet = function(body) {
var doc = body.ownerDocument;
this.timeSheetRecordsPrinter(body, this.store);
-}; \ No newline at end of file
+};
diff --git a/lib/rhbzpage.js b/lib/rhbzpage.js
index 1e870f7..5e8291d 100644
--- a/lib/rhbzpage.js
+++ b/lib/rhbzpage.js
@@ -51,8 +51,6 @@ var RHBugzillaPage = function RHBugzillaPage(win, config) {
frameNo: new RegExp("^\\s*#([0-9]*)\\s"),
soughtLines: new RegExp("^\\s*(\\[[0-9 .]*\\])?\\s*\\((EE|WW)\\)|\\s*Backtrace")
};
-
- this.constantData.XMLRPCData = JSON.parse(self.data.load("XMLRPCdata.json"));
// END OF CONSTANTS
var that = this;
@@ -60,7 +58,6 @@ var RHBugzillaPage = function RHBugzillaPage(win, config) {
this.signaturesCounter = 0;
this.chipMagicInterestingLine = "";
- this.login = this.getLogin();
this.product = this.doc.getElementById("product").value;
this.maintCCAddr = null;
@@ -72,11 +69,6 @@ var RHBugzillaPage = function RHBugzillaPage(win, config) {
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);
- }
-
if (!this.constantData.ProfessionalProducts) {
this.constantData.ProfessionalProducts =
JSON.parse(self.data.load("professionalProducts.json"));
@@ -150,18 +142,6 @@ RHBugzillaPage.prototype = util.heir(BZPage);
RHBugzillaPage.prototype.constructor = RHBugzillaPage;
/**
- * Get login of the currently logged-in user.
- *
- * @return String with the login name of the currently logged-in user
- */
-RHBugzillaPage.prototype.getLogin = function getLogin () {
- var lastLIElement = this.doc.querySelector("#header ul.links li:last-of-type");
- var loginArr = lastLIElement.textContent.split("\n");
- var loginStr = loginArr[loginArr.length - 1].trim();
- return loginStr;
-};
-
-/**
* Find default assignee based on the current component
*
* @return String what would be a default assignee if
diff --git a/lib/util.js b/lib/util.js
index 76c8a02..18a3c1b 100644
--- a/lib/util.js
+++ b/lib/util.js
@@ -60,10 +60,13 @@ var getParamsFromURL = exports.getParamsFromURL = function getParamsFromURL (url
return params;
};
+/**
+ * FIXME this should go to bzpage.js ... no reason to keep it here
+ */
exports.getBugNo = function getBugNo(url) {
var params = getParamsFromURL(url);
if (params && params.id) {
- return parseInt(params.id, 10);
+ return params.id;
}
};
@@ -207,4 +210,4 @@ exports.getObjectKeys = function getObjectKeys(obj) {
}
}
return keys;
-}; \ No newline at end of file
+};