aboutsummaryrefslogtreecommitdiffstats
path: root/data/rhlib/addAttachmentRow.js
diff options
context:
space:
mode:
authorMatěj Cepl <mcepl@redhat.com>2011-05-13 13:40:14 +0200
committerMatěj Cepl <mcepl@redhat.com>2011-05-13 13:40:14 +0200
commitfd9319c3297c854cdb269c9704152f7b24c12273 (patch)
treeb9a9f65a478665ef999d60cbee0f44d97003b850 /data/rhlib/addAttachmentRow.js
parent055324f75df68eab8a3752d2aeedcbe9318cf797 (diff)
downloadbugzilla-triage-fd9319c3297c854cdb269c9704152f7b24c12273.tar.gz
Move RH BZ-related XMLRPC calls to data/rhlib/ directory.
Fixes #79
Diffstat (limited to 'data/rhlib/addAttachmentRow.js')
-rw-r--r--data/rhlib/addAttachmentRow.js63
1 files changed, 63 insertions, 0 deletions
diff --git a/data/rhlib/addAttachmentRow.js b/data/rhlib/addAttachmentRow.js
new file mode 100644
index 0000000..63babcd
--- /dev/null
+++ b/data/rhlib/addAttachmentRow.js
@@ -0,0 +1,63 @@
+//Released under the MIT/X11 license
+//http://www.opensource.org/licenses/mit-license.php
+"use strict";
+
+//FIXME resp is JSON, not XML anymore
+function addAttachmentCallback(resp) {
+ var newAttachID = parseInt(
+ resp.params.param.value.array.data.value.int, 10);
+ console.log("attachID = " + newAttachID);
+ // FIXME callback.call(param, newAttachID, data.length);
+}
+
+/**
+ *
+ * This has to stay in RHBugzillaPage because upstream doesn't have
+ * addAttachment XML-RPC call yet.
+ *
+ Params: $params = {
+ id => '<bug_id>', # ID of the bug report
+ comment => "<Attachment Comment>", # OPTIONAL Text string containing comment to add.
+ description => "<Attachment Description>", # REQUIRED Text Description of the attachment.
+ isprivate => <Private Attachment ON/OFF 1/0>, # OPTIONAL Whether the Attachment
+ will be private # Default: false
+ filename => "<Attachment Filename>", REQUIRED The name of the file to attach to the bug report.
+ obsoletes => [List of attach_id's to obsolete], OPTIONAL List if attachment ids that are
+ obsoleted by this new attachment.
+ ispatch => <Patch Attachment True/False 1/0>, OPTIONAL Whether the attachment is a Patch
+ or not, if not provided the it will be considered NON Patch attachment.
+ contenttype => "<Attachment Content Type>", OPTIONAL If the attachment is patch
+ REQUIRED If the attachment is not a patch
+ If the attachment is patch then contenttype will always be text/plain
+ data => "<Encoded String of the Attachment Data>", REQUIRED It is a base64
+ encoded string of the actual attachment data.
+ nomail => 0, OPTIONAL Flag that is either 1 or 0 if you want email
+ to be send ot not for this change }
+ */
+function addAttachment(data, callback, param) {
+ var params = [];
+
+ if (!constantData.passwordState.passAvailable) {
+ console
+ .error("addAttachment : No password, no XML-RPC calls; sorry");
+ return null;
+ }
+
+ var params = {
+ id : getBugNo(),
+ description : titleParsedAttachment,
+ filename : "parsed-backtrace.txt",
+ contenttype : "text/plain",
+ data : window.btoa(data),
+ nomail : true
+ };
+
+ self.postMessage(new Message("MakeJSONRPCall", {
+ url : constantData.XMLRPCData[window.location.hostname].url
+ .replace("xmlrpc.cgi", "jsonrpc.cgi"),
+ method : "bugzilla.addAttachment",
+ params : params,
+ callRPC : "AddAttachmentCallback"
+ }));
+ reqCounter++;
+}