1
0
mirror of https://github.com/spacebarchat/server.git synced 2024-11-21 09:52:38 +01:00

run prettier

This commit is contained in:
dank074 2024-11-19 14:19:40 -06:00
parent 93219757a6
commit f5d6394c38
14 changed files with 157 additions and 128 deletions

View File

@ -9,39 +9,46 @@ import { FlatCompat } from "@eslint/eslintrc";
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
allConfig: js.configs.all
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
allConfig: js.configs.all,
});
export default [{
ignores: [
"**/node_modules",
"**/dist",
"**/README.md",
"**/COPYING",
"src/webrtc",
"**/scripts/",
"**/assets",
],
}, ...compat.extends("eslint:recommended", "plugin:@typescript-eslint/recommended"), {
plugins: {
"@typescript-eslint": typescriptEslint,
},
export default [
{
ignores: [
"**/node_modules",
"**/dist",
"**/README.md",
"**/COPYING",
"src/webrtc",
"**/scripts/",
"**/assets",
],
},
...compat.extends(
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
),
{
plugins: {
"@typescript-eslint": typescriptEslint,
},
languageOptions: {
globals: {
...globals.node,
},
languageOptions: {
globals: {
...globals.node,
},
parser: tsParser,
},
parser: tsParser,
},
rules: {
"no-mixed-spaces-and-tabs": "off",
"@typescript-eslint/no-inferrable-types": "off", // Required by typeorm
"@typescript-eslint/no-var-requires": "off", // Sometimes requred by typeorm to resolve circular deps
"@typescript-eslint/no-require-imports": "off",
"@typescript-eslint/no-unused-vars": "off",
},
}];
rules: {
"no-mixed-spaces-and-tabs": "off",
"@typescript-eslint/no-inferrable-types": "off", // Required by typeorm
"@typescript-eslint/no-var-requires": "off", // Sometimes requred by typeorm to resolve circular deps
"@typescript-eslint/no-require-imports": "off",
"@typescript-eslint/no-unused-vars": "off",
},
},
];

View File

@ -1,61 +1,61 @@
{
"nodes": {
"flake-utils": {
"inputs": {
"systems": "systems"
},
"locked": {
"lastModified": 1731533236,
"narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1731676054,
"narHash": "sha256-OZiZ3m8SCMfh3B6bfGC/Bm4x3qc1m2SVEAlkV6iY7Yg=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "5e4fbfb6b3de1aa2872b76d49fafc942626e2add",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs"
}
},
"systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
}
},
"root": "root",
"version": 7
"nodes": {
"flake-utils": {
"inputs": {
"systems": "systems"
},
"locked": {
"lastModified": 1731533236,
"narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1731676054,
"narHash": "sha256-OZiZ3m8SCMfh3B6bfGC/Bm4x3qc1m2SVEAlkV6iY7Yg=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "5e4fbfb6b3de1aa2872b76d49fafc942626e2add",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs"
}
},
"systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
}
},
"root": "root",
"version": 7
}

View File

@ -1,23 +1,23 @@
{
"folders": [
{
"path": "src"
"path": "src",
},
{
"path": "assets"
"path": "assets",
},
{
"path": "scripts"
"path": "scripts",
},
{
"path": "."
}
"path": ".",
},
],
"settings": {
"typescript.tsdk": "util\\node_modules\\typescript\\lib"
"typescript.tsdk": "util\\node_modules\\typescript\\lib",
},
"launch": {
"version": "0.2.0",
"configurations": []
}
"configurations": [],
},
}

View File

@ -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" }));

View File

@ -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"));

View File

@ -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(),
]);

View File

@ -54,7 +54,7 @@ router.post(
...member,
roles: member?.roles?.map((x) => x.id),
},
}
}
: null),
channel_id,
timestamp,

View File

@ -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;

View File

@ -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)}`,

View File

@ -118,7 +118,7 @@ router.get(
guild: {
roles: x?.roles || [],
},
});
});
return {
id: x.guild.id,

View File

@ -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,
},

View File

@ -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?.());

View File

@ -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),
]);

View File

@ -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[]) {