diff options
| author | Oskar Nyberg <oskar@mullvad.net> | 2021-03-10 20:28:08 +0100 |
|---|---|---|
| committer | Oskar Nyberg <oskar@mullvad.net> | 2021-03-24 16:42:37 +0100 |
| commit | a34620a0a6bf807bb465597779051566d06aab20 (patch) | |
| tree | 4454bbabc0bc6fff8c28264588297ac791cfca32 | |
| parent | 60f78f5d4fdaeeee2e69bbe7c8026130902c80fd (diff) | |
| download | mullvadvpn-a34620a0a6bf807bb465597779051566d06aab20.tar.xz mullvadvpn-a34620a0a6bf807bb465597779051566d06aab20.zip | |
Make problem report IPC calls transfer id instead of path
| -rw-r--r-- | gui/src/main/index.ts | 19 | ||||
| -rw-r--r-- | gui/src/renderer/app.tsx | 12 | ||||
| -rw-r--r-- | gui/src/renderer/components/Support.tsx | 18 | ||||
| -rw-r--r-- | gui/src/renderer/containers/SupportPage.tsx | 4 | ||||
| -rw-r--r-- | gui/src/shared/ipc-schema.ts | 4 |
5 files changed, 33 insertions, 24 deletions
diff --git a/gui/src/main/index.ts b/gui/src/main/index.ts index a9ffc2175d..d9acc95a42 100644 --- a/gui/src/main/index.ts +++ b/gui/src/main/index.ts @@ -1141,7 +1141,8 @@ class ApplicationMain { }); IpcMainEventChannel.problemReport.handleCollectLogs((toRedact) => { - const reportPath = path.join(app.getPath('temp'), uuid.v4() + '.log'); + const id = uuid.v4(); + const reportPath = this.getProblemReportPath(id); const executable = resolveBin('mullvad-problem-report'); const args = ['collect', '--output', reportPath]; if (toRedact.length > 0) { @@ -1159,15 +1160,16 @@ class ApplicationMain { reject(error.message); } else { log.debug(`Problem report was written to ${reportPath}`); - resolve(reportPath); + resolve(id); } }); }); }); - IpcMainEventChannel.problemReport.handleSendReport(({ email, message, savedReport }) => { + IpcMainEventChannel.problemReport.handleSendReport(({ email, message, savedReportId }) => { const executable = resolveBin('mullvad-problem-report'); - const args = ['send', '--email', email, '--message', message, '--report', savedReport]; + const reportPath = this.getProblemReportPath(savedReportId); + const args = ['send', '--email', email, '--message', message, '--report', reportPath]; return new Promise((resolve, reject) => { execFile(executable, args, { windowsHide: true }, (error, stdout, stderr) => { @@ -1186,13 +1188,16 @@ class ApplicationMain { }); }); + IpcMainEventChannel.problemReport.handleViewLog((savedReportId) => + shell.openPath(this.getProblemReportPath(savedReportId)), + ); + IpcMainEventChannel.app.handleQuit(() => app.quit()); IpcMainEventChannel.app.handleOpenUrl(async (url) => { if (Object.values(config.links).find((link) => url.startsWith(link))) { await shell.openExternal(url); } }); - IpcMainEventChannel.app.handleOpenPath((path) => shell.openPath(path)); IpcMainEventChannel.app.handleShowOpenDialog((options) => dialog.showOpenDialog(options)); } @@ -1795,6 +1800,10 @@ class ApplicationMain { return shell.openExternal(url); } } + + private getProblemReportPath(id: string): string { + return path.join(app.getPath('temp'), `${id}.log`); + } } const applicationMain = new ApplicationMain(); diff --git a/gui/src/renderer/app.tsx b/gui/src/renderer/app.tsx index 1277db2e63..6f656c5dfe 100644 --- a/gui/src/renderer/app.tsx +++ b/gui/src/renderer/app.tsx @@ -460,9 +460,13 @@ export default class AppRenderer { public async sendProblemReport( email: string, message: string, - savedReport: string, + savedReportId: string, ): Promise<void> { - await IpcRendererEventChannel.problemReport.sendReport({ email, message, savedReport }); + await IpcRendererEventChannel.problemReport.sendReport({ email, message, savedReportId }); + } + + public viewLog(id: string): Promise<string> { + return IpcRendererEventChannel.problemReport.viewLog(id); } public quit(): void { @@ -473,10 +477,6 @@ export default class AppRenderer { return IpcRendererEventChannel.app.openUrl(url); } - public openPath(path: string): Promise<string> { - return IpcRendererEventChannel.app.openPath(path); - } - public showOpenDialog( options: Electron.OpenDialogOptions, ): Promise<Electron.OpenDialogReturnValue> { diff --git a/gui/src/renderer/components/Support.tsx b/gui/src/renderer/components/Support.tsx index d6657d4c44..e7960a30c7 100644 --- a/gui/src/renderer/components/Support.tsx +++ b/gui/src/renderer/components/Support.tsx @@ -40,7 +40,7 @@ enum SendState { interface ISupportState { email: string; message: string; - savedReport?: string; + savedReportId?: string; sendState: SendState; disableActions: boolean; showOutdatedVersionWarning: boolean; @@ -56,7 +56,7 @@ interface ISupportProps { saveReportForm: (form: ISupportReportForm) => void; clearReportForm: () => void; collectProblemReport: (accountsToRedact: string[]) => Promise<string>; - sendProblemReport: (email: string, message: string, savedReport: string) => Promise<void>; + sendProblemReport: (email: string, message: string, savedReportId: string) => Promise<void>; outdatedVersion: boolean; suggestedIsBeta: boolean; onExternalLink: (url: string) => void; @@ -66,7 +66,7 @@ export default class Support extends React.Component<ISupportProps, ISupportStat public state = { email: '', message: '', - savedReport: undefined, + savedReportId: undefined, sendState: SendState.initial, disableActions: false, showOutdatedVersionWarning: false, @@ -102,8 +102,8 @@ export default class Support extends React.Component<ISupportProps, ISupportStat public onViewLog = () => { this.performWithActionsDisabled(async () => { try { - const reportPath = await this.collectLog(); - this.props.viewLog(reportPath); + const reportId = await this.collectLog(); + this.props.viewLog(reportId); } catch (error) { // TODO: handle error } @@ -199,9 +199,9 @@ export default class Support extends React.Component<ISupportProps, ISupportStat this.collectLogPromise = collectPromise; try { - const reportPath = await collectPromise; + const reportId = await collectPromise; return new Promise((resolve) => { - this.setState({ savedReport: reportPath }, () => resolve(reportPath)); + this.setState({ savedReportId: reportId }, () => resolve(reportId)); }); } catch (error) { this.collectLogPromise = undefined; @@ -216,8 +216,8 @@ export default class Support extends React.Component<ISupportProps, ISupportStat this.setState({ sendState: SendState.sending }, async () => { try { const { email, message } = this.state; - const reportPath = await this.collectLog(); - await this.props.sendProblemReport(email, message, reportPath); + const reportId = await this.collectLog(); + await this.props.sendProblemReport(email, message, reportId); this.props.clearReportForm(); this.setState({ sendState: SendState.success }, () => { resolve(); diff --git a/gui/src/renderer/containers/SupportPage.tsx b/gui/src/renderer/containers/SupportPage.tsx index 94053f1ccd..1df4827223 100644 --- a/gui/src/renderer/containers/SupportPage.tsx +++ b/gui/src/renderer/containers/SupportPage.tsx @@ -23,8 +23,8 @@ const mapDispatchToProps = (dispatch: ReduxDispatch, props: IAppContext & RouteC onClose() { props.history.goBack(); }, - viewLog(path: string) { - consumePromise(props.app.openPath(path)); + viewLog(id: string) { + consumePromise(props.app.viewLog(id)); }, saveReportForm, clearReportForm, diff --git a/gui/src/shared/ipc-schema.ts b/gui/src/shared/ipc-schema.ts index 3f0d86d995..5cc347e51e 100644 --- a/gui/src/shared/ipc-schema.ts +++ b/gui/src/shared/ipc-schema.ts @@ -126,7 +126,6 @@ export const ipcSchema = { app: { quit: send<void>(), openUrl: invoke<string, void>(), - openPath: invoke<string, string>(), showOpenDialog: invoke<Electron.OpenDialogOptions, Electron.OpenDialogReturnValue>(), }, tunnel: { @@ -185,7 +184,8 @@ export const ipcSchema = { }, problemReport: { collectLogs: invoke<string[], string>(), - sendReport: invoke<{ email: string; message: string; savedReport: string }, void>(), + sendReport: invoke<{ email: string; message: string; savedReportId: string }, void>(), + viewLog: invoke<string, string>(), }, logging: { log: send<ILogEntry>(), |
