From c311edc99c4dfc2a275ab99b887769660c29bbf0 Mon Sep 17 00:00:00 2001 From: Puyodead1 Date: Sun, 27 Aug 2023 20:16:49 -0400 Subject: make guild voice a text based channel --- src/util/entities/Channel.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/util') diff --git a/src/util/entities/Channel.ts b/src/util/entities/Channel.ts index 19952bc2..6268d735 100644 --- a/src/util/entities/Channel.ts +++ b/src/util/entities/Channel.ts @@ -506,7 +506,6 @@ export interface DMChannel extends Omit { export function isTextChannel(type: ChannelType): boolean { switch (type) { case ChannelType.GUILD_STORE: - case ChannelType.GUILD_VOICE: case ChannelType.GUILD_STAGE_VOICE: case ChannelType.GUILD_CATEGORY: case ChannelType.GUILD_FORUM: @@ -515,6 +514,7 @@ export function isTextChannel(type: ChannelType): boolean { case ChannelType.DM: case ChannelType.GROUP_DM: case ChannelType.GUILD_NEWS: + case ChannelType.GUILD_VOICE: case ChannelType.GUILD_NEWS_THREAD: case ChannelType.GUILD_PUBLIC_THREAD: case ChannelType.GUILD_PRIVATE_THREAD: -- cgit 1.5.1 From ed7fd34f46ffd1322f7d0e6ea81e4612afb0ec4a Mon Sep 17 00:00:00 2001 From: Madeline <46743919+MaddyUnderStars@users.noreply.github.com> Date: Sat, 2 Sep 2023 01:01:58 +1000 Subject: DB_LOGGING env var --- src/util/util/Database.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/util') diff --git a/src/util/util/Database.ts b/src/util/util/Database.ts index a6b24b3e..3a45eea0 100644 --- a/src/util/util/Database.ts +++ b/src/util/util/Database.ts @@ -16,12 +16,12 @@ along with this program. If not, see . */ -import { DataSource } from "typeorm"; -import { yellow, green, red } from "picocolors"; -import { Migration } from "../entities/Migration"; -import { ConfigEntity } from "../entities/Config"; import { config } from "dotenv"; import path from "path"; +import { green, red, yellow } from "picocolors"; +import { DataSource } from "typeorm"; +import { ConfigEntity } from "../entities/Config"; +import { Migration } from "../entities/Migration"; // UUID extension option is only supported with postgres // We want to generate all id's with Snowflakes that's why we have our own BaseEntity class @@ -50,7 +50,7 @@ const DataSourceOptions = new DataSource({ database: isSqlite ? dbConnectionString : undefined, entities: [path.join(__dirname, "..", "entities", "*.js")], synchronize: !!process.env.DB_SYNC, - logging: false, + logging: !!process.env.DB_LOGGING, bigNumberStrings: false, supportBigNumbers: true, name: "default", @@ -129,7 +129,7 @@ export async function initDatabase(): Promise { return dbConnection; } -export { dbConnection, DataSourceOptions, DatabaseType }; +export { DataSourceOptions, DatabaseType, dbConnection }; export async function closeDatabase() { await dbConnection?.destroy(); -- cgit 1.5.1 From 2f48212e6e6813f90eb13cf8ed79e0ebb3440b31 Mon Sep 17 00:00:00 2001 From: Madeline <46743919+MaddyUnderStars@users.noreply.github.com> Date: Sat, 2 Sep 2023 02:21:42 +1000 Subject: typeorm inverse relations of guild relations --- src/util/entities/Channel.ts | 5 +++-- src/util/entities/Emoji.ts | 2 +- src/util/entities/Invite.ts | 2 +- src/util/entities/Member.ts | 1 + src/util/entities/Role.ts | 4 ++-- src/util/entities/Sticker.ts | 4 ++-- src/util/entities/VoiceState.ts | 4 ++-- 7 files changed, 12 insertions(+), 10 deletions(-) (limited to 'src/util') diff --git a/src/util/entities/Channel.ts b/src/util/entities/Channel.ts index 6268d735..9f7041d4 100644 --- a/src/util/entities/Channel.ts +++ b/src/util/entities/Channel.ts @@ -97,10 +97,11 @@ export class Channel extends BaseClass { guild_id?: string; @JoinColumn({ name: "guild_id" }) - @ManyToOne(() => Guild, { + @ManyToOne(() => Guild, (guild) => guild.channels, { onDelete: "CASCADE", + nullable: true, }) - guild: Guild; + guild?: Guild; @Column({ nullable: true }) @RelationId((channel: Channel) => channel.parent) diff --git a/src/util/entities/Emoji.ts b/src/util/entities/Emoji.ts index 0bc2f423..4d851698 100644 --- a/src/util/entities/Emoji.ts +++ b/src/util/entities/Emoji.ts @@ -33,7 +33,7 @@ export class Emoji extends BaseClass { guild_id: string; @JoinColumn({ name: "guild_id" }) - @ManyToOne(() => Guild, { + @ManyToOne(() => Guild, (guild) => guild.emojis, { onDelete: "CASCADE", }) guild: Guild; diff --git a/src/util/entities/Invite.ts b/src/util/entities/Invite.ts index 7970c4f0..f7e54fbe 100644 --- a/src/util/entities/Invite.ts +++ b/src/util/entities/Invite.ts @@ -53,7 +53,7 @@ export class Invite extends BaseClassWithoutId { guild_id: string; @JoinColumn({ name: "guild_id" }) - @ManyToOne(() => Guild, { + @ManyToOne(() => Guild, (guild) => guild.invites, { onDelete: "CASCADE", }) guild: Guild; diff --git a/src/util/entities/Member.ts b/src/util/entities/Member.ts index d305e4f5..0535313e 100644 --- a/src/util/entities/Member.ts +++ b/src/util/entities/Member.ts @@ -327,6 +327,7 @@ export class Member extends BaseClassWithoutId { id: guild_id, }, relations: PublicGuildRelations, + relationLoadStrategy: "query", }); const memberCount = await Member.count({ where: { guild_id } }); diff --git a/src/util/entities/Role.ts b/src/util/entities/Role.ts index 9a601f31..e8e5feda 100644 --- a/src/util/entities/Role.ts +++ b/src/util/entities/Role.ts @@ -23,12 +23,12 @@ import { Guild } from "./Guild"; @Entity("roles") export class Role extends BaseClass { - @Column({ nullable: true }) + @Column() @RelationId((role: Role) => role.guild) guild_id: string; @JoinColumn({ name: "guild_id" }) - @ManyToOne(() => Guild, { + @ManyToOne(() => Guild, (guild) => guild.roles, { onDelete: "CASCADE", }) guild: Guild; diff --git a/src/util/entities/Sticker.ts b/src/util/entities/Sticker.ts index cd07e65a..e9294f92 100644 --- a/src/util/entities/Sticker.ts +++ b/src/util/entities/Sticker.ts @@ -17,9 +17,9 @@ */ import { Column, Entity, JoinColumn, ManyToOne, RelationId } from "typeorm"; -import { User } from "./User"; import { BaseClass } from "./BaseClass"; import { Guild } from "./Guild"; +import { User } from "./User"; export enum StickerType { STANDARD = 1, @@ -62,7 +62,7 @@ export class Sticker extends BaseClass { guild_id?: string; @JoinColumn({ name: "guild_id" }) - @ManyToOne(() => Guild, { + @ManyToOne(() => Guild, (guild) => guild.stickers, { onDelete: "CASCADE", }) guild?: Guild; diff --git a/src/util/entities/VoiceState.ts b/src/util/entities/VoiceState.ts index b291c4d3..84b0ca71 100644 --- a/src/util/entities/VoiceState.ts +++ b/src/util/entities/VoiceState.ts @@ -20,8 +20,8 @@ import { Column, Entity, JoinColumn, ManyToOne, RelationId } from "typeorm"; import { BaseClass } from "./BaseClass"; import { Channel } from "./Channel"; import { Guild } from "./Guild"; -import { User } from "./User"; import { Member } from "./Member"; +import { User } from "./User"; //https://gist.github.com/vassjozsef/e482c65df6ee1facaace8b3c9ff66145#file-voice_state-ex @Entity("voice_states") @@ -31,7 +31,7 @@ export class VoiceState extends BaseClass { guild_id: string; @JoinColumn({ name: "guild_id" }) - @ManyToOne(() => Guild, { + @ManyToOne(() => Guild, (guild) => guild.voice_states, { onDelete: "CASCADE", }) guild?: Guild; -- cgit 1.5.1 From eebd61b19d9d21c32685e72552748874c10c8dfb Mon Sep 17 00:00:00 2001 From: Madeline <46743919+MaddyUnderStars@users.noreply.github.com> Date: Sat, 2 Sep 2023 14:10:32 +1000 Subject: update sentry --- package-lock.json | 104 ++++++++++++++++++++++++++---------------------- package.json | 5 +-- src/util/util/Sentry.ts | 35 ++++++++++------ 3 files changed, 81 insertions(+), 63 deletions(-) (limited to 'src/util') diff --git a/package-lock.json b/package-lock.json index 0576c589..aabad644 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,9 +11,8 @@ "license": "AGPL-3.0-only", "dependencies": { "@aws-sdk/client-s3": "^3.385.0", - "@sentry/integrations": "^7.61.1", - "@sentry/node": "^7.61.1", - "@sentry/tracing": "^7.61.1", + "@sentry/integrations": "^7.66.0", + "@sentry/node": "^7.66.0", "ajv": "8.6.2", "ajv-formats": "2.1.1", "amqplib": "^0.10.3", @@ -1245,41 +1244,34 @@ "node": "6.* || 8.* || >=10.*" } }, - "node_modules/@sentry-internal/tracing": { - "version": "7.63.0", - "resolved": "https://registry.npmjs.org/@sentry-internal/tracing/-/tracing-7.63.0.tgz", - "integrity": "sha512-Fxpc53p6NGvLSURg3iRvZA0k10K9yfeVhtczvJnpX30POBuV41wxpkLHkb68fjksirjEma1K3Ut1iLOEEDpPQg==", + "node_modules/@sentry/integrations": { + "version": "7.66.0", + "resolved": "https://registry.npmjs.org/@sentry/integrations/-/integrations-7.66.0.tgz", + "integrity": "sha512-2PNEnihG9e9Rjbz205+A4BYtFcS2XdgwsN6obAU6Yir7VIbskwZXxx87lKZuz6S53sOWPHleC7uvUBjL+Q6vYg==", "dependencies": { - "@sentry/core": "7.63.0", - "@sentry/types": "7.63.0", - "@sentry/utils": "7.63.0", + "@sentry/types": "7.66.0", + "@sentry/utils": "7.66.0", + "localforage": "^1.8.1", "tslib": "^2.4.1 || ^1.9.3" }, "engines": { "node": ">=8" } }, - "node_modules/@sentry/core": { - "version": "7.63.0", - "resolved": "https://registry.npmjs.org/@sentry/core/-/core-7.63.0.tgz", - "integrity": "sha512-13Ljiq8hv6ieCkO+Am99/PljYJO5ynKT/hRQrWgGy9IIEgUr8sV3fW+1W6K4/3MCeOJou0HsiGBjOD1mASItVg==", - "dependencies": { - "@sentry/types": "7.63.0", - "@sentry/utils": "7.63.0", - "tslib": "^2.4.1 || ^1.9.3" - }, + "node_modules/@sentry/integrations/node_modules/@sentry/types": { + "version": "7.66.0", + "resolved": "https://registry.npmjs.org/@sentry/types/-/types-7.66.0.tgz", + "integrity": "sha512-uUMSoSiar6JhuD8p7ON/Ddp4JYvrVd2RpwXJRPH1A4H4Bd4DVt1mKJy1OLG6HdeQv39XyhB1lPZckKJg4tATPw==", "engines": { "node": ">=8" } }, - "node_modules/@sentry/integrations": { - "version": "7.63.0", - "resolved": "https://registry.npmjs.org/@sentry/integrations/-/integrations-7.63.0.tgz", - "integrity": "sha512-+P8GNqFZNH/yS/KPbvUfUDERneoRNUrqp9ayvvp8aq4cTtrBdM72CYgI21oG6cti42SSM1VDLYZomTV3ElPzSg==", + "node_modules/@sentry/integrations/node_modules/@sentry/utils": { + "version": "7.66.0", + "resolved": "https://registry.npmjs.org/@sentry/utils/-/utils-7.66.0.tgz", + "integrity": "sha512-9GYUVgXjK66uXXcLXVMXVzlptqMtq1eJENCuDeezQiEFrNA71KkLDg00wESp+LL+bl3wpVTBApArpbF6UEG5hQ==", "dependencies": { - "@sentry/types": "7.63.0", - "@sentry/utils": "7.63.0", - "localforage": "^1.8.1", + "@sentry/types": "7.66.0", "tslib": "^2.4.1 || ^1.9.3" }, "engines": { @@ -1287,14 +1279,14 @@ } }, "node_modules/@sentry/node": { - "version": "7.63.0", - "resolved": "https://registry.npmjs.org/@sentry/node/-/node-7.63.0.tgz", - "integrity": "sha512-tSMyfQNbfjX1w8vJDZtvWeaD4QQ/Z4zVW/TLXfL/JZFIIksPgDZmqLdF+NJS4bSGTU5JiHiUh4pYhME4mHgNBQ==", - "dependencies": { - "@sentry-internal/tracing": "7.63.0", - "@sentry/core": "7.63.0", - "@sentry/types": "7.63.0", - "@sentry/utils": "7.63.0", + "version": "7.66.0", + "resolved": "https://registry.npmjs.org/@sentry/node/-/node-7.66.0.tgz", + "integrity": "sha512-PxqIqLr4Sh5xcDfECiBQ4PuZ7v8yTgLhaRkruWrZPYxQrcJFPkwbFkw/IskzVnhT2VwXUmeWEIlRMQKBJ0t83A==", + "dependencies": { + "@sentry-internal/tracing": "7.66.0", + "@sentry/core": "7.66.0", + "@sentry/types": "7.66.0", + "@sentry/utils": "7.66.0", "cookie": "^0.4.1", "https-proxy-agent": "^5.0.0", "lru_map": "^0.3.3", @@ -1304,31 +1296,47 @@ "node": ">=8" } }, - "node_modules/@sentry/tracing": { - "version": "7.63.0", - "resolved": "https://registry.npmjs.org/@sentry/tracing/-/tracing-7.63.0.tgz", - "integrity": "sha512-91gjqM/3CD6XdN1JVSLnUTD7HAI77NodP48+FZ2kgRkNmD2jojJBWsTC9NHG4UEO0PppjjwDPPJR1iHwybaO8g==", + "node_modules/@sentry/node/node_modules/@sentry-internal/tracing": { + "version": "7.66.0", + "resolved": "https://registry.npmjs.org/@sentry-internal/tracing/-/tracing-7.66.0.tgz", + "integrity": "sha512-3vCgC2hC3T45pn53yTDVcRpHoJTBxelDPPZVsipAbZnoOVPkj7n6dNfDhj3I3kwWCBPahPkXmE+R4xViR8VqJg==", "dependencies": { - "@sentry-internal/tracing": "7.63.0" + "@sentry/core": "7.66.0", + "@sentry/types": "7.66.0", + "@sentry/utils": "7.66.0", + "tslib": "^2.4.1 || ^1.9.3" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/@sentry/node/node_modules/@sentry/core": { + "version": "7.66.0", + "resolved": "https://registry.npmjs.org/@sentry/core/-/core-7.66.0.tgz", + "integrity": "sha512-WMAEPN86NeCJ1IT48Lqiz4MS5gdDjBwP4M63XP4msZn9aujSf2Qb6My5uT87AJr9zBtgk8MyJsuHr35F0P3q1w==", + "dependencies": { + "@sentry/types": "7.66.0", + "@sentry/utils": "7.66.0", + "tslib": "^2.4.1 || ^1.9.3" }, "engines": { "node": ">=8" } }, - "node_modules/@sentry/types": { - "version": "7.63.0", - "resolved": "https://registry.npmjs.org/@sentry/types/-/types-7.63.0.tgz", - "integrity": "sha512-pZNwJVW7RqNLGuTUAhoygt0c9zmc0js10eANAz0MstygJRhQI1tqPDuiELVdujPrbeL+IFKF+7NvRDAydR2Niw==", + "node_modules/@sentry/node/node_modules/@sentry/types": { + "version": "7.66.0", + "resolved": "https://registry.npmjs.org/@sentry/types/-/types-7.66.0.tgz", + "integrity": "sha512-uUMSoSiar6JhuD8p7ON/Ddp4JYvrVd2RpwXJRPH1A4H4Bd4DVt1mKJy1OLG6HdeQv39XyhB1lPZckKJg4tATPw==", "engines": { "node": ">=8" } }, - "node_modules/@sentry/utils": { - "version": "7.63.0", - "resolved": "https://registry.npmjs.org/@sentry/utils/-/utils-7.63.0.tgz", - "integrity": "sha512-7FQv1RYAwnuTuarruP+1+Jd6YQuN7i/Y7KltwPMVEwU7j5mzYQaexLr/Jz1XIdR2KYVdkbXQyP8jj8BmA6u9Jw==", + "node_modules/@sentry/node/node_modules/@sentry/utils": { + "version": "7.66.0", + "resolved": "https://registry.npmjs.org/@sentry/utils/-/utils-7.66.0.tgz", + "integrity": "sha512-9GYUVgXjK66uXXcLXVMXVzlptqMtq1eJENCuDeezQiEFrNA71KkLDg00wESp+LL+bl3wpVTBApArpbF6UEG5hQ==", "dependencies": { - "@sentry/types": "7.63.0", + "@sentry/types": "7.66.0", "tslib": "^2.4.1 || ^1.9.3" }, "engines": { diff --git a/package.json b/package.json index 70e4ae84..3994670b 100644 --- a/package.json +++ b/package.json @@ -66,9 +66,8 @@ }, "dependencies": { "@aws-sdk/client-s3": "^3.385.0", - "@sentry/integrations": "^7.61.1", - "@sentry/node": "^7.61.1", - "@sentry/tracing": "^7.61.1", + "@sentry/integrations": "^7.66.0", + "@sentry/node": "^7.66.0", "ajv": "8.6.2", "ajv-formats": "2.1.1", "amqplib": "^0.10.3", diff --git a/src/util/util/Sentry.ts b/src/util/util/Sentry.ts index e302da0c..74a23a1e 100644 --- a/src/util/util/Sentry.ts +++ b/src/util/util/Sentry.ts @@ -16,13 +16,12 @@ along with this program. If not, see . */ -import { Config } from "./Config"; import { yellow } from "picocolors"; +import { Config } from "./Config"; -import express from "express"; -import * as SentryNode from "@sentry/node"; -import * as Tracing from "@sentry/tracing"; import * as Integrations from "@sentry/integrations"; +import * as SentryNode from "@sentry/node"; +import express from "express"; // Work around for when bundle calls api/etc let errorHandlersUsed = false; @@ -46,16 +45,28 @@ export const Sentry = { ); } + const integrations = [ + new SentryNode.Integrations.Http({ tracing: true }), + new Integrations.RewriteFrames({ + root: __dirname, + }), + new SentryNode.Integrations.Http({ + tracing: true, + breadcrumbs: true, + }), + ...SentryNode.autoDiscoverNodePerformanceMonitoringIntegrations(), + ]; + + if (app) + integrations.push( + new SentryNode.Integrations.Express({ + app, + }), + ); + SentryNode.init({ dsn: endpoint, - integrations: [ - new SentryNode.Integrations.Http({ tracing: true }), - new Tracing.Integrations.Express({ app }), - new Tracing.Integrations.Mysql(), - new Integrations.RewriteFrames({ - root: __dirname, - }), - ], + integrations, tracesSampleRate: traceSampleRate, // naming? environment, }); -- cgit 1.5.1