mirror of
https://github.com/spacebarchat/server.git
synced 2026-03-30 16:05:41 +00:00
Update schemas for profile customisation
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -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();
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user