Qodana: fix async warnings

This commit is contained in:
Rory&
2026-03-14 03:26:26 +01:00
parent 589dd7dea7
commit b5e63c06b6
26 changed files with 41 additions and 42 deletions
+1 -1
View File
@@ -6,7 +6,7 @@
}:
{
imports = [
(modulesPath + "/virtualisation/qemu-vm.nix")
# (modulesPath + "/virtualisation/qemu-vm.nix")
];
virtualisation.vmVariant = {
+1 -1
View File
@@ -256,4 +256,4 @@ async function main() {
);
}
main();
main().then(() => {});
+1 -1
View File
@@ -380,4 +380,4 @@ function columnizedObjectDiff(a, b, trackEqual = false) {
return diffs;
}
main();
main().then(() => {});
+1 -1
View File
@@ -13,4 +13,4 @@ async function main() {
console.log((await ret.json()).token);
}
main();
main().then(() => {});
+2 -2
View File
@@ -34,9 +34,9 @@ async function main() {
captcha_key: null,
}),
headers: { "content-type": "application/json" },
});
}).then(() => {});
console.log(i);
}
}
main();
main().then(() => {});
+1 -1
View File
@@ -34,5 +34,5 @@ const { initDatabase } = require("..");
console.log("synchronising");
await db.synchronize();
console.log("done");
db.destroy();
await db.destroy();
})();
+1 -1
View File
@@ -200,7 +200,7 @@ export class SpacebarServer extends Server {
this.app.use(ErrorHandler);
ConnectionLoader.loadConnections();
await ConnectionLoader.loadConnections();
if (logRequests) console.log(red(`Warning: Request logging is enabled! This will spam your console!\nTo disable this, unset the 'LOG_REQUESTS' environment variable!`));
@@ -122,7 +122,7 @@ router.patch(
app.bot.assign(body);
app.bot.save();
await app.bot.save();
await app.save();
res.json(app).status(200);
@@ -113,7 +113,7 @@ router.patch(
} as MessageUpdateEvent),
]);
postHandleMessage(new_message);
postHandleMessage(new_message).catch((e) => console.error("[Message] post-message handler failed", e));
// TODO: a DTO?
return res.json({
@@ -295,7 +295,7 @@ router.delete(
});
if (channel.type === ChannelType.GUILD_PUBLIC_THREAD) {
if (channel.message_count !== undefined) channel.message_count--;
channel.save(); //Save async, it's fine
await channel.save();
}
const message = await Message.findOneOrFail({
where: { id: message_id },
@@ -89,7 +89,7 @@ router.post(
},
author_id: user.id,
});
sendMessage({
await sendMessage({
channel_id: channel.id,
type: MessageType.THREAD_CREATED,
content: thread.name,
@@ -126,7 +126,7 @@ router.post(
}),
]);
if (body.type !== ChannelType.GUILD_PRIVATE_THREAD && !channel.isForum())
sendMessage({
await sendMessage({
channel_id: channel.id,
type: MessageType.THREAD_CREATED,
content: thread.name,
@@ -43,7 +43,7 @@ router.get("/", route({}), async (req: Request, res: Response) => {
});
res.json({
url: await connection.getAuthorizationUrl(req.user_id),
url: connection.getAuthorizationUrl(req.user_id),
});
});
@@ -49,7 +49,7 @@ router.post("/", route({ requestBody: "ConnectionCallbackSchema" }), async (req:
// whether we should emit a connections update event, only used when a connection doesnt already exist
if (connectedAccnt)
emitEvent({
await emitEvent({
event: "USER_CONNECTIONS_UPDATE",
data: { ...connectedAccnt, token_data: undefined },
user_id: userId,
@@ -68,7 +68,7 @@ router.get(
}
if (channel_id) {
const ids = new Set(channel_id instanceof Array ? channel_id : [channel_id]);
Promise.all(
await Promise.all(
[...ids].map(async (id) => {
const permissions = await getPermission(req.user_id, req.params.guild_id as string, id);
permissions.hasThrow("VIEW_CHANNEL");
@@ -83,27 +83,27 @@ router.get(
switch (style) {
case "shield":
ctx.textAlign = "center";
await drawText(ctx, 73, 13, "#FFFFFF", "thin 10px Verdana", presence);
drawText(ctx, 73, 13, "#FFFFFF", "thin 10px Verdana", presence);
break;
case "banner1":
if (icon) await drawIcon(ctx, 20, 27, 50, icon);
await drawText(ctx, 83, 51, "#FFFFFF", "12px Verdana", name, 22);
await drawText(ctx, 83, 66, "#C9D2F0FF", "thin 11px Verdana", presence);
drawText(ctx, 83, 51, "#FFFFFF", "12px Verdana", name, 22);
drawText(ctx, 83, 66, "#C9D2F0FF", "thin 11px Verdana", presence);
break;
case "banner2":
if (icon) await drawIcon(ctx, 13, 19, 36, icon);
await drawText(ctx, 62, 34, "#FFFFFF", "12px Verdana", name, 15);
await drawText(ctx, 62, 49, "#C9D2F0FF", "thin 11px Verdana", presence);
drawText(ctx, 62, 34, "#FFFFFF", "12px Verdana", name, 15);
drawText(ctx, 62, 49, "#C9D2F0FF", "thin 11px Verdana", presence);
break;
case "banner3":
if (icon) await drawIcon(ctx, 20, 20, 50, icon);
await drawText(ctx, 83, 44, "#FFFFFF", "12px Verdana", name, 27);
await drawText(ctx, 83, 58, "#C9D2F0FF", "thin 11px Verdana", presence);
drawText(ctx, 83, 44, "#FFFFFF", "12px Verdana", name, 27);
drawText(ctx, 83, 58, "#C9D2F0FF", "thin 11px Verdana", presence);
break;
case "banner4":
if (icon) await drawIcon(ctx, 21, 136, 50, icon);
await drawText(ctx, 84, 156, "#FFFFFF", "13px Verdana", name, 27);
await drawText(ctx, 84, 171, "#C9D2F0FF", "thin 12px Verdana", presence);
drawText(ctx, 84, 156, "#FFFFFF", "13px Verdana", name, 27);
drawText(ctx, 84, 171, "#C9D2F0FF", "thin 12px Verdana", presence);
break;
default:
throw new HTTPError("Value must be one of ('shield', 'banner1', 'banner2', 'banner3', 'banner4').", 400);
@@ -77,7 +77,7 @@ router.post("/", route({}), async (req: Request, res: Response) => {
clearTimeout(interaction.timeout);
emitEvent({
await emitEvent({
event: "INTERACTION_SUCCESS",
user_id: interaction?.userId,
data: {
+2 -2
View File
@@ -32,7 +32,7 @@ router.post("/", route({}), async (req: Request, res: Response) => {
const interactionId = Snowflake.generate();
const interactionToken = randomBytes(24).toString("base64url");
emitEvent({
await emitEvent({
event: "INTERACTION_CREATE",
user_id: req.user_id,
data: {
@@ -94,7 +94,7 @@ router.post("/", route({}), async (req: Request, res: Response) => {
interactionData.message = await Message.findOneOrFail({ where: { id: body.message_id, flags: undefined }, relations: { author: true } });
}
emitEvent({
await emitEvent({
event: "INTERACTION_CREATE",
user_id: body.application_id,
data: interactionData,
@@ -59,8 +59,9 @@ router.patch(
const body = req.body as UserGuildSettingsSchema;
if (body.channel_overrides) {
// TODO: rewrite to a single query?
for (const channel in body.channel_overrides) {
Channel.findOneOrFail({ where: { id: channel } });
await Channel.findOneOrFail({ where: { id: channel } });
}
}
+2 -2
View File
@@ -79,9 +79,9 @@ router.put(
},
})
) {
Note.update({ owner: { id: owner.id }, target: { id: target.id } }, { owner, target, content: note });
await Note.update({ owner: { id: owner.id }, target: { id: target.id } }, { owner, target, content: note });
} else {
Note.insert({
await Note.insert({
id: Snowflake.generate(),
owner,
target,
+1 -1
View File
@@ -115,7 +115,7 @@ export async function handleMessage(opts: MessageOptions): Promise<Message> {
}
if (!ephermal) {
channel.last_message_id = message.id;
channel.save();
await channel.save();
}
if (cloudAttachments && cloudAttachments.length > 0) {
-2
View File
@@ -20,9 +20,7 @@ import { Server, ServerOptions } from "lambert-server";
import { Attachment, Config, initDatabase, registerRoutes } from "@spacebar/util";
import { CORS, BodyParser } from "@spacebar/api";
import path from "path";
import avatarsRoute from "./routes/avatars";
import guildProfilesRoute from "./routes/guild-profiles";
import iconsRoute from "./routes/role-icons";
import morgan from "morgan";
import { Like } from "typeorm";
+2 -2
View File
@@ -240,7 +240,7 @@ async function consume(this: WebSocket, opts: EventOpts) {
break;
case "GUILD_MEMBER_UPDATE":
if (!this.member_events[data.user.id]) break;
this.member_events[data.user.id]();
await this.member_events[data.user.id]();
break;
case "RELATIONSHIP_REMOVE":
case "CHANNEL_DELETE":
@@ -266,7 +266,7 @@ async function consume(this: WebSocket, opts: EventOpts) {
this.events[data.user.id] = await listenEvent(data.user.id, handlePresenceUpdate.bind(this), this.listen_options);
break;
case "GUILD_CREATE":
Promise.all([
await Promise.all([
...data.channels.map(async ({ id }: { id: string }) => {
this.events[id] = await listenEvent(id, consumer, listenOpts);
}),
+1 -1
View File
@@ -37,4 +37,4 @@ const server = new Server({
if (fs.existsSync("/proc/self/comm")) fs.writeFileSync("/proc/self/comm", `spacebar-gw-${cluster.worker ? cluster.worker.id : port}`);
process.title = `sb-gw-${cluster.worker ? cluster.worker.id : port}`;
server.start();
server.start().then(() => {});
+3 -3
View File
@@ -28,7 +28,7 @@ const connectionsLoaded = false;
export class ConnectionLoader {
public static async loadConnections() {
if (connectionsLoaded) return;
ConnectionConfig.init();
await ConnectionConfig.init();
const dirs = fs.readdirSync(root).filter((x) => {
try {
fs.readdirSync(path.join(root, x));
@@ -38,7 +38,7 @@ export class ConnectionLoader {
}
});
dirs.forEach(async (x) => {
dirs.forEach((x) => {
const modPath = path.resolve(path.join(root, x));
const mod = new (require(modPath).default)() as Connection;
ConnectionStore.connections.set(mod.id, mod);
@@ -54,7 +54,7 @@ export class ConnectionLoader {
if (cfg) cfg = Object.assign({}, defaults, cfg);
else {
cfg = defaults;
this.setConnectionConfig(id, cfg);
this.setConnectionConfig(id, cfg).catch((e) => console.error(`[Connections/ERROR] Failed to set default config for '${id}'!`, e));
}
}
+1 -1
View File
@@ -102,7 +102,7 @@ export class RabbitMQ {
this.events.emit("disconnected");
// Schedule reconnection
this.scheduleReconnect(host);
this.scheduleReconnect(host).catch((e) => console.error("[RabbitMQ] Failed to schedule reconnection:", e));
});
}
+1 -1
View File
@@ -35,4 +35,4 @@ const server = new Server({
if (fs.existsSync("/proc/self/comm")) fs.writeFileSync("/proc/self/comm", `spacebar-wrtc-${cluster.worker ? cluster.worker.id : port}`);
process.title = `sb-wrtc-${cluster.worker ? cluster.worker.id : port}`;
server.start();
server.start().catch((e) => console.error("Failed to start WebRTC server:", e));