diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/VencordNative.ts | 2 | ||||
-rw-r--r-- | src/main/ipcPlugins.ts | 13 | ||||
-rw-r--r-- | src/plugins/voiceMessages/DesktopRecorder.tsx | 2 |
3 files changed, 11 insertions, 6 deletions
diff --git a/src/VencordNative.ts b/src/VencordNative.ts index 4e34f3d..ed0686d 100644 --- a/src/VencordNative.ts +++ b/src/VencordNative.ts @@ -64,7 +64,7 @@ export default { resolveRedirect: (url: string) => invoke<string>(IpcEvents.OPEN_IN_APP__RESOLVE_REDIRECT, url), }, VoiceMessages: { - readRecording: () => invoke<Uint8Array | null>(IpcEvents.VOICE_MESSAGES_READ_RECORDING), + readRecording: (path: string) => invoke<Uint8Array | null>(IpcEvents.VOICE_MESSAGES_READ_RECORDING, path), } } }; diff --git a/src/main/ipcPlugins.ts b/src/main/ipcPlugins.ts index 7ab4c25..bcc0a1b 100644 --- a/src/main/ipcPlugins.ts +++ b/src/main/ipcPlugins.ts @@ -20,7 +20,7 @@ import { IpcEvents } from "@utils/IpcEvents"; import { app, ipcMain } from "electron"; import { readFile } from "fs/promises"; import { request } from "https"; -import { join } from "path"; +import { basename, normalize } from "path"; // #region OpenInApp // These links don't support CORS, so this has to be native @@ -49,10 +49,15 @@ ipcMain.handle(IpcEvents.OPEN_IN_APP__RESOLVE_REDIRECT, async (_, url: string) = // #region VoiceMessages -ipcMain.handle(IpcEvents.VOICE_MESSAGES_READ_RECORDING, async () => { - const path = join(app.getPath("userData"), "module_data/discord_voice/recording.ogg"); +ipcMain.handle(IpcEvents.VOICE_MESSAGES_READ_RECORDING, async (_, filePath: string) => { + filePath = normalize(filePath); + const filename = basename(filePath); + const discordBaseDirWithTrailingSlash = normalize(app.getPath("userData") + "/"); + console.log(filename, discordBaseDirWithTrailingSlash, filePath); + if (filename !== "recording.ogg" || !filePath.startsWith(discordBaseDirWithTrailingSlash)) return null; + try { - const buf = await readFile(path); + const buf = await readFile(filePath); return new Uint8Array(buf.buffer); } catch { return null; diff --git a/src/plugins/voiceMessages/DesktopRecorder.tsx b/src/plugins/voiceMessages/DesktopRecorder.tsx index 176faf3..36f6a60 100644 --- a/src/plugins/voiceMessages/DesktopRecorder.tsx +++ b/src/plugins/voiceMessages/DesktopRecorder.tsx @@ -49,7 +49,7 @@ export const VoiceRecorderDesktop: VoiceRecorder = ({ setAudioBlob, onRecordingC } else { discordVoice.stopLocalAudioRecording(async (filePath: string) => { if (filePath) { - const buf = await VencordNative.pluginHelpers.VoiceMessages.readRecording(); + const buf = await VencordNative.pluginHelpers.VoiceMessages.readRecording(filePath); if (buf) setAudioBlob(new Blob([buf], { type: "audio/ogg; codecs=opus" })); else |