diff --git a/api/assets/openapi.json b/api/assets/openapi.json index 15e55bf9..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" }, @@ -3800,7 +3804,8 @@ "format": "date-time" }, "premium_since": { - "type": "integer" + "type": "string", + "format": "date-time" }, "deaf": { "type": "boolean" diff --git a/api/src/routes/users/#id/profile.ts b/api/src/routes/users/#id/profile.ts index 9481451d..4dbb84cf 100644 --- a/api/src/routes/users/#id/profile.ts +++ b/api/src/routes/users/#id/profile.ts @@ -16,22 +16,30 @@ router.get("/", route({ test: { response: { body: "UserProfileResponse" } } }), const user = await User.getPublicUser(req.params.id, { relations: ["connected_accounts"] }); var mutual_guilds: object[] = []; - + var premium_guild_since; const requested_member = await Member.find( { id: req.params.id, }) const self_member = await Member.find( { id: req.user_id, }) for(const rmem of requested_member) { + if(rmem.premium_since) { + if(premium_guild_since){ + if(premium_guild_since > rmem.premium_since) { + premium_guild_since = rmem.premium_since; + } + } else { + premium_guild_since = rmem.premium_since; + } + } for(const smem of self_member) { if (smem.guild_id === rmem.guild_id) { mutual_guilds.push({id: rmem.guild_id, nick: rmem.nick}) } } } - res.json({ connected_accounts: user.connected_accounts, - premium_guild_since: null, // TODO - premium_since: null, // TODO + premium_guild_since: premium_guild_since, // 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/Member.ts b/util/src/entities/Member.ts index 0f7be2a7..3c5f9db0 100644 --- a/util/src/entities/Member.ts +++ b/util/src/entities/Member.ts @@ -86,7 +86,7 @@ export class Member extends BaseClassWithoutId { joined_at: Date; @Column({ nullable: true }) - premium_since?: number; + premium_since?: Date; @Column() deaf: boolean; @@ -245,7 +245,7 @@ export class Member extends BaseClassWithoutId { nick: undefined, roles: [guild_id], // @everyone role joined_at: new Date(), - premium_since: undefined, + premium_since: new Date(), deaf: false, mute: false, pending: false, 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,