summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--assets/openapi.json89
-rw-r--r--assets/schemas.json89
-rw-r--r--src/api/routes/users/@me/index.ts26
-rw-r--r--src/schemas/api/users/User.ts10
-rw-r--r--src/schemas/uncategorised/UserModifySchema.ts6
5 files changed, 216 insertions, 4 deletions
diff --git a/assets/openapi.json b/assets/openapi.json

index ef7607f3..d361c5d1 100644 --- a/assets/openapi.json +++ b/assets/openapi.json
@@ -2756,6 +2756,18 @@ "items": { "type": "string" } + }, + "avatar_decoration_data": { + "$ref": "#/components/schemas/AvatarDecorationData" + }, + "display_name_styles": { + "$ref": "#/components/schemas/DisplayNameStyle" + }, + "collectibles": { + "$ref": "#/components/schemas/Collectibles" + }, + "primary_guild": { + "$ref": "#/components/schemas/PrimaryGuild" } }, "required": [ @@ -2831,6 +2843,18 @@ "type": "string" } }, + "avatar_decoration_data": { + "$ref": "#/components/schemas/AvatarDecorationData" + }, + "display_name_styles": { + "$ref": "#/components/schemas/DisplayNameStyle" + }, + "collectibles": { + "$ref": "#/components/schemas/Collectibles" + }, + "primary_guild": { + "$ref": "#/components/schemas/PrimaryGuild" + }, "mfa_enabled": { "type": "boolean" }, @@ -2958,6 +2982,18 @@ "type": "string" } }, + "avatar_decoration_data": { + "$ref": "#/components/schemas/AvatarDecorationData" + }, + "display_name_styles": { + "$ref": "#/components/schemas/DisplayNameStyle" + }, + "collectibles": { + "$ref": "#/components/schemas/Collectibles" + }, + "primary_guild": { + "$ref": "#/components/schemas/PrimaryGuild" + }, "mfa_enabled": { "type": "boolean" }, @@ -6076,6 +6112,42 @@ "minLength": 4, "maxLength": 4, "type": "string" + }, + "display_name_colors": { + "type": "array", + "items": { + "type": "integer" + } + }, + "display_name_effect_id": { + "enum": [ + 0, + 1, + 2, + 3, + 4, + 5, + 6 + ], + "type": "number" + }, + "display_name_font_id": { + "enum": [ + 0, + 1, + 10, + 11, + 12, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9 + ], + "type": "number" } } }, @@ -8538,7 +8610,10 @@ "type": "integer" }, "colors": { - "type": "integer" + "type": "array", + "items": { + "type": "integer" + } } }, "required": [ @@ -10997,6 +11072,18 @@ "items": { "type": "string" } + }, + "avatar_decoration_data": { + "$ref": "#/components/schemas/AvatarDecorationData" + }, + "display_name_styles": { + "$ref": "#/components/schemas/DisplayNameStyle" + }, + "collectibles": { + "$ref": "#/components/schemas/Collectibles" + }, + "primary_guild": { + "$ref": "#/components/schemas/PrimaryGuild" } }, "required": [ diff --git a/assets/schemas.json b/assets/schemas.json
index 5c51dbca..b905dc18 100644 --- a/assets/schemas.json +++ b/assets/schemas.json
@@ -2892,6 +2892,18 @@ "items": { "type": "string" } + }, + "avatar_decoration_data": { + "$ref": "#/definitions/AvatarDecorationData" + }, + "display_name_styles": { + "$ref": "#/definitions/DisplayNameStyle" + }, + "collectibles": { + "$ref": "#/definitions/Collectibles" + }, + "primary_guild": { + "$ref": "#/definitions/PrimaryGuild" } }, "additionalProperties": false, @@ -2969,6 +2981,18 @@ "type": "string" } }, + "avatar_decoration_data": { + "$ref": "#/definitions/AvatarDecorationData" + }, + "display_name_styles": { + "$ref": "#/definitions/DisplayNameStyle" + }, + "collectibles": { + "$ref": "#/definitions/Collectibles" + }, + "primary_guild": { + "$ref": "#/definitions/PrimaryGuild" + }, "mfa_enabled": { "type": "boolean" }, @@ -3101,6 +3125,18 @@ "type": "string" } }, + "avatar_decoration_data": { + "$ref": "#/definitions/AvatarDecorationData" + }, + "display_name_styles": { + "$ref": "#/definitions/DisplayNameStyle" + }, + "collectibles": { + "$ref": "#/definitions/Collectibles" + }, + "primary_guild": { + "$ref": "#/definitions/PrimaryGuild" + }, "mfa_enabled": { "type": "boolean" }, @@ -6472,6 +6508,42 @@ "minLength": 4, "maxLength": 4, "type": "string" + }, + "display_name_colors": { + "type": "array", + "items": { + "type": "integer" + } + }, + "display_name_effect_id": { + "enum": [ + 0, + 1, + 2, + 3, + 4, + 5, + 6 + ], + "type": "number" + }, + "display_name_font_id": { + "enum": [ + 0, + 1, + 10, + 11, + 12, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9 + ], + "type": "number" } }, "additionalProperties": false, @@ -9049,7 +9121,10 @@ "type": "integer" }, "colors": { - "type": "integer" + "type": "array", + "items": { + "type": "integer" + } } }, "additionalProperties": false, @@ -11639,6 +11714,18 @@ "items": { "type": "string" } + }, + "avatar_decoration_data": { + "$ref": "#/definitions/AvatarDecorationData" + }, + "display_name_styles": { + "$ref": "#/definitions/DisplayNameStyle" + }, + "collectibles": { + "$ref": "#/definitions/Collectibles" + }, + "primary_guild": { + "$ref": "#/definitions/PrimaryGuild" } }, "additionalProperties": false, diff --git a/src/api/routes/users/@me/index.ts b/src/api/routes/users/@me/index.ts
index 187862f1..469dddef 100644 --- a/src/api/routes/users/@me/index.ts +++ b/src/api/routes/users/@me/index.ts
@@ -20,7 +20,7 @@ import { route } from "@spacebar/api"; import { Config, emitEvent, FieldErrors, generateToken, handleFile, User, UserUpdateEvent } from "@spacebar/util"; import bcrypt from "bcrypt"; import { Request, Response, Router } from "express"; -import { PrivateUserProjection, UserModifySchema } from "@spacebar/schemas"; +import { DisplayNameStyle, PrivateUserProjection, UserModifySchema } from "@spacebar/schemas"; const router: Router = Router({ mergeParams: true }); @@ -191,6 +191,30 @@ router.patch( } } + if ("display_name_font_id" in body) { + if (!body.display_name_font_id) user.display_name_styles = undefined; + else { + user.display_name_styles ??= {} as unknown as DisplayNameStyle; + user.display_name_styles!.font_id = body.display_name_font_id; + } + } + + if ("display_name_effect_id" in body) { + if (!body.display_name_effect_id) user.display_name_styles = undefined; + else { + user.display_name_styles ??= {} as unknown as DisplayNameStyle; + user.display_name_styles!.effect_id = body.display_name_effect_id; + } + } + + if ("display_name_colors" in body) { + if (!body.display_name_colors) user.display_name_styles = undefined; + else { + user.display_name_styles ??= {} as unknown as DisplayNameStyle; + user.display_name_styles!.colors = body.display_name_colors; + } + } + user.assign(body); user.validate(); await user.save(); diff --git a/src/schemas/api/users/User.ts b/src/schemas/api/users/User.ts
index 41d60673..29b211d4 100644 --- a/src/schemas/api/users/User.ts +++ b/src/schemas/api/users/User.ts
@@ -57,6 +57,10 @@ interface UserEntityPleaseRewriteThankYou { fingerprints: string[]; settings?: UserSettingsSchema; badge_ids?: string[]; + avatar_decoration_data?: AvatarDecorationData; + display_name_styles?: DisplayNameStyle; + collectibles?: Collectibles; + primary_guild?: PrimaryGuild; } export interface PartialUser { @@ -97,7 +101,7 @@ export interface NameplateData { export interface DisplayNameStyle { font_id: number; effect_id: number; - colors: number; + colors: number[]; } export interface PrimaryGuild { @@ -122,6 +126,10 @@ export enum PublicUserEnum { theme_colors, pronouns, badge_ids, + avatar_decoration_data, + display_name_styles, + collectibles, + primary_guild, } export type PublicUserKeys = keyof typeof PublicUserEnum; diff --git a/src/schemas/uncategorised/UserModifySchema.ts b/src/schemas/uncategorised/UserModifySchema.ts
index c7228e7b..45c1ae90 100644 --- a/src/schemas/uncategorised/UserModifySchema.ts +++ b/src/schemas/uncategorised/UserModifySchema.ts
@@ -16,6 +16,8 @@ along with this program. If not, see <https://www.gnu.org/licenses/>. */ +import { User_DisplayNameEffect, User_DisplayNameFont } from "discord-protos"; + export interface UserModifySchema { /** * @minLength 2 @@ -49,4 +51,8 @@ export interface UserModifySchema { * @maxLength 4 */ discriminator?: string; + + display_name_colors?: number[]; + display_name_effect_id?: User_DisplayNameEffect; + display_name_font_id?: User_DisplayNameFont; }