summaryrefslogtreecommitdiffhomepage
path: root/gui/src/main
diff options
context:
space:
mode:
authorOskar Nyberg <oskar@mullvad.net>2020-12-09 16:31:50 +0100
committerOskar Nyberg <oskar@mullvad.net>2020-12-10 11:30:31 +0100
commit6a8cf020b3a561b28773831fc2cef4066d445884 (patch)
tree98b494619e4ddde3949011f06082ef48e493b04b /gui/src/main
parentae3cae40c16b01683b2a562ac48799699c711ca2 (diff)
downloadmullvadvpn-6a8cf020b3a561b28773831fc2cef4066d445884.tar.xz
mullvadvpn-6a8cf020b3a561b28773831fc2cef4066d445884.zip
Move problem report ipc calls to ipc-event-channel
Diffstat (limited to 'gui/src/main')
-rw-r--r--gui/src/main/index.ts67
1 files changed, 22 insertions, 45 deletions
diff --git a/gui/src/main/index.ts b/gui/src/main/index.ts
index 36744104b5..f0cd89a52d 100644
--- a/gui/src/main/index.ts
+++ b/gui/src/main/index.ts
@@ -1097,52 +1097,36 @@ class ApplicationMain {
}
});
- ipcMain.on(
- 'collect-logs',
- (event: Electron.IpcMainEvent, requestId: string, toRedact: string[]) => {
- const reportPath = path.join(app.getPath('temp'), uuid.v4() + '.log');
- const executable = resolveBin('mullvad-problem-report');
- const args = ['collect', '--output', reportPath];
- if (toRedact.length > 0) {
- args.push('--redact', ...toRedact);
- }
+ IpcMainEventChannel.problemReport.handleCollectLogs((toRedact) => {
+ const reportPath = path.join(app.getPath('temp'), uuid.v4() + '.log');
+ const executable = resolveBin('mullvad-problem-report');
+ const args = ['collect', '--output', reportPath];
+ if (toRedact.length > 0) {
+ args.push('--redact', ...toRedact);
+ }
+ return new Promise((resolve, reject) => {
execFile(executable, args, { windowsHide: true }, (error, stdout, stderr) => {
if (error) {
log.error(
`Failed to collect a problem report.
- Stdout: ${stdout.toString()}
- Stderr: ${stderr.toString()}`,
+ Stdout: ${stdout.toString()}
+ Stderr: ${stderr.toString()}`,
);
-
- event.sender.send('collect-logs-reply', requestId, {
- success: false,
- error: error.message,
- });
+ reject(error.message);
} else {
log.debug(`Problem report was written to ${reportPath}`);
-
- event.sender.send('collect-logs-reply', requestId, {
- success: true,
- reportPath,
- });
+ resolve(reportPath);
}
});
- },
- );
+ });
+ });
- ipcMain.on(
- 'send-problem-report',
- (
- event: Electron.IpcMainEvent,
- requestId: string,
- email: string,
- message: string,
- savedReport: string,
- ) => {
- const executable = resolveBin('mullvad-problem-report');
- const args = ['send', '--email', email, '--message', message, '--report', savedReport];
+ IpcMainEventChannel.problemReport.handleSendReport(({ email, message, savedReport }) => {
+ const executable = resolveBin('mullvad-problem-report');
+ const args = ['send', '--email', email, '--message', message, '--report', savedReport];
+ return new Promise((resolve, reject) => {
execFile(executable, args, { windowsHide: true }, (error, stdout, stderr) => {
if (error) {
log.error(
@@ -1150,21 +1134,14 @@ class ApplicationMain {
Stdout: ${stdout.toString()}
Stderr: ${stderr.toString()}`,
);
-
- event.sender.send('send-problem-report-reply', requestId, {
- success: false,
- error: error.message,
- });
+ reject(error.message);
} else {
log.info('Problem report was sent.');
-
- event.sender.send('send-problem-report-reply', requestId, {
- success: true,
- });
+ resolve();
}
});
- },
- );
+ });
+ });
}
private async createNewAccount(): Promise<string> {