1
0
mirror of https://github.com/spacebarchat/server.git synced 2024-11-09 20:22:47 +01:00

Fix deleting an application if it has a bot

This commit is contained in:
Madeline 2023-01-17 00:01:14 +11:00
parent 49a311f5d0
commit c0b12bc166
No known key found for this signature in database
GPG Key ID: 1958E017C36F2E47
2 changed files with 2 additions and 4 deletions

View File

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

View File

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