summary refs log tree commit diff
diff options
context:
space:
mode:
authorIratu <me@iratu.pro>2022-02-16 22:00:13 +0000
committerErkin Alp Güney <erkinalp9035@gmail.com>2022-02-18 19:50:11 +0300
commit903ce169a17cc82f5a22cb5814d5a59f5812c25f (patch)
treea742fb1d37a56191bb9e8abb8041cf243fd68f69
parentForgot the openapi.json change. (diff)
downloadserver-903ce169a17cc82f5a22cb5814d5a59f5812c25f.tar.xz
changed user.premium_since to also load from the database.
-rw-r--r--api/assets/openapi.json4
-rw-r--r--api/src/routes/users/#id/profile.ts2
-rw-r--r--gateway/src/opcodes/Identify.ts2
-rw-r--r--util/src/entities/User.ts5
4 files changed, 12 insertions, 1 deletions
diff --git a/api/assets/openapi.json b/api/assets/openapi.json
index 33118b4b..1af0600d 100644
--- a/api/assets/openapi.json
+++ b/api/assets/openapi.json
@@ -2821,6 +2821,10 @@
 						"type": "string",
 						"format": "date-time"
 					},
+					"premium_since": {
+						"type": "string",
+						"format": "date-time"
+					},
 					"verified": {
 						"type": "boolean"
 					},
diff --git a/api/src/routes/users/#id/profile.ts b/api/src/routes/users/#id/profile.ts
index 06be66ae..4dbb84cf 100644
--- a/api/src/routes/users/#id/profile.ts
+++ b/api/src/routes/users/#id/profile.ts
@@ -39,7 +39,7 @@ router.get("/", route({ test: { response: { body: "UserProfileResponse" } } }),
 	res.json({
 		connected_accounts: user.connected_accounts,
 		premium_guild_since: premium_guild_since, // TODO
-		premium_since: null, // TODO
+		premium_since: user.premium_since, // TODO
 		mutual_guilds: mutual_guilds, // TODO {id: "", nick: null} when ?with_mutual_guilds=true
 		user: {
 			username: user.username,
diff --git a/gateway/src/opcodes/Identify.ts b/gateway/src/opcodes/Identify.ts
index f39ac808..904aa963 100644
--- a/gateway/src/opcodes/Identify.ts
+++ b/gateway/src/opcodes/Identify.ts
@@ -173,6 +173,7 @@ export async function onIdentify(this: WebSocket, data: Payload) {
 			avatar: related_user.avatar,
 			bot: related_user.bot,
 			bio: related_user.bio,
+			premium_since: user.premium_since
 		};
 		users.push(public_related_user);
 	}
@@ -225,6 +226,7 @@ export async function onIdentify(this: WebSocket, data: Payload) {
 		accent_color: user.accent_color || 0,
 		banner: user.banner,
 		bio: user.bio,
+		premium_since: user.premium_since
 	};
 
 	const d: ReadyEventData = {
diff --git a/util/src/entities/User.ts b/util/src/entities/User.ts
index f157ac39..1d18c838 100644
--- a/util/src/entities/User.ts
+++ b/util/src/entities/User.ts
@@ -16,6 +16,7 @@ export enum PublicUserEnum {
 	banner,
 	bio,
 	bot,
+	premium_since,
 }
 export type PublicUserKeys = keyof typeof PublicUserEnum;
 
@@ -110,6 +111,9 @@ export class User extends BaseClass {
 	@Column()
 	created_at: Date; // registration date
 
+	@Column({ nullable: true })
+	premium_since: Date; // premium date
+
 	@Column({ select: false })
 	verified: boolean; // if the user is offically verified
 
@@ -246,6 +250,7 @@ export class User extends BaseClass {
 			id: Snowflake.generate(),
 			bot: false,
 			system: false,
+			premium_since: new Date(),
 			desktop: false,
 			mobile: false,
 			premium: true,