diff --git a/jira@codeunifier/files/jira@codeunifier/lib/jira.js b/jira@codeunifier/files/jira@codeunifier/lib/jira.js index ebf8f5300..7dfba8d9d 100644 --- a/jira@codeunifier/files/jira@codeunifier/lib/jira.js +++ b/jira@codeunifier/files/jira@codeunifier/lib/jira.js @@ -1,7 +1,13 @@ const Soup = imports.gi.Soup; +const ByteArray = imports.byteArray; -const _httpSession = new Soup.SessionAsync(); -Soup.Session.prototype.add_feature.call(_httpSession, new Soup.ProxyResolverDefault()); +var _httpSession; +if (Soup.MAJOR_VERSION === 2) { + _httpSession = new Soup.SessionAsync(); + Soup.Session.prototype.add_feature.call(_httpSession, new Soup.ProxyResolverDefault()); +} else { + _httpSession = new Soup.Session(); +} var JiraUtility = function() {}; @@ -19,16 +25,34 @@ JiraUtility.prototype.getAssigned = function (here, callback) { _httpSession.timeout = 10; _httpSession.idle_timeout = 10; - _httpSession.queue_message(message, function (session, message) { - if (message.status_code == 200) { - try { - callback.call(here, message.response_body.data.toString()); - } catch (e) { - global.logError(IDEN + ': ERROR | ' + e.message); - callback.call(here, null); + + if (Soup.MAJOR_VERSION === 2) { + _httpSession.queue_message(message, function (session, message) { + if (message.status_code == 200) { + try { + callback.call(here, message.response_body.data.toString()); + } catch (e) { + global.logError(IDEN + ': ERROR | ' + e.message); + callback.call(here, null); + } + } else { + global.logError(IDEN + ': BAD_API | ' + message.status_code); + } + }); + } else { + _httpSession.send_and_read_async(message, 0, null, (session, res) => { + if (message.get_status() === Soup.Status.OK) { + try { + const bytes = session.send_and_read_finish(res); + const data = ByteArray.toString(bytes.get_data()); + callback.call(here, data); + } catch (e) { + global.logError(IDEN + ': ERROR | ' + e.message); + } + } else { + global.logError(IDEN + ': BAD_API | ' + message.get_status()); } - } else { - global.logError(IDEN + ': BAD_API | ' + message.status_code); - } - }); + }); + } + }; \ No newline at end of file