diff options
author | Madeline <46743919+MaddyUnderStars@users.noreply.github.com> | 2023-01-17 00:01:14 +1100 |
---|---|---|
committer | Madeline <46743919+MaddyUnderStars@users.noreply.github.com> | 2023-01-17 00:01:14 +1100 |
commit | c0b12bc1668bb68f416747818f877c1a18a0b44a (patch) | |
tree | ebbcc7d0afa6611b8beab1d939b05c96ade1f688 | |
parent | Return embed proxy url even if imagor not set up. Also make warning nicer (diff) | |
download | server-c0b12bc1668bb68f416747818f877c1a18a0b44a.tar.xz |
Fix deleting an application if it has a bot
-rw-r--r-- | src/api/routes/applications/#id/index.ts | 2 | ||||
-rw-r--r-- | src/util/entities/Application.ts | 4 |
2 files changed, 2 insertions, 4 deletions
diff --git a/src/api/routes/applications/#id/index.ts b/src/api/routes/applications/#id/index.ts index 11cd5a56..6ed602f1 100644 --- a/src/api/routes/applications/#id/index.ts +++ b/src/api/routes/applications/#id/index.ts @@ -71,8 +71,6 @@ router.post("/delete", route({}), async (req: Request, res: Response) => { ) throw new HTTPError(req.t("auth:login.INVALID_TOTP_CODE"), 60008); - if (app.bot) await User.delete({ id: app.bot.id }); - await Application.delete({ id: app.id }); res.send().status(200); diff --git a/src/util/entities/Application.ts b/src/util/entities/Application.ts index e37f5ee5..081b5cf4 100644 --- a/src/util/entities/Application.ts +++ b/src/util/entities/Application.ts @@ -41,7 +41,7 @@ export class Application extends BaseClass { verify_key: string; @JoinColumn({ name: "owner_id" }) - @ManyToOne(() => User) + @ManyToOne(() => User, { onDelete: "CASCADE" }) owner: User; // TODO: enum this? https://discord.com/developers/docs/resources/application#application-object-application-flags @@ -76,7 +76,7 @@ export class Application extends BaseClass { discovery_eligibility_flags: number = 2240; @JoinColumn({ name: "bot_user_id" }) - @OneToOne(() => User) + @OneToOne(() => User, { onDelete: "CASCADE" }) bot?: User; @Column({ type: "simple-array", nullable: true }) |