diff options
Diffstat (limited to '')
-rw-r--r-- | src/routes/auth/register.ts | 1 | ||||
-rw-r--r-- | src/routes/guilds/#guild_id/index.ts | 4 | ||||
-rw-r--r-- | src/routes/users/#id/profile.ts | 1 | ||||
-rw-r--r-- | src/routes/users/@me/index.ts | 5 | ||||
-rw-r--r-- | src/routes/users/@me/profile.ts | 1 | ||||
-rw-r--r-- | src/schema/User.ts | 4 |
6 files changed, 11 insertions, 5 deletions
diff --git a/src/routes/auth/register.ts b/src/routes/auth/register.ts index 279103bc..f9005655 100644 --- a/src/routes/auth/register.ts +++ b/src/routes/auth/register.ts @@ -197,6 +197,7 @@ router.post( discriminator, avatar: null, accent_color: null, + banner: null, bot: false, system: false, desktop: false, diff --git a/src/routes/guilds/#guild_id/index.ts b/src/routes/guilds/#guild_id/index.ts index 8e052f6d..404a289a 100644 --- a/src/routes/guilds/#guild_id/index.ts +++ b/src/routes/guilds/#guild_id/index.ts @@ -43,8 +43,8 @@ router.patch("/", check(GuildUpdateSchema), async (req: Request, res: Response) const perms = await getPermission(req.user_id, guild_id); perms.hasThrow("MANAGE_GUILD"); - body.icon = await handleFile(`/icons/${guild_id}`, body.icon); - body.banner = await handleFile(`/banners/${guild_id}`, body.banner); + if (body.icon) body.icon = await handleFile(`/icons/${guild_id}`, body.icon); + if(body.banner) body.banner = await handleFile(`/banners/${guild_id}`, body.banner); const guild = await GuildModel.findOneAndUpdate({ id: guild_id }, body) .populate({ path: "joined_at", match: { id: req.user_id } }) diff --git a/src/routes/users/#id/profile.ts b/src/routes/users/#id/profile.ts index b86b0b90..4b4b9439 100644 --- a/src/routes/users/#id/profile.ts +++ b/src/routes/users/#id/profile.ts @@ -17,6 +17,7 @@ router.get("/", async (req: Request, res: Response) => { 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, } diff --git a/src/routes/users/@me/index.ts b/src/routes/users/@me/index.ts index 185e44d4..f6b29958 100644 --- a/src/routes/users/@me/index.ts +++ b/src/routes/users/@me/index.ts @@ -1,6 +1,5 @@ import { Router, Request, Response } from "express"; import { UserModel, toObject, PublicUserProjection } from "@fosscord/server-util"; -import { HTTPError } from "lambert-server"; import { getPublicUser } from "../../../util/User"; import { UserModifySchema } from "../../../schema/User"; import { check } from "../../../util/instanceOf"; @@ -14,7 +13,9 @@ router.get("/", async (req: Request, res: Response) => { router.patch("/", check(UserModifySchema), async (req: Request, res: Response) => { const body = req.body as UserModifySchema; - body.avatar = await handleFile(`/avatars/${req.user_id}`, body.avatar as string); + + if(body.avatar) body.avatar = await handleFile(`/avatars/${req.user_id}`, body.avatar as string); + if (body.banner) body.banner = await handleFile(`/banners/${req.user_id}`, body.banner as string); const user = await UserModel.findOneAndUpdate({ id: req.user_id }, body, { projection: PublicUserProjection }).exec(); // TODO: dispatch user update event diff --git a/src/routes/users/@me/profile.ts b/src/routes/users/@me/profile.ts index 0d295d05..b67d1964 100644 --- a/src/routes/users/@me/profile.ts +++ b/src/routes/users/@me/profile.ts @@ -17,6 +17,7 @@ router.get("/", async (req: Request, res: Response) => { public_flags: user.public_flags, avatar: user.avatar, accent_color: user.accent_color, + banner: user.banner, bio: user.bio, bot: user.bot, } diff --git a/src/schema/User.ts b/src/schema/User.ts index ae213ee3..77ee08b4 100644 --- a/src/schema/User.ts +++ b/src/schema/User.ts @@ -4,7 +4,8 @@ export const UserModifySchema = { $username: new Length(String, 2, 32), $avatar: String, $bio: new Length(String, 0, 190), - $accent_color: Number + $accent_color: Number, + $banner: String }; export interface UserModifySchema { @@ -12,4 +13,5 @@ export interface UserModifySchema { avatar?: string | null; bio?: string; accent_color?: number | null; + banner?: string | null; } |