mirror of
https://github.com/spacebarchat/server.git
synced 2024-11-05 10:22:31 +01:00
Fix docs for /users/:id/profile
This commit is contained in:
parent
6e47b8e0b3
commit
6c603afc54
@ -4237,6 +4237,32 @@
|
||||
"type"
|
||||
]
|
||||
},
|
||||
"UserProfile": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"accent_color": {
|
||||
"type": "integer"
|
||||
},
|
||||
"banner": {
|
||||
"type": "string"
|
||||
},
|
||||
"bio": {
|
||||
"type": "string"
|
||||
},
|
||||
"theme_colors": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "integer"
|
||||
}
|
||||
},
|
||||
"pronouns": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"bio"
|
||||
]
|
||||
},
|
||||
"TokenResponse": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@ -7638,11 +7664,116 @@
|
||||
"premium_since": {
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
},
|
||||
"mutual_guilds": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "string"
|
||||
},
|
||||
"nick": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"additionalProperties": false,
|
||||
"required": [
|
||||
"id"
|
||||
]
|
||||
}
|
||||
},
|
||||
"premium_type": {
|
||||
"type": "integer"
|
||||
},
|
||||
"profile_themes_experiment_bucket": {
|
||||
"type": "integer"
|
||||
},
|
||||
"user_profile": {
|
||||
"$ref": "#/components/schemas/UserProfile"
|
||||
},
|
||||
"guild_member": {
|
||||
"additionalProperties": false,
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "string"
|
||||
},
|
||||
"guild_id": {
|
||||
"type": "string"
|
||||
},
|
||||
"nick": {
|
||||
"type": "string"
|
||||
},
|
||||
"joined_at": {
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
},
|
||||
"pending": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"deaf": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"mute": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"premium_since": {
|
||||
"type": "integer"
|
||||
},
|
||||
"user": {
|
||||
"$ref": "#/components/schemas/PublicUser"
|
||||
},
|
||||
"roles": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"deaf",
|
||||
"guild_id",
|
||||
"id",
|
||||
"joined_at",
|
||||
"mute",
|
||||
"pending",
|
||||
"roles",
|
||||
"user"
|
||||
]
|
||||
},
|
||||
"guild_member_profile": {
|
||||
"additionalProperties": false,
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"guild_id": {
|
||||
"type": "string"
|
||||
},
|
||||
"banner": {
|
||||
"type": "string"
|
||||
},
|
||||
"bio": {
|
||||
"type": "string"
|
||||
},
|
||||
"accent_color": {
|
||||
"type": "null"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"accent_color",
|
||||
"banner",
|
||||
"bio",
|
||||
"guild_id"
|
||||
]
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"connected_accounts",
|
||||
"user"
|
||||
"mutual_guilds",
|
||||
"premium_type",
|
||||
"profile_themes_experiment_bucket",
|
||||
"user",
|
||||
"user_profile"
|
||||
]
|
||||
},
|
||||
"UserRelationshipsResponse": {
|
||||
|
3563
assets/schemas.json
3563
assets/schemas.json
File diff suppressed because it is too large
Load Diff
@ -84,18 +84,6 @@ router.get(
|
||||
|
||||
// TODO: make proper DTO's in util?
|
||||
|
||||
const userDto = {
|
||||
username: user.username,
|
||||
discriminator: user.discriminator,
|
||||
id: user.id,
|
||||
public_flags: user.public_flags,
|
||||
avatar: user.avatar,
|
||||
accent_color: user.accent_color,
|
||||
banner: user.banner,
|
||||
bio: req.user_bot ? null : user.bio,
|
||||
bot: user.bot,
|
||||
};
|
||||
|
||||
const userProfile = {
|
||||
bio: req.user_bot ? null : user.bio,
|
||||
accent_color: user.accent_color,
|
||||
@ -104,28 +92,6 @@ router.get(
|
||||
theme_colors: user.theme_colors,
|
||||
};
|
||||
|
||||
const guildMemberDto = guild_member
|
||||
? {
|
||||
avatar: guild_member.avatar,
|
||||
banner: guild_member.banner,
|
||||
bio: req.user_bot ? null : guild_member.bio,
|
||||
communication_disabled_until:
|
||||
guild_member.communication_disabled_until,
|
||||
deaf: guild_member.deaf,
|
||||
flags: user.flags,
|
||||
is_pending: guild_member.pending,
|
||||
pending: guild_member.pending, // why is this here twice, discord?
|
||||
joined_at: guild_member.joined_at,
|
||||
mute: guild_member.mute,
|
||||
nick: guild_member.nick,
|
||||
premium_since: guild_member.premium_since,
|
||||
roles: guild_member.roles
|
||||
.map((x) => x.id)
|
||||
.filter((id) => id != guild_id),
|
||||
user: userDto,
|
||||
}
|
||||
: undefined;
|
||||
|
||||
const guildMemberProfile = {
|
||||
accent_color: null,
|
||||
banner: guild_member?.banner || null,
|
||||
@ -139,11 +105,11 @@ router.get(
|
||||
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: userDto,
|
||||
user: user.toPublicUser(),
|
||||
premium_type: user.premium_type,
|
||||
profile_themes_experiment_bucket: 4, // TODO: This doesn't make it available, for some reason?
|
||||
user_profile: userProfile,
|
||||
guild_member: guild_id && guildMemberDto,
|
||||
guild_member: guild_member?.toPublicMember(),
|
||||
guild_member_profile: guild_id && guildMemberProfile,
|
||||
});
|
||||
},
|
||||
|
@ -344,11 +344,7 @@ export class Member extends BaseClassWithoutId {
|
||||
relations: ["user", "roles"],
|
||||
take: 10,
|
||||
})
|
||||
).map((member) => ({
|
||||
...member.toPublicMember(),
|
||||
user: member.user.toPublicUser(),
|
||||
roles: member.roles.map((x) => x.id),
|
||||
}));
|
||||
).map((member) => member.toPublicMember());
|
||||
|
||||
if (
|
||||
await Member.count({
|
||||
@ -455,6 +451,10 @@ export class Member extends BaseClassWithoutId {
|
||||
PublicMemberProjection.forEach((x) => {
|
||||
member[x] = this[x];
|
||||
});
|
||||
|
||||
if (member.roles) member.roles = member.roles.map((x: Role) => x.id);
|
||||
if (member.user) member.user = member.user.toPublicUser();
|
||||
|
||||
return member as PublicMember;
|
||||
}
|
||||
}
|
||||
|
@ -1,26 +0,0 @@
|
||||
/*
|
||||
Spacebar: A FOSS re-implementation and extension of the Discord.com backend.
|
||||
Copyright (C) 2023 Spacebar and Spacebar Contributors
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published
|
||||
by the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { PublicConnectedAccount, PublicUser } from "..";
|
||||
|
||||
export interface UserProfileResponse {
|
||||
user: PublicUser;
|
||||
connected_accounts: PublicConnectedAccount;
|
||||
premium_guild_since?: Date;
|
||||
premium_since?: Date;
|
||||
}
|
@ -1,8 +1,37 @@
|
||||
import { PublicConnectedAccount, PublicUser } from "../../entities";
|
||||
import {
|
||||
Member,
|
||||
PublicConnectedAccount,
|
||||
PublicMember,
|
||||
PublicUser,
|
||||
User,
|
||||
} from "@spacebar/util";
|
||||
|
||||
export type MutualGuild = {
|
||||
id: string;
|
||||
nick?: string;
|
||||
};
|
||||
|
||||
export type PublicMemberProfile = Pick<
|
||||
Member,
|
||||
"banner" | "bio" | "guild_id"
|
||||
> & {
|
||||
accent_color: null; // TODO
|
||||
};
|
||||
|
||||
export type UserProfile = Pick<
|
||||
User,
|
||||
"bio" | "accent_color" | "banner" | "pronouns" | "theme_colors"
|
||||
>;
|
||||
|
||||
export interface UserProfileResponse {
|
||||
user: PublicUser;
|
||||
connected_accounts: PublicConnectedAccount;
|
||||
premium_guild_since?: Date;
|
||||
premium_since?: Date;
|
||||
mutual_guilds: MutualGuild[];
|
||||
premium_type: number;
|
||||
profile_themes_experiment_bucket: number;
|
||||
user_profile: UserProfile;
|
||||
guild_member?: PublicMember;
|
||||
guild_member_profile?: PublicMemberProfile;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user