summary refs log tree commit diff
path: root/util/src/entities
diff options
context:
space:
mode:
authorFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-09-13 12:22:59 +0200
committerFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-09-13 12:22:59 +0200
commit9429c5c09ab1b7ce081c0786e080da4ee78ad22c (patch)
tree60753f7209271c2096505530624258e9daad276e /util/src/entities
parent:bug: fix relationship (diff)
downloadserver-9429c5c09ab1b7ce081c0786e080da4ee78ad22c.tar.xz
:bug: fix In() query
Diffstat (limited to 'util/src/entities')
-rw-r--r--util/src/entities/User.ts14
1 files changed, 11 insertions, 3 deletions
diff --git a/util/src/entities/User.ts b/util/src/entities/User.ts
index 9394f9e8..736704f8 100644
--- a/util/src/entities/User.ts
+++ b/util/src/entities/User.ts
@@ -106,7 +106,7 @@ export class User extends BaseClass {
 	mfa_enabled: boolean; // if multi factor authentication is enabled
 
 	@Column()
-	created_at: Date = new Date(); // registration date
+	created_at: Date; // registration date
 
 	@Column()
 	verified: boolean; // if the user is offically verified
@@ -127,7 +127,7 @@ export class User extends BaseClass {
 	public_flags: string;
 
 	@JoinColumn({ name: "relationship_ids" })
-	@OneToMany(() => Relationship, (relationship: Relationship) => relationship.user, { cascade: true })
+	@OneToMany(() => Relationship, (relationship: Relationship) => relationship.from)
 	relationships: Relationship[];
 
 	@JoinColumn({ name: "connected_account_ids" })
@@ -146,6 +146,14 @@ export class User extends BaseClass {
 	@Column({ type: "simple-json" })
 	settings: UserSettings;
 
+	toPublicUser() {
+		const user: any = {};
+		PublicUserProjection.forEach((x) => {
+			user[x] = this[x];
+		});
+		return user as PublicUser;
+	}
+
 	static async getPublicUser(user_id: string, opts?: FindOneOptions<User>) {
 		const user = await User.findOne(
 			{ id: user_id },
@@ -261,7 +269,7 @@ export class UserFlags extends BitField {
 		SYSTEM: BigInt(1) << BigInt(12),
 		HAS_UNREAD_URGENT_MESSAGES: BigInt(1) << BigInt(13),
 		BUGHUNTER_LEVEL_2: BigInt(1) << BigInt(14),
-	        UNDERAGE_DELETED: BigInt(1) << BigInt(15),
+		UNDERAGE_DELETED: BigInt(1) << BigInt(15),
 		VERIFIED_BOT: BigInt(1) << BigInt(16),
 		EARLY_VERIFIED_BOT_DEVELOPER: BigInt(1) << BigInt(17),
 	};