mirror of
https://github.com/Equicord/Equicord.git
synced 2025-06-26 22:58:21 -04:00
VoiceMessages: Read file from dynamic path (fixes mac & linux support)
This commit is contained in:
parent
d18681c197
commit
fe5e041db8
3 changed files with 11 additions and 6 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue