diff options
author | Flam3rboy <34555296+Flam3rboy@users.noreply.github.com> | 2021-08-18 11:53:03 +0200 |
---|---|---|
committer | Flam3rboy <34555296+Flam3rboy@users.noreply.github.com> | 2021-08-18 11:53:03 +0200 |
commit | 9d0dcae5621d999100c8d850e373cf96f018b32b (patch) | |
tree | e667f0fc3c35865b5c8a402a3c0cff9078818451 /api | |
parent | fix #199 (diff) | |
download | server-9d0dcae5621d999100c8d850e373cf96f018b32b.tar.xz |
:ambulance: user settings route
Diffstat (limited to 'api')
-rw-r--r-- | api/src/routes/users/@me/settings.ts | 10 | ||||
-rw-r--r-- | api/src/schema/User.ts | 51 |
2 files changed, 59 insertions, 2 deletions
diff --git a/api/src/routes/users/@me/settings.ts b/api/src/routes/users/@me/settings.ts index cca9b3ab..5664fc2f 100644 --- a/api/src/routes/users/@me/settings.ts +++ b/api/src/routes/users/@me/settings.ts @@ -1,9 +1,15 @@ import { Router, Response, Request } from "express"; +import { UserModel, UserSettings } from "@fosscord/util"; +import { check } from "../../../util/instanceOf"; +import { UserSettingsSchema } from "../../../schema/User"; const router = Router(); -router.patch("/", (req: Request, res: Response) => { - // TODO: +router.patch("/", check(UserSettingsSchema), async (req: Request, res: Response) => { + const body = req.body as UserSettings; + + await UserModel.updateOne({ id: req.user_id }, body).exec(); + res.sendStatus(204); }); diff --git a/api/src/schema/User.ts b/api/src/schema/User.ts index c7478f8d..0d094b9e 100644 --- a/api/src/schema/User.ts +++ b/api/src/schema/User.ts @@ -1,3 +1,4 @@ +import { UserSettings } from "../../../util/dist"; import { Length } from "../util/instanceOf"; export const UserModifySchema = { @@ -21,3 +22,53 @@ export interface UserModifySchema { new_password?: string; code?: string; } + +export const UserSettingsSchema = { + $afk_timeout: Number, + $allow_accessibility_detection: Boolean, + $animate_emoji: Boolean, + $animate_stickers: Number, + $contact_sync_enabled: Boolean, + $convert_emoticons: Boolean, + $custom_status: { + $emoji_id: String, + $emoji_name: String, + $expires_at: Number, + $text: String + }, + $default_guilds_restricted: Boolean, + $detect_platform_accounts: Boolean, + $developer_mode: Boolean, + $disable_games_tab: Boolean, + $enable_tts_command: Boolean, + $explicit_content_filter: Number, + $friend_source_flags: { + all: Boolean + }, + $gateway_connected: Boolean, + $gif_auto_play: Boolean, + $guild_folders: [ + { + color: Number, + guild_ids: [String], + id: Number, + name: String + } + ], + $guild_positions: [String], + $inline_attachment_media: Boolean, + $inline_embed_media: Boolean, + $locale: String, + $message_display_compact: Boolean, + $native_phone_integration_enabled: Boolean, + $render_embeds: Boolean, + $render_reactions: Boolean, + $restricted_guilds: [String], + $show_current_game: Boolean, + $status: String, + $stream_notifications_enabled: Boolean, + $theme: String, + $timezone_offset: Number +}; + +export interface UserSettingsSchema extends UserSettings {} |