1
0
mirror of https://github.com/spacebarchat/server.git synced 2024-11-06 10:52:31 +01:00

Merge branch 'fosscord:master' into slowcord

This commit is contained in:
Madeline 2022-02-19 11:48:21 +11:00 committed by GitHub
commit c821916ffe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 27 additions and 7 deletions

View File

@ -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"

View File

@ -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,

View File

@ -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 = {

View File

@ -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,

View File

@ -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,