diff --git a/background.html b/background.html index f91f9a561b..c7cb3f6008 100644 --- a/background.html +++ b/background.html @@ -698,7 +698,7 @@ sudo apt update && sudo apt install signal-desktop
@@ -717,7 +717,7 @@ sudo apt update && sudo apt install signal-desktop diff --git a/js/debugLog.js b/js/debugLog.js index cc213562e5..0d621ec46d 100644 --- a/js/debugLog.js +++ b/js/debugLog.js @@ -42,6 +42,7 @@ var MAX_MESSAGES = 2000; var PHONE_REGEX = /\+\d{7,12}(\d{3})/g; + var DEBUGLOGS_BASE_URL = 'https://debuglogs.org'; var log = new DebugLog(); if (window.console) { console._log = console.log; @@ -60,13 +61,51 @@ if (log === undefined) { log = console.get(); } - return new Promise(function(resolve) { - $.post('https://api.github.com/gists', textsecure.utils.jsonThing({ - "files": { "debugLog.txt": { "content": log } } - })).then(function(response) { - console._log('Posted debug log to ', response.html_url); - resolve(response.html_url); - }).fail(resolve); + + return new Promise(function(resolve, reject) { + $.get(DEBUGLOGS_BASE_URL).then(function (signedForm) { + var url = signedForm.url; + var fields = signedForm.fields; + + var formData = new FormData(); + + // NOTE: Service expects `key` to come first: + formData.append('key', fields.key); + formData.append('Content-Type', 'text/plain'); + for (var key in fields) { + if (key === 'key') { + continue; + } + var value = fields[key]; + formData.append(key, value); + } + + var contentBlob = new Blob([log], { type: 'text/plain' }); + formData.append('file', contentBlob); + + var publishedLogURL = DEBUGLOGS_BASE_URL + '/' + fields.key; + + var request = new XMLHttpRequest(); + request.open('POST', url); + request.onreadystatechange = function (event) { + if (request.readyState !== XMLHttpRequest.DONE) { + return; + } + + if (request.status !== 204) { + return reject( + new Error('Failed to publish debug log. Status: ' + + request.statusText + ' (' + request.status + ')' + ) + ); + } + + return resolve(publishedLogURL); + }; + request.send(formData); + }).fail(function () { + reject(new Error('Failed to publish logs')); + }); }); }; diff --git a/js/views/migration_view.js b/js/views/migration_view.js index dd1e36a5eb..4a90f622bc 100644 --- a/js/views/migration_view.js +++ b/js/views/migration_view.js @@ -145,7 +145,7 @@ 'click .start': 'onClickStart', 'click .installed': 'onClickInstalled', 'click .choose': 'onClickChoose', - 'click .debug-log': 'onClickDebugLog', + 'click .submit-debug-log': 'onClickDebugLog', 'click .cancel': 'onClickCancel', }, initialize: function() {