mirror of
https://github.com/spacebarchat/server.git
synced 2026-05-10 19:17:03 +00:00
properly mark unused params
This commit is contained in:
@@ -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,
|
||||
}));
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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>;
|
||||
|
||||
@@ -59,6 +59,7 @@ router.post(
|
||||
},
|
||||
);
|
||||
|
||||
// noinspection JSUnusedLocalSymbols - TODO: implement
|
||||
router.post(
|
||||
"/verify-code",
|
||||
route({
|
||||
|
||||
@@ -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({
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -28,4 +28,4 @@ async function main() {
|
||||
}
|
||||
}
|
||||
|
||||
main().then((r) => console.log("meow"));
|
||||
main().then(() => console.log("meow"));
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -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();
|
||||
|
||||
@@ -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 },
|
||||
});
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -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> {}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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());
|
||||
|
||||
@@ -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" },
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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) => {
|
||||
|
||||
Reference in New Issue
Block a user