Update the user agent for debug log requests
This commit is contained in:
parent
c517e4193b
commit
b159a8d7c7
|
@ -8,6 +8,7 @@ const config = url.parse(window.location.toString(), true).query;
|
|||
const { locale } = config;
|
||||
const localeMessages = ipcRenderer.sendSync('locale-data');
|
||||
|
||||
window.getVersion = () => config.version;
|
||||
window.theme = config.theme;
|
||||
window.i18n = i18n.setup(locale, localeMessages);
|
||||
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
/* eslint-env node */
|
||||
/* global window */
|
||||
|
||||
const FormData = require('form-data');
|
||||
const got = require('got');
|
||||
|
||||
const BASE_URL = 'https://debuglogs.org';
|
||||
const VERSION = window.getVersion();
|
||||
const USER_AGENT = `Signal Desktop ${VERSION}`;
|
||||
|
||||
// Workaround: Submitting `FormData` using native `FormData::submit` procedure
|
||||
// as integration with `got` results in S3 error saying we haven’t set the
|
||||
|
@ -22,7 +25,12 @@ const submitFormData = (form, url) =>
|
|||
|
||||
// upload :: String -> Promise URL
|
||||
exports.upload = async content => {
|
||||
const signedForm = await got.get(BASE_URL, { json: true });
|
||||
const signedForm = await got.get(BASE_URL, {
|
||||
json: true,
|
||||
headers: {
|
||||
'user-agent': USER_AGENT,
|
||||
},
|
||||
});
|
||||
const { fields, url } = signedForm.body;
|
||||
|
||||
const form = new FormData();
|
||||
|
@ -36,10 +44,11 @@ exports.upload = async content => {
|
|||
|
||||
const contentBuffer = Buffer.from(content, 'utf8');
|
||||
const contentType = 'text/plain';
|
||||
form.append('User-Agent', USER_AGENT);
|
||||
form.append('Content-Type', contentType);
|
||||
form.append('file', contentBuffer, {
|
||||
contentType,
|
||||
filename: 'signal-desktop-debug-log.txt',
|
||||
filename: `signal-desktop-debug-log-${VERSION}.txt`,
|
||||
});
|
||||
|
||||
// WORKAROUND: See comment on `submitFormData`:
|
||||
|
|
|
@ -11,8 +11,6 @@ const localeMessages = ipcRenderer.sendSync('locale-data');
|
|||
window.theme = config.theme;
|
||||
window.i18n = i18n.setup(locale, localeMessages);
|
||||
|
||||
require('./js/logging');
|
||||
|
||||
// So far we're only using this for Signal.Types
|
||||
const Signal = require('./js/modules/signal');
|
||||
|
||||
|
@ -80,3 +78,5 @@ function makeSetter(name) {
|
|||
ipcRenderer.send(`set-${name}`, value);
|
||||
});
|
||||
}
|
||||
|
||||
require('./js/logging');
|
||||
|
|
|
@ -1,18 +0,0 @@
|
|||
const { assert } = require('chai');
|
||||
const got = require('got');
|
||||
|
||||
const debuglogs = require('../../js/modules/debuglogs');
|
||||
|
||||
describe('debuglogs', () => {
|
||||
describe('upload', () => {
|
||||
it('should upload log content', async () => {
|
||||
const nonce = Math.random()
|
||||
.toString()
|
||||
.slice(2);
|
||||
const url = await debuglogs.upload(nonce);
|
||||
|
||||
const { body } = await got.get(url);
|
||||
assert.equal(nonce, body);
|
||||
}).timeout(3000);
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue