Upload debug logs to debuglogs.org
This commit is contained in:
		
					parent
					
						
							
								bd5f3bd73a
							
						
					
				
			
			
				commit
				
					
						3ab3e93a28
					
				
			
		
					 1 changed files with 19 additions and 23 deletions
				
			
		| 
						 | 
				
			
			@ -2,12 +2,10 @@
 | 
			
		|||
 | 
			
		||||
/* eslint strict: ['error', 'never'] */
 | 
			
		||||
 | 
			
		||||
/* global $: false */
 | 
			
		||||
/* global textsecure: false */
 | 
			
		||||
 | 
			
		||||
const electron = require('electron');
 | 
			
		||||
const bunyan = require('bunyan');
 | 
			
		||||
const _ = require('lodash');
 | 
			
		||||
const superagent = require('superagent');
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
const ipc = electron.ipcRenderer;
 | 
			
		||||
| 
						 | 
				
			
			@ -110,27 +108,25 @@ function fetch() {
 | 
			
		|||
  });
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function publish(rawContent) {
 | 
			
		||||
  const content = rawContent || fetch();
 | 
			
		||||
 | 
			
		||||
  return new Promise((resolve) => {
 | 
			
		||||
    const payload = textsecure.utils.jsonThing({
 | 
			
		||||
      files: {
 | 
			
		||||
        'debugLog.txt': {
 | 
			
		||||
          content,
 | 
			
		||||
        },
 | 
			
		||||
      },
 | 
			
		||||
const DEBUGLOGS_API_URL = 'https://debuglogs.org';
 | 
			
		||||
const publish = async (content) => {
 | 
			
		||||
  const credentialsResponse = await superagent.get(DEBUGLOGS_API_URL);
 | 
			
		||||
  const { fields, url } = credentialsResponse.body;
 | 
			
		||||
  const uploadRequest = superagent.post(url);
 | 
			
		||||
  Object.entries(fields).forEach(([key, value]) => {
 | 
			
		||||
    uploadRequest.field(key, value);
 | 
			
		||||
  });
 | 
			
		||||
 | 
			
		||||
    // eslint-disable-next-line more/no-then
 | 
			
		||||
    $.post('https://api.github.com/gists', payload)
 | 
			
		||||
      .then((response) => {
 | 
			
		||||
        console._log('Posted debug log to ', response.html_url);
 | 
			
		||||
        resolve(response.html_url);
 | 
			
		||||
      })
 | 
			
		||||
      .fail(resolve);
 | 
			
		||||
  const contentBuffer = Buffer.from(content, 'utf8');
 | 
			
		||||
  uploadRequest.attach('file', contentBuffer, {
 | 
			
		||||
    contentType: 'text/plain',
 | 
			
		||||
    filename: 'signal-desktop-debug-log.txt',
 | 
			
		||||
  });
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
  await uploadRequest;
 | 
			
		||||
 | 
			
		||||
  return `${DEBUGLOGS_API_URL}/${fields.key}`;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
// A modern logging interface for the browser
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue