summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorMadeline <46743919+MaddyUnderStars@users.noreply.github.com>2024-11-20 12:00:26 +1100
committerGitHub <noreply@github.com>2024-11-20 12:00:26 +1100
commit43b342a152be86ed554f7d43c35304227aedef7c (patch)
tree01b420a21f7ce8a3064a296155ebdc70da1fdf80 /src
parentbuild(deps): update npm dependencies hash [dependabot skip] (diff)
parentrun prettier (diff)
downloadserver-ts-43b342a152be86ed554f7d43c35304227aedef7c.tar.xz
Merge pull request #1236 from dank074/patch/prettier
Diffstat (limited to 'src')
-rw-r--r--src/api/Server.ts3
-rw-r--r--src/api/routes/auth/generate-registration-tokens.ts2
-rw-r--r--src/api/routes/channels/#channel_id/messages/index.ts2
-rw-r--r--src/api/routes/channels/#channel_id/typing.ts2
-rw-r--r--src/api/routes/discoverable-guilds.ts8
-rw-r--r--src/api/routes/guild-recommendations.ts2
-rw-r--r--src/api/routes/oauth2/authorize.ts2
-rw-r--r--src/gateway/events/Message.ts6
-rw-r--r--src/gateway/listener/listener.ts25
-rw-r--r--src/util/entities/Channel.ts2
-rw-r--r--src/util/util/Permissions.ts28
11 files changed, 52 insertions, 30 deletions
diff --git a/src/api/Server.ts b/src/api/Server.ts

index 27adc0bd2..b42749699 100644 --- a/src/api/Server.ts +++ b/src/api/Server.ts
@@ -100,8 +100,7 @@ export class SpacebarServer extends Server { this.app.set("json replacer", JSONReplacer); const trustedProxies = Config.get().security.trustedProxies; - if(trustedProxies) - this.app.set("trust proxy", trustedProxies); + if (trustedProxies) this.app.set("trust proxy", trustedProxies); this.app.use(CORS); this.app.use(BodyParser({ inflate: true, limit: "10mb" })); diff --git a/src/api/routes/auth/generate-registration-tokens.ts b/src/api/routes/auth/generate-registration-tokens.ts
index 50c389e0a..dbe2dab44 100644 --- a/src/api/routes/auth/generate-registration-tokens.ts +++ b/src/api/routes/auth/generate-registration-tokens.ts
@@ -72,7 +72,7 @@ router.get( `${Config.get().general.frontPage}/register?token=${ x.token }`, - ) + ) : tokens.map((x) => x.token); if (req.query.plain) return res.send(ret.join("\n")); diff --git a/src/api/routes/channels/#channel_id/messages/index.ts b/src/api/routes/channels/#channel_id/messages/index.ts
index 521ab7a1b..4ba289275 100644 --- a/src/api/routes/channels/#channel_id/messages/index.ts +++ b/src/api/routes/channels/#channel_id/messages/index.ts
@@ -417,7 +417,7 @@ router.post( ? Member.update( { id: req.user_id, guild_id: message.guild_id }, { last_message_id: message.id }, - ) + ) : null, channel.save(), ]); diff --git a/src/api/routes/channels/#channel_id/typing.ts b/src/api/routes/channels/#channel_id/typing.ts
index 90e781753..bb8d48977 100644 --- a/src/api/routes/channels/#channel_id/typing.ts +++ b/src/api/routes/channels/#channel_id/typing.ts
@@ -54,7 +54,7 @@ router.post( ...member, roles: member?.roles?.map((x) => x.id), }, - } + } : null), channel_id, timestamp, diff --git a/src/api/routes/discoverable-guilds.ts b/src/api/routes/discoverable-guilds.ts
index b8c6a3867..781affe76 100644 --- a/src/api/routes/discoverable-guilds.ts +++ b/src/api/routes/discoverable-guilds.ts
@@ -42,24 +42,24 @@ router.get( guilds = showAllGuilds ? await Guild.find({ take: Math.abs(Number(limit || configLimit)), - }) + }) : await Guild.find({ where: { features: Like(`%DISCOVERABLE%`) }, take: Math.abs(Number(limit || configLimit)), - }); + }); } else { guilds = showAllGuilds ? await Guild.find({ where: { primary_category_id: categories.toString() }, take: Math.abs(Number(limit || configLimit)), - }) + }) : await Guild.find({ where: { primary_category_id: categories.toString(), features: Like("%DISCOVERABLE%"), }, take: Math.abs(Number(limit || configLimit)), - }); + }); } const total = guilds ? guilds.length : undefined; diff --git a/src/api/routes/guild-recommendations.ts b/src/api/routes/guild-recommendations.ts
index 876780df3..3ac31680f 100644 --- a/src/api/routes/guild-recommendations.ts +++ b/src/api/routes/guild-recommendations.ts
@@ -48,7 +48,7 @@ router.get( : await Guild.find({ where: { features: Like("%DISCOVERABLE%") }, take: Math.abs(Number(limit || 24)), - }); + }); res.send({ recommended_guilds: guilds, load_id: `server_recs/${genLoadId(32)}`, diff --git a/src/api/routes/oauth2/authorize.ts b/src/api/routes/oauth2/authorize.ts
index 2f2351f38..63f403a13 100644 --- a/src/api/routes/oauth2/authorize.ts +++ b/src/api/routes/oauth2/authorize.ts
@@ -118,7 +118,7 @@ router.get( guild: { roles: x?.roles || [], }, - }); + }); return { id: x.guild.id, diff --git a/src/gateway/events/Message.ts b/src/gateway/events/Message.ts
index f63ec37c4..8ec9fc7d8 100644 --- a/src/gateway/events/Message.ts +++ b/src/gateway/events/Message.ts
@@ -89,11 +89,13 @@ export async function Message(this: WebSocket, buffer: WS.Data) { } try { - return await Sentry.startSpan( // Emma [it/its]@Rory&: is this the right function to migrate to in v8? + return await Sentry.startSpan( + // Emma [it/its]@Rory&: is this the right function to migrate to in v8? { op: "websocket.server", name: `GATEWAY ${OPCODES[data.op]}`, - attributes: { // this needs to be reworked :) + attributes: { + // this needs to be reworked :) ...data.d, token: data?.d?.token ? "[Redacted]" : undefined, }, diff --git a/src/gateway/listener/listener.ts b/src/gateway/listener/listener.ts
index eb1afe16a..4044b1116 100644 --- a/src/gateway/listener/listener.ts +++ b/src/gateway/listener/listener.ts
@@ -82,7 +82,7 @@ export async function setupListener(this: WebSocket) { const opts: { acknowledge: boolean; - channel?: AMQChannel & { queues?: unknown, ch?: number }; + channel?: AMQChannel & { queues?: unknown; ch?: number }; } = { acknowledge: true, }; @@ -91,10 +91,20 @@ export async function setupListener(this: WebSocket) { console.log("[RabbitMQ] setupListener: open for ", this.user_id); if (RabbitMQ.connection) { - console.log("[RabbitMQ] setupListener: opts.channel = ", typeof opts.channel, "with channel id", opts.channel?.ch); + console.log( + "[RabbitMQ] setupListener: opts.channel = ", + typeof opts.channel, + "with channel id", + opts.channel?.ch, + ); opts.channel = await RabbitMQ.connection.createChannel(); opts.channel.queues = {}; - console.log("[RabbitMQ] channel created: ", typeof opts.channel, "with channel id", opts.channel?.ch); + console.log( + "[RabbitMQ] channel created: ", + typeof opts.channel, + "with channel id", + opts.channel?.ch, + ); } this.events[this.user_id] = await listenEvent(this.user_id, consumer, opts); @@ -132,7 +142,14 @@ export async function setupListener(this: WebSocket) { }); this.once("close", () => { - console.log("[RabbitMQ] setupListener: close for", this.user_id, "=", typeof opts.channel, "with channel id", opts.channel?.ch); + console.log( + "[RabbitMQ] setupListener: close for", + this.user_id, + "=", + typeof opts.channel, + "with channel id", + opts.channel?.ch, + ); if (opts.channel) opts.channel.close(); else { Object.values(this.events).forEach((x) => x?.()); diff --git a/src/util/entities/Channel.ts b/src/util/entities/Channel.ts
index 7bc79d196..898308ac8 100644 --- a/src/util/entities/Channel.ts +++ b/src/util/entities/Channel.ts
@@ -323,7 +323,7 @@ export class Channel extends BaseClass { event: "CHANNEL_CREATE", data: channel, guild_id: channel.guild_id, - } as ChannelCreateEvent) + } as ChannelCreateEvent) : Promise.resolve(), Guild.insertChannelInOrder(guild.id, ret.id, position, guild), ]); diff --git a/src/util/util/Permissions.ts b/src/util/util/Permissions.ts
index 996c72ea5..5aae14c25 100644 --- a/src/util/util/Permissions.ts +++ b/src/util/util/Permissions.ts
@@ -132,18 +132,22 @@ export class Permissions extends BitField { init?: bigint, ) { // TODO: do not deny any permissions if admin - return overwrites.reduce((permission, overwrite) => { - // apply disallowed permission - // * permission: current calculated permission (e.g. 010) - // * deny contains all denied permissions (e.g. 011) - // * allow contains all explicitly allowed permisions (e.g. 100) - return ( - (permission & ~BigInt(overwrite.deny)) | BigInt(overwrite.allow) - ); - // ~ operator inverts deny (e.g. 011 -> 100) - // & operator only allows 1 for both ~deny and permission (e.g. 010 & 100 -> 000) - // | operators adds both together (e.g. 000 + 100 -> 100) - }, init || BigInt(0)); + return overwrites.reduce( + (permission, overwrite) => { + // apply disallowed permission + // * permission: current calculated permission (e.g. 010) + // * deny contains all denied permissions (e.g. 011) + // * allow contains all explicitly allowed permisions (e.g. 100) + return ( + (permission & ~BigInt(overwrite.deny)) | + BigInt(overwrite.allow) + ); + // ~ operator inverts deny (e.g. 011 -> 100) + // & operator only allows 1 for both ~deny and permission (e.g. 010 & 100 -> 000) + // | operators adds both together (e.g. 000 + 100 -> 100) + }, + init || BigInt(0), + ); } static rolePermission(roles: Role[]) {