Dev/post refactor fixes (#927)

* Re-introduce outgoing message logging

Signed-off-by: TheArcaneBrony <myrainbowdash949@gmail.com>

* Websocket dumping

* Sentry user count on API

* Generate session ID upon opening websocket, fix gateway dumps

* Async file io in src/gateway/events/Message.ts

Signed-off-by: TheArcaneBrony <myrainbowdash949@gmail.com>

* Async file io in src/util/util/Config.ts

Signed-off-by: TheArcaneBrony <myrainbowdash949@gmail.com>

* Make pre-commit hook executable

Signed-off-by: TheArcaneBrony <myrainbowdash949@gmail.com>

* Fixed sync file io in src/util/util/Config.ts

Signed-off-by: TheArcaneBrony <myrainbowdash949@gmail.com>

* Fixed missing await call in src/util/util/AutoUpdate.ts

Signed-off-by: TheArcaneBrony <myrainbowdash949@gmail.com>

* Add comment to src/gateway/events/Connection.ts

Signed-off-by: TheArcaneBrony <myrainbowdash949@gmail.com>

* Clean up gateway dumping code

Signed-off-by: TheArcaneBrony <myrainbowdash949@gmail.com>
Co-authored-by: Madeline <46743919+MaddyUnderStars@users.noreply.github.com>
This commit is contained in:
TheArcaneBrony
2023-01-12 13:46:36 +01:00
committed by GitHub
parent da9ce34933
commit 6122374e4d
9 changed files with 55 additions and 9 deletions
+1 -1
View File
@@ -60,7 +60,7 @@ async function download(url: string, dir: string) {
const response = await fetch(url, { agent });
const buffer = await response.buffer();
const tempDir = await fs.mkdtemp("fosscord");
fs.writeFile(path.join(tempDir, "Fosscord.zip"), buffer);
await fs.writeFile(path.join(tempDir, "Fosscord.zip"), buffer);
} catch (error) {
console.error(`[Auto Update] download failed`, error);
}
+8 -4
View File
@@ -1,5 +1,6 @@
import { ConfigEntity } from "../entities/Config";
import fs from "fs";
import fs from "fs/promises";
import syncFs from "fs";
import { ConfigValue } from "../config";
// TODO: yaml instead of json
@@ -31,11 +32,14 @@ export const Config = {
);
try {
const overrideConfig = JSON.parse(
fs.readFileSync(overridePath, { encoding: "utf8" }),
await fs.readFile(overridePath, { encoding: "utf8" }),
);
config = overrideConfig.merge(config);
} catch (error) {
fs.writeFileSync(overridePath, JSON.stringify(config, null, 4));
await fs.writeFile(
overridePath,
JSON.stringify(config, null, 4),
);
}
}
@@ -79,7 +83,7 @@ function applyConfig(val: ConfigValue) {
}
if (process.env.CONFIG_PATH)
fs.writeFileSync(overridePath, JSON.stringify(val, null, 4));
syncFs.writeFileSync(overridePath, JSON.stringify(val, null, 4));
return apply(val);
}