summary refs log tree commit diff
diff options
context:
space:
mode:
authorRory& <root@rory.gay>2026-03-14 03:59:28 +0100
committerRory& <root@rory.gay>2026-03-14 03:59:28 +0100
commita451f92e67ee51136d4841fdda6befe8629a298b (patch)
tree822c6a6f1e5338ea013b92fae5e149163760ec97
parentlambert-server: remove unused code (diff)
downloadserver-ts-a451f92e67ee51136d4841fdda6befe8629a298b.tar.xz
properly mark unused params
-rw-r--r--.idea/workspace.xml43
-rw-r--r--scripts/schema.js6
-rw-r--r--scripts/util/getRouteDescriptions.js2
-rw-r--r--src/api/middlewares/Authentication.ts2
-rw-r--r--src/api/routes/channels/#channel_id/thread-members.ts14
-rw-r--r--src/api/routes/channels/#channel_id/threads.ts1
-rw-r--r--src/api/routes/guilds/automations/email-domain-lookup.ts1
-rw-r--r--src/api/routes/reporting/index.ts1
-rw-r--r--src/api/routes/webhooks/#webhook_id/#token/index.ts1
-rw-r--r--src/api/util/handlers/Message.ts3
-rw-r--r--src/apply-migrations.ts2
-rw-r--r--src/gateway/Server.ts6
-rw-r--r--src/gateway/opcodes/Identify.ts5
-rw-r--r--src/gateway/opcodes/LazyRequest.ts1
-rw-r--r--src/gateway/opcodes/StreamDelete.ts1
-rw-r--r--src/gateway/util/Utils.ts2
-rw-r--r--src/util/Signing.ts2
-rw-r--r--src/util/entities/UserSettingsProtos.ts2
-rw-r--r--src/util/migration/postgres-initial.ts2
-rw-r--r--src/util/migration/postgres/1761113394664-delete-bot-users-without-an-application.ts2
-rw-r--r--src/util/util/Database.ts3
-rw-r--r--src/util/util/email/clients/IEmailClient.ts2
-rw-r--r--src/util/util/json/JsonSerializer.ts1
-rw-r--r--src/webrtc/events/Message.ts7
-rw-r--r--src/webrtc/opcodes/BackendVersion.ts2
-rw-r--r--src/webrtc/opcodes/Identify.ts1
-rw-r--r--src/webrtc/opcodes/Video.ts2
27 files changed, 78 insertions, 39 deletions
diff --git a/.idea/workspace.xml b/.idea/workspace.xml

index 11f4ea46..f2c77cea 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml
@@ -12,6 +12,18 @@ <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" /> <option name="LAST_RESOLUTION" value="IGNORE" /> </component> + <component name="CopilotPersistence"> + <persistenceIdMap> + <entry key="_/home/Rory/git/spacebar/server-master" value="2oJ9u2nkEFq1qQW1NFF69ECjiYu" /> + </persistenceIdMap> + </component> + <component name="CopilotUserSelectedModel"> + <selectedModels> + <entry key="chat-panel" value="Gemini 3 Pro (Preview)" /> + <entry key="agent-panel" value="Gemini 3 Pro (Preview)" /> + <entry key="edit-panel" value="GPT-5 mini" /> + </selectedModels> + </component> <component name="FileTemplateManagerImpl"> <option name="RECENT_TEMPLATES"> <list> @@ -42,7 +54,7 @@ <scope name="src" pattern="!file[server]:*/||file[server]:src//*" /> </component> <component name="ProblemsViewState"> - <option name="selectedTabId" value="ProjectErrors" /> + <option name="selectedTabId" value="QODANA_PROBLEMS_VIEW_TAB" /> </component> <component name="ProjectColorInfo">{ &quot;customColor&quot;: &quot;&quot;, @@ -99,6 +111,24 @@ ] } }</component> + <component name="QodanaHighlightedReportService"> + <option name="localRunNotPublishedPersistedInfo"> + <LocalReportPersistedInfo> + <option name="path" value="/tmp/qodana_output1/qodana.sarif.json" /> + <option name="reportGuid" value="ffc75f9a-8af2-4039-9caf-5031bc73d78a" /> + <option name="reportName" value="server-master/qodana/2026-03-14" /> + </LocalReportPersistedInfo> + </option> + </component> + <component name="QodanaIsSelectedPersistenceService"> + <option name="selectedOrLoading" value="true" /> + </component> + <component name="QodanaReportsService"> + <option name="descriptions"> + <ReportDescription localRun="true" path="/tmp/qodana_output/qodana.sarif.json" reportGuid="23b693fa-9bcf-42d2-b172-3372ba9c21ff" reportId="server-master/qodana/2026-03-14" /> + <ReportDescription localRun="true" path="/tmp/qodana_output1/qodana.sarif.json" reportGuid="ffc75f9a-8af2-4039-9caf-5031bc73d78a" reportId="server-master/qodana/2026-03-14" /> + </option> + </component> <component name="RecentsManager"> <key name="CopyFile.RECENT_KEYS"> <recent name="$PROJECT_DIR$/nix/modules/default" /> @@ -130,8 +160,6 @@ <entry key="Start CDN" value="STOPPED" /> <entry key="Start Gateway" value="STOPPED" /> <entry key="Start bundle" value="STOPPED" /> - <entry key="build:src:tsgo" value="STOPPED" /> - <entry key="build:tsgo" value="STOPPED" /> </map> </value> </entry> @@ -194,6 +222,7 @@ <workItem from="1772714447261" duration="12025000" /> <workItem from="1772830175841" duration="4576000" /> <workItem from="1772918744394" duration="70646000" /> + <workItem from="1773448797192" duration="8146000" /> </task> <servers /> </component> @@ -232,4 +261,12 @@ </breakpoints> </breakpoint-manager> </component> + <component name="github-copilot-workspace"> + <instructionFileLocations> + <option value=".github/instructions" /> + </instructionFileLocations> + <promptFileLocations> + <option value=".github/prompts" /> + </promptFileLocations> + </component> </project> \ No newline at end of file diff --git a/scripts/schema.js b/scripts/schema.js
index 60398472..171abb5a 100644 --- a/scripts/schema.js +++ b/scripts/schema.js
@@ -210,11 +210,11 @@ async function main() { for (const defKey in schema.definitions) { if (definitions[defKey] && deepEqual(definitions[defKey], schema.definitions[defKey])) { // console.log("Definition", defKey, "from schema", schemaName, "is identical to existing definition, skipping."); - schema.definitions = Object.fromEntries(Object.entries(schema.definitions).filter(([k, v]) => k !== defKey)); + schema.definitions = Object.fromEntries(Object.entries(schema.definitions).filter(([k, _]) => k !== defKey)); process.stdout.write(greenBright("T")); } else if (!nestedDefinitions[defKey]) { nestedDefinitions[defKey] = schema.definitions[defKey]; - schema.definitions = Object.fromEntries(Object.entries(schema.definitions).filter(([k, v]) => k !== defKey)); + schema.definitions = Object.fromEntries(Object.entries(schema.definitions).filter(([k, _]) => k !== defKey)); // console.log("Tracking sub-definition", defKey, "from schema", schemaName); process.stdout.write(green("N")); } else if (!deepEqual(nestedDefinitions[defKey], schema.definitions[defKey])) { @@ -222,7 +222,7 @@ async function main() { console.log(columnizedObjectDiff(nestedDefinitions[defKey], schema.definitions[defKey], true)); } else { // console.log("Definition", defKey, "from schema", schemaName, "is identical to existing definition, skipping."); - schema.definitions = Object.fromEntries(Object.entries(schema.definitions).filter(([k, v]) => k !== defKey)); + schema.definitions = Object.fromEntries(Object.entries(schema.definitions).filter(([k, _]) => k !== defKey)); process.stdout.write(greenBright("M")); } } diff --git a/scripts/util/getRouteDescriptions.js b/scripts/util/getRouteDescriptions.js
index 5c4c0aff..69be334a 100644 --- a/scripts/util/getRouteDescriptions.js +++ b/scripts/util/getRouteDescriptions.js
@@ -2,7 +2,7 @@ const express = require("express"); const path = require("path"); const { traverseDirectory } = require("lambert-server"); const RouteUtility = require("../../dist/api/util/handlers/route.js"); -const { bgRedBright, greenBright, yellowBright, blueBright, redBright, underline, bold, bgYellow, black } = require("picocolors"); +const { greenBright, yellowBright, blueBright, redBright, underline, bgYellow, black } = require("picocolors"); const methods = ["get", "post", "put", "delete", "patch"]; const routes = new Map(); diff --git a/src/api/middlewares/Authentication.ts b/src/api/middlewares/Authentication.ts
index ad949b25..a35c5fbc 100644 --- a/src/api/middlewares/Authentication.ts +++ b/src/api/middlewares/Authentication.ts
@@ -120,7 +120,7 @@ export async function Authentication(req: Request, res: Response, next: NextFunc if (!req.headers.authorization) return next(new HTTPError("Missing Authorization Header", 401)); try { - const { decoded, user, session, tokenVersion } = (req.tokenData = await checkToken(req.headers.authorization, { + const { decoded, user, session } = (req.tokenData = await checkToken(req.headers.authorization, { ipAddress: req.ip, fingerprint: req.fingerprint, })); diff --git a/src/api/routes/channels/#channel_id/thread-members.ts b/src/api/routes/channels/#channel_id/thread-members.ts
index 281ed2f9..83b1b293 100644 --- a/src/api/routes/channels/#channel_id/thread-members.ts +++ b/src/api/routes/channels/#channel_id/thread-members.ts
@@ -50,12 +50,14 @@ router.get( limit = undefined; } - return await ThreadMember.find({ - where: { channel: { id: channel_id }, ...(after ? { user_id: MoreThan(after) } : {}) }, - take: limit ? parseInt(limit) : 50, - order: { member_idx: "ASC" }, - relations: { ...(with_member ? { member: true } : {}) }, - }); + return res.send( + await ThreadMember.find({ + where: { channel: { id: channel_id }, ...(after ? { user_id: MoreThan(after) } : {}) }, + take: limit ? parseInt(limit) : 50, + order: { member_idx: "ASC" }, + relations: { ...(with_member ? { member: true } : {}) }, + }), + ); }, ); router.post( diff --git a/src/api/routes/channels/#channel_id/threads.ts b/src/api/routes/channels/#channel_id/threads.ts
index 22b29e52..e81c8d79 100644 --- a/src/api/routes/channels/#channel_id/threads.ts +++ b/src/api/routes/channels/#channel_id/threads.ts
@@ -217,6 +217,7 @@ router.get( }, }), async (req: Request, res: Response) => { + // noinspection JSUnusedLocalSymbols - ??? const { name, slop, tag, tag_setting, archived, sort_by, sort_order, limit, offset, max_id, min_id } = req.query as Record<string, string | undefined>; const tags = tag ? tag.split(",") : []; const { channel_id } = req.params as Record<string, string>; diff --git a/src/api/routes/guilds/automations/email-domain-lookup.ts b/src/api/routes/guilds/automations/email-domain-lookup.ts
index 943097f8..63ec39d4 100644 --- a/src/api/routes/guilds/automations/email-domain-lookup.ts +++ b/src/api/routes/guilds/automations/email-domain-lookup.ts
@@ -59,6 +59,7 @@ router.post( }, ); +// noinspection JSUnusedLocalSymbols - TODO: implement router.post( "/verify-code", route({ diff --git a/src/api/routes/reporting/index.ts b/src/api/routes/reporting/index.ts
index a04f76de..7f8e539e 100644 --- a/src/api/routes/reporting/index.ts +++ b/src/api/routes/reporting/index.ts
@@ -66,6 +66,7 @@ for (const type of Object.values(ReportMenuTypeNames)) { }, ); if (process.env.LOG_ROUTES !== "false") console.log(`[Server] Route /reporting/menu/${type} registered (reports).`); + // noinspection JSUnusedLocalSymbols - TODO: implement router.post( `/${type}`, route({ diff --git a/src/api/routes/webhooks/#webhook_id/#token/index.ts b/src/api/routes/webhooks/#webhook_id/#token/index.ts
index 556ee489..1dd2dac4 100644 --- a/src/api/routes/webhooks/#webhook_id/#token/index.ts +++ b/src/api/routes/webhooks/#webhook_id/#token/index.ts
@@ -149,6 +149,7 @@ router.patch( }, }), async (req: Request, res: Response) => { + // noinspection JSUnusedLocalSymbols - TODO: shouldnt token be checked? const { webhook_id, token } = req.params as { [key: string]: string }; const body = req.body as WebhookUpdateSchema; diff --git a/src/api/util/handlers/Message.ts b/src/api/util/handlers/Message.ts
index 5ec13dd6..c21a47b4 100644 --- a/src/api/util/handlers/Message.ts +++ b/src/api/util/handlers/Message.ts
@@ -228,6 +228,7 @@ export async function handleMessage(opts: MessageOptions): Promise<Message> { } } else { permission ||= await getPermission(opts.author_id, channel.guild_id, channel); + if (permission === null) throw new HTTPError("permission was null after getPermission", 500); permission.hasThrow("SEND_MESSAGES"); if (permission.cache.member) { message.member = permission.cache.member; @@ -238,7 +239,7 @@ export async function handleMessage(opts: MessageOptions): Promise<Message> { permission.hasThrow("READ_MESSAGE_HISTORY"); // code below has to be redone when we add custom message routing if (message.guild_id !== null) { - const guild = await Guild.findOneOrFail({ + await Guild.findOneOrFail({ where: { id: channel.guild_id }, }); if (!opts.message_reference.guild_id) opts.message_reference.guild_id = channel.guild_id; diff --git a/src/apply-migrations.ts b/src/apply-migrations.ts
index d43f67bf..7d3ac90a 100644 --- a/src/apply-migrations.ts +++ b/src/apply-migrations.ts
@@ -28,4 +28,4 @@ async function main() { } } -main().then((r) => console.log("meow")); +main().then(() => console.log("meow")); diff --git a/src/gateway/Server.ts b/src/gateway/Server.ts
index 7fea1a27..c6419cfa 100644 --- a/src/gateway/Server.ts +++ b/src/gateway/Server.ts
@@ -38,9 +38,9 @@ export class Server { if (server) this.server = server; else { - const elu = [1, 5, 15].map((x) => performance.eventLoopUtilization()); - const eluP = [1, 5, 15].map((x) => performance.eventLoopUtilization()); - const cpu = [1, 5, 15].map((x) => process.cpuUsage()); + const elu = [1, 5, 15].map(() => performance.eventLoopUtilization()); + const eluP = [1, 5, 15].map(() => performance.eventLoopUtilization()); + const cpu = [1, 5, 15].map(() => process.cpuUsage()); let sec = 0; setInterval(() => { sec += 1; diff --git a/src/gateway/opcodes/Identify.ts b/src/gateway/opcodes/Identify.ts
index 65c54ae0..7dd21658 100644 --- a/src/gateway/opcodes/Identify.ts +++ b/src/gateway/opcodes/Identify.ts
@@ -64,11 +64,6 @@ import { ChannelType, DefaultUserGuildSettings, DMChannel, IdentifySchema, Priva // TODO: user sharding // TODO: check privileged intents, if defined in the config -function logAuth(message: string) { - if (process.env.LOG_AUTH != "true") return; - console.log(`[Gateway/Auth] ${message}`); -} - export async function onIdentify(this: WebSocket, data: Payload) { const totalSw = Stopwatch.startNew(); const taskSw = Stopwatch.startNew(); diff --git a/src/gateway/opcodes/LazyRequest.ts b/src/gateway/opcodes/LazyRequest.ts
index 0e63a7d2..cb465cf0 100644 --- a/src/gateway/opcodes/LazyRequest.ts +++ b/src/gateway/opcodes/LazyRequest.ts
@@ -158,6 +158,7 @@ export async function onLazyRequest(this: WebSocket, { d }: Payload) { const startTime = Date.now(); // TODO: check data check.call(this, LazyRequestSchema, d); + // noinspection JSUnusedLocalSymbols - TODO: implement typing/activities subscriptions const { guild_id, typing, channels, activities, members } = d as LazyRequestSchema; if (members) { diff --git a/src/gateway/opcodes/StreamDelete.ts b/src/gateway/opcodes/StreamDelete.ts
index c5d8bec3..6135e1f3 100644 --- a/src/gateway/opcodes/StreamDelete.ts +++ b/src/gateway/opcodes/StreamDelete.ts
@@ -21,6 +21,7 @@ export async function onStreamDelete(this: WebSocket, data: Payload) { return this.close(4000, "Invalid stream key"); } + // noinspection JSUnusedLocalSymbols - TODO: what is type here? const { userId, channelId, guildId, type } = parsedKey; // when a user selects to stop watching another user stream, this event gets triggered diff --git a/src/gateway/util/Utils.ts b/src/gateway/util/Utils.ts
index ec0f411c..1ca45ee4 100644 --- a/src/gateway/util/Utils.ts +++ b/src/gateway/util/Utils.ts
@@ -58,7 +58,7 @@ export async function cleanupOnStartup(): Promise<void> { console.log("[Gateway] Starting async voice state wipe..."); VoiceState.clear() - .then((e) => console.log("[Gateway] Successfully cleaned voice states")) + .then(() => console.log("[Gateway] Successfully cleaned voice states")) .catch((e) => console.error("[Gateway] Error cleaning voice states on startup:", e)); } diff --git a/src/util/Signing.ts b/src/util/Signing.ts
index 26daf808..24f3c206 100644 --- a/src/util/Signing.ts +++ b/src/util/Signing.ts
@@ -114,7 +114,7 @@ export class UrlSignResult { } export const getUrlSignature = (data: NewUrlSignatureData): UrlSignResult => { - const { cdnSignatureKey, cdnSignatureDuration } = Config.get().security; + const { cdnSignatureDuration } = Config.get().security; // calculate the expiration time const now = Date.now(); diff --git a/src/util/entities/UserSettingsProtos.ts b/src/util/entities/UserSettingsProtos.ts
index c08b98ff..a3c1e4fb 100644 --- a/src/util/entities/UserSettingsProtos.ts +++ b/src/util/entities/UserSettingsProtos.ts
@@ -99,7 +99,7 @@ export class UserSettingsProtos extends BaseClassWithoutId { } static async getOrDefault(user_id: string, save: boolean = false): Promise<UserSettingsProtos> { - const user = await User.findOneOrFail({ + await User.findOneOrFail({ where: { id: user_id }, select: { settings: true }, }); diff --git a/src/util/migration/postgres-initial.ts b/src/util/migration/postgres-initial.ts
index 20a747c2..b158ba2a 100644 --- a/src/util/migration/postgres-initial.ts +++ b/src/util/migration/postgres-initial.ts
@@ -719,7 +719,7 @@ export class initial0 implements MigrationInterface { await queryRunner.query(`ALTER TABLE ONLY public.team_members ADD CONSTRAINT "FK_fdad7d5768277e60c40e01cdcea" FOREIGN KEY (team_id) REFERENCES public.teams(id) ON DELETE CASCADE;`); } - public async down(queryRunner: QueryRunner): Promise<void> { + public async down(_: QueryRunner): Promise<void> { throw new Error("Can't revert this: just throw away your database lol"); } } diff --git a/src/util/migration/postgres/1761113394664-delete-bot-users-without-an-application.ts b/src/util/migration/postgres/1761113394664-delete-bot-users-without-an-application.ts
index cf770afc..d8e13fdc 100644 --- a/src/util/migration/postgres/1761113394664-delete-bot-users-without-an-application.ts +++ b/src/util/migration/postgres/1761113394664-delete-bot-users-without-an-application.ts
@@ -6,5 +6,5 @@ export class DeleteBotUsersWithoutAnApplication1761113394664 implements Migratio await queryRunner.query(`DELETE FROM users WHERE bot = true AND id NOT IN (SELECT bot_user_id FROM applications);`); } - public async down(queryRunner: QueryRunner): Promise<void> {} + public async down(_: QueryRunner): Promise<void> {} } diff --git a/src/util/util/Database.ts b/src/util/util/Database.ts
index 805a9c18..0a3e6937 100644 --- a/src/util/util/Database.ts +++ b/src/util/util/Database.ts
@@ -59,7 +59,8 @@ if (!isHeadlessProcess) { ); console.log(`[Database] ${red(`If you would like to try *anyways*, see the error below:`)}`); try { - const _ = require("sqlite3"); + // TODO: fully remove sqlite3 + require("sqlite3"); } catch (e) { console.log(`[Database] ${red(`Failed to load sqlite3 package. Please install it with 'npm install --no-save sqlite3', or switch to a real database like Postgres.`)}`); process.exit(1); diff --git a/src/util/util/email/clients/IEmailClient.ts b/src/util/util/email/clients/IEmailClient.ts
index 9f118a96..722dd6c4 100644 --- a/src/util/util/email/clients/IEmailClient.ts +++ b/src/util/util/email/clients/IEmailClient.ts
@@ -33,6 +33,8 @@ export class BaseEmailClient implements IEmailClient { return; } sendMail(email: IEmail): Promise<void> { + // noinspection JSUnusedLocalSymbols - parameter exists for public API reasons + const _ = email; throw new Error("Method not implemented."); } } diff --git a/src/util/util/json/JsonSerializer.ts b/src/util/util/json/JsonSerializer.ts
index c88e4a2f..5d4b8075 100644 --- a/src/util/util/json/JsonSerializer.ts +++ b/src/util/util/json/JsonSerializer.ts
@@ -23,6 +23,7 @@ function getNextWorker(): Worker { return worker; } +// noinspection JSUnusedLocalSymbols - TODO: implement options export class JsonSerializer { public static Serialize<T>(value: T, opts?: JsonSerializerOptions): string { return JSON.stringify(value); diff --git a/src/webrtc/events/Message.ts b/src/webrtc/events/Message.ts
index 461d76e5..dfcc0610 100644 --- a/src/webrtc/events/Message.ts +++ b/src/webrtc/events/Message.ts
@@ -21,13 +21,6 @@ import { Tuple } from "lambert-server"; import OPCodeHandlers from "../opcodes"; import { VoiceOPCodes, VoicePayload, WebRtcWebSocket } from "../util"; -const PayloadSchema = { - op: Number, - $d: new Tuple(Object, Number), // or number for heartbeat sequence - $s: Number, - $t: String, -}; - export async function onMessage(this: WebRtcWebSocket, buffer: Buffer) { try { const data: VoicePayload = JSON.parse(buffer.toString()); diff --git a/src/webrtc/opcodes/BackendVersion.ts b/src/webrtc/opcodes/BackendVersion.ts
index d9172a7f..7e6673e7 100644 --- a/src/webrtc/opcodes/BackendVersion.ts +++ b/src/webrtc/opcodes/BackendVersion.ts
@@ -18,7 +18,7 @@ import { VoiceOPCodes, VoicePayload, WebRtcWebSocket, Send } from "../util"; -export async function onBackendVersion(this: WebRtcWebSocket, data: VoicePayload) { +export async function onBackendVersion(this: WebRtcWebSocket, _: VoicePayload) { await Send(this, { op: VoiceOPCodes.VOICE_BACKEND_VERSION, d: { voice: "0.8.43", rtc_worker: "0.3.26" }, diff --git a/src/webrtc/opcodes/Identify.ts b/src/webrtc/opcodes/Identify.ts
index d61d4bbb..e62fc7af 100644 --- a/src/webrtc/opcodes/Identify.ts +++ b/src/webrtc/opcodes/Identify.ts
@@ -25,6 +25,7 @@ import { subscribeToProducers } from "./Video"; export async function onIdentify(this: WebRtcWebSocket, data: VoicePayload) { clearTimeout(this.readyTimeout); + // noinspection JSUnusedLocalSymbols - TODO: use video? const { server_id, user_id, session_id, token, streams, video } = validateSchema("VoiceIdentifySchema", data.d) as VoiceIdentifySchema; // server_id can be one of the following: a unique id for a GO Live stream, a channel id for a DM voice call, or a guild id for a guild voice channel diff --git a/src/webrtc/opcodes/Video.ts b/src/webrtc/opcodes/Video.ts
index a7426198..38eb419b 100644 --- a/src/webrtc/opcodes/Video.ts +++ b/src/webrtc/opcodes/Video.ts
@@ -53,7 +53,7 @@ export async function onVideo(this: WebRtcWebSocket, payload: VoicePayload) { if (wantsToProduceAudio) { try { await Promise.race([ - new Promise<void>((resolve, reject) => { + new Promise<void>((resolve, _) => { this.webRtcClient?.emitter.once("connected", () => resolve()); }), new Promise<void>((resolve, reject) => {