summary refs log tree commit diff
path: root/util/src/entities
diff options
context:
space:
mode:
authorTheArcaneBrony <myrainbowdash949@gmail.com>2022-08-13 20:45:51 +0200
committerTheArcaneBrony <myrainbowdash949@gmail.com>2022-08-13 20:45:51 +0200
commitde9a6f28e5a06e2727bfa82c38b9f88fcd7bda02 (patch)
tree33367f419e70cce1ddab1aef129644e88f2d8263 /util/src/entities
parentMerge pull request #839 from fosscord/dev/dms (diff)
downloadserver-de9a6f28e5a06e2727bfa82c38b9f88fcd7bda02.tar.xz
Do the funny thing (make user->invite cascade delet)
Diffstat (limited to 'util/src/entities')
-rw-r--r--util/src/entities/Invite.ts13
1 files changed, 8 insertions, 5 deletions
diff --git a/util/src/entities/Invite.ts b/util/src/entities/Invite.ts
index b672caf7..1e0ebe52 100644
--- a/util/src/entities/Invite.ts
+++ b/util/src/entities/Invite.ts
@@ -4,19 +4,20 @@ import { BaseClassWithoutId } from "./BaseClass";
 import { Channel } from "./Channel";
 import { Guild } from "./Guild";
 import { User } from "./User";
+import { random } from "@fosscord/api";
 
 export const PublicInviteRelation = ["inviter", "guild", "channel"];
 
 @Entity("invites")
 export class Invite extends BaseClassWithoutId {
 	@PrimaryColumn()
-	code: string;
+	code: string = random();
 
 	@Column()
-	temporary: boolean;
+	temporary: boolean = true;
 
 	@Column()
-	uses: number;
+	uses: number = 0;
 
 	@Column()
 	max_uses: number;
@@ -25,7 +26,7 @@ export class Invite extends BaseClassWithoutId {
 	max_age: number;
 
 	@Column()
-	created_at: Date;
+	created_at: Date = new Date();
 
 	@Column()
 	expires_at: Date;
@@ -55,7 +56,9 @@ export class Invite extends BaseClassWithoutId {
 	inviter_id: string;
 
 	@JoinColumn({ name: "inviter_id" })
-	@ManyToOne(() => User)
+	@ManyToOne(() => User, {
+		onDelete: "CASCADE"
+	})
 	inviter: User;
 
 	@Column({ nullable: true })