diff options
author | Madeline <46743919+MaddyUnderStars@users.noreply.github.com> | 2022-10-28 19:23:02 +1100 |
---|---|---|
committer | Madeline <46743919+MaddyUnderStars@users.noreply.github.com> | 2022-10-28 19:23:02 +1100 |
commit | 4c58a8bc249856a3e3b0af02ac086226a9308ddc (patch) | |
tree | 65ababbcb6915bf2e686d003383ce5ea573289df | |
parent | lol (diff) | |
download | server-4c58a8bc249856a3e3b0af02ac086226a9308ddc.tar.xz |
Fix user settings not saving properly and guild folders
-rw-r--r-- | assets/schemas.json | 1315 | ||||
-rw-r--r-- | fosscord-server.code-workspace | 3 | ||||
-rw-r--r-- | src/api/routes/users/@me/settings.ts | 9 | ||||
-rw-r--r-- | src/util/entities/User.ts | 6 | ||||
-rw-r--r-- | src/util/schemas/UserGuildSettingsSchema.ts | 2 | ||||
-rw-r--r-- | src/util/schemas/index.ts | 3 |
6 files changed, 1117 insertions, 221 deletions
diff --git a/assets/schemas.json b/assets/schemas.json index 464eeb66..316d512b 100644 --- a/assets/schemas.json +++ b/assets/schemas.json @@ -817,6 +817,27 @@ "end_time", "selected_time_window" ] + }, + "Partial<{color:number;guild_ids:string[];id:number;name:string;}>": { + "type": "object", + "properties": { + "color": { + "type": "integer" + }, + "guild_ids": { + "type": "array", + "items": { + "type": "string" + } + }, + "id": { + "type": "integer" + }, + "name": { + "type": "string" + } + }, + "additionalProperties": false } }, "$schema": "http://json-schema.org/draft-07/schema#" @@ -1347,6 +1368,27 @@ "end_time", "selected_time_window" ] + }, + "Partial<{color:number;guild_ids:string[];id:number;name:string;}>": { + "type": "object", + "properties": { + "color": { + "type": "integer" + }, + "guild_ids": { + "type": "array", + "items": { + "type": "string" + } + }, + "id": { + "type": "integer" + }, + "name": { + "type": "string" + } + }, + "additionalProperties": false } }, "$schema": "http://json-schema.org/draft-07/schema#" @@ -1860,6 +1902,27 @@ "end_time", "selected_time_window" ] + }, + "Partial<{color:number;guild_ids:string[];id:number;name:string;}>": { + "type": "object", + "properties": { + "color": { + "type": "integer" + }, + "guild_ids": { + "type": "array", + "items": { + "type": "string" + } + }, + "id": { + "type": "integer" + }, + "name": { + "type": "string" + } + }, + "additionalProperties": false } }, "$schema": "http://json-schema.org/draft-07/schema#" @@ -2374,6 +2437,27 @@ "end_time", "selected_time_window" ] + }, + "Partial<{color:number;guild_ids:string[];id:number;name:string;}>": { + "type": "object", + "properties": { + "color": { + "type": "integer" + }, + "guild_ids": { + "type": "array", + "items": { + "type": "string" + } + }, + "id": { + "type": "integer" + }, + "name": { + "type": "string" + } + }, + "additionalProperties": false } }, "$schema": "http://json-schema.org/draft-07/schema#" @@ -2968,6 +3052,27 @@ "end_time", "selected_time_window" ] + }, + "Partial<{color:number;guild_ids:string[];id:number;name:string;}>": { + "type": "object", + "properties": { + "color": { + "type": "integer" + }, + "guild_ids": { + "type": "array", + "items": { + "type": "string" + } + }, + "id": { + "type": "integer" + }, + "name": { + "type": "string" + } + }, + "additionalProperties": false } }, "$schema": "http://json-schema.org/draft-07/schema#" @@ -3477,6 +3582,27 @@ "end_time", "selected_time_window" ] + }, + "Partial<{color:number;guild_ids:string[];id:number;name:string;}>": { + "type": "object", + "properties": { + "color": { + "type": "integer" + }, + "guild_ids": { + "type": "array", + "items": { + "type": "string" + } + }, + "id": { + "type": "integer" + }, + "name": { + "type": "string" + } + }, + "additionalProperties": false } }, "$schema": "http://json-schema.org/draft-07/schema#" @@ -4008,6 +4134,27 @@ "end_time", "selected_time_window" ] + }, + "Partial<{color:number;guild_ids:string[];id:number;name:string;}>": { + "type": "object", + "properties": { + "color": { + "type": "integer" + }, + "guild_ids": { + "type": "array", + "items": { + "type": "string" + } + }, + "id": { + "type": "integer" + }, + "name": { + "type": "string" + } + }, + "additionalProperties": false } }, "$schema": "http://json-schema.org/draft-07/schema#" @@ -4517,6 +4664,27 @@ "end_time", "selected_time_window" ] + }, + "Partial<{color:number;guild_ids:string[];id:number;name:string;}>": { + "type": "object", + "properties": { + "color": { + "type": "integer" + }, + "guild_ids": { + "type": "array", + "items": { + "type": "string" + } + }, + "id": { + "type": "integer" + }, + "name": { + "type": "string" + } + }, + "additionalProperties": false } }, "$schema": "http://json-schema.org/draft-07/schema#" @@ -5041,6 +5209,27 @@ "end_time", "selected_time_window" ] + }, + "Partial<{color:number;guild_ids:string[];id:number;name:string;}>": { + "type": "object", + "properties": { + "color": { + "type": "integer" + }, + "guild_ids": { + "type": "array", + "items": { + "type": "string" + } + }, + "id": { + "type": "integer" + }, + "name": { + "type": "string" + } + }, + "additionalProperties": false } }, "$schema": "http://json-schema.org/draft-07/schema#" @@ -5568,6 +5757,27 @@ "end_time", "selected_time_window" ] + }, + "Partial<{color:number;guild_ids:string[];id:number;name:string;}>": { + "type": "object", + "properties": { + "color": { + "type": "integer" + }, + "guild_ids": { + "type": "array", + "items": { + "type": "string" + } + }, + "id": { + "type": "integer" + }, + "name": { + "type": "string" + } + }, + "additionalProperties": false } }, "$schema": "http://json-schema.org/draft-07/schema#" @@ -6092,6 +6302,27 @@ "end_time", "selected_time_window" ] + }, + "Partial<{color:number;guild_ids:string[];id:number;name:string;}>": { + "type": "object", + "properties": { + "color": { + "type": "integer" + }, + "guild_ids": { + "type": "array", + "items": { + "type": "string" + } + }, + "id": { + "type": "integer" + }, + "name": { + "type": "string" + } + }, + "additionalProperties": false } }, "$schema": "http://json-schema.org/draft-07/schema#" @@ -6604,6 +6835,27 @@ "end_time", "selected_time_window" ] + }, + "Partial<{color:number;guild_ids:string[];id:number;name:string;}>": { + "type": "object", + "properties": { + "color": { + "type": "integer" + }, + "guild_ids": { + "type": "array", + "items": { + "type": "string" + } + }, + "id": { + "type": "integer" + }, + "name": { + "type": "string" + } + }, + "additionalProperties": false } }, "$schema": "http://json-schema.org/draft-07/schema#" @@ -7124,6 +7376,27 @@ "end_time", "selected_time_window" ] + }, + "Partial<{color:number;guild_ids:string[];id:number;name:string;}>": { + "type": "object", + "properties": { + "color": { + "type": "integer" + }, + "guild_ids": { + "type": "array", + "items": { + "type": "string" + } + }, + "id": { + "type": "integer" + }, + "name": { + "type": "string" + } + }, + "additionalProperties": false } }, "$schema": "http://json-schema.org/draft-07/schema#" @@ -7636,6 +7909,27 @@ "end_time", "selected_time_window" ] + }, + "Partial<{color:number;guild_ids:string[];id:number;name:string;}>": { + "type": "object", + "properties": { + "color": { + "type": "integer" + }, + "guild_ids": { + "type": "array", + "items": { + "type": "string" + } + }, + "id": { + "type": "integer" + }, + "name": { + "type": "string" + } + }, + "additionalProperties": false } }, "$schema": "http://json-schema.org/draft-07/schema#" @@ -8148,6 +8442,27 @@ "end_time", "selected_time_window" ] + }, + "Partial<{color:number;guild_ids:string[];id:number;name:string;}>": { + "type": "object", + "properties": { + "color": { + "type": "integer" + }, + "guild_ids": { + "type": "array", + "items": { + "type": "string" + } + }, + "id": { + "type": "integer" + }, + "name": { + "type": "string" + } + }, + "additionalProperties": false } }, "$schema": "http://json-schema.org/draft-07/schema#" @@ -8656,6 +8971,27 @@ "end_time", "selected_time_window" ] + }, + "Partial<{color:number;guild_ids:string[];id:number;name:string;}>": { + "type": "object", + "properties": { + "color": { + "type": "integer" + }, + "guild_ids": { + "type": "array", + "items": { + "type": "string" + } + }, + "id": { + "type": "integer" + }, + "name": { + "type": "string" + } + }, + "additionalProperties": false } }, "$schema": "http://json-schema.org/draft-07/schema#" @@ -9190,6 +9526,27 @@ "end_time", "selected_time_window" ] + }, + "Partial<{color:number;guild_ids:string[];id:number;name:string;}>": { + "type": "object", + "properties": { + "color": { + "type": "integer" + }, + "guild_ids": { + "type": "array", + "items": { + "type": "string" + } + }, + "id": { + "type": "integer" + }, + "name": { + "type": "string" + } + }, + "additionalProperties": false } }, "$schema": "http://json-schema.org/draft-07/schema#" @@ -9703,6 +10060,27 @@ "end_time", "selected_time_window" ] + }, + "Partial<{color:number;guild_ids:string[];id:number;name:string;}>": { + "type": "object", + "properties": { + "color": { + "type": "integer" + }, + "guild_ids": { + "type": "array", + "items": { + "type": "string" + } + }, + "id": { + "type": "integer" + }, + "name": { + "type": "string" + } + }, + "additionalProperties": false } }, "$schema": "http://json-schema.org/draft-07/schema#" @@ -10215,6 +10593,27 @@ "end_time", "selected_time_window" ] + }, + "Partial<{color:number;guild_ids:string[];id:number;name:string;}>": { + "type": "object", + "properties": { + "color": { + "type": "integer" + }, + "guild_ids": { + "type": "array", + "items": { + "type": "string" + } + }, + "id": { + "type": "integer" + }, + "name": { + "type": "string" + } + }, + "additionalProperties": false } }, "$schema": "http://json-schema.org/draft-07/schema#" @@ -10742,6 +11141,27 @@ "end_time", "selected_time_window" ] + }, + "Partial<{color:number;guild_ids:string[];id:number;name:string;}>": { + "type": "object", + "properties": { + "color": { + "type": "integer" + }, + "guild_ids": { + "type": "array", + "items": { + "type": "string" + } + }, + "id": { + "type": "integer" + }, + "name": { + "type": "string" + } + }, + "additionalProperties": false } }, "$schema": "http://json-schema.org/draft-07/schema#" @@ -11257,6 +11677,27 @@ "end_time", "selected_time_window" ] + }, + "Partial<{color:number;guild_ids:string[];id:number;name:string;}>": { + "type": "object", + "properties": { + "color": { + "type": "integer" + }, + "guild_ids": { + "type": "array", + "items": { + "type": "string" + } + }, + "id": { + "type": "integer" + }, + "name": { + "type": "string" + } + }, + "additionalProperties": false } }, "$schema": "http://json-schema.org/draft-07/schema#" @@ -11772,6 +12213,27 @@ "end_time", "selected_time_window" ] + }, + "Partial<{color:number;guild_ids:string[];id:number;name:string;}>": { + "type": "object", + "properties": { + "color": { + "type": "integer" + }, + "guild_ids": { + "type": "array", + "items": { + "type": "string" + } + }, + "id": { + "type": "integer" + }, + "name": { + "type": "string" + } + }, + "additionalProperties": false } }, "$schema": "http://json-schema.org/draft-07/schema#" @@ -12314,6 +12776,27 @@ "end_time", "selected_time_window" ] + }, + "Partial<{color:number;guild_ids:string[];id:number;name:string;}>": { + "type": "object", + "properties": { + "color": { + "type": "integer" + }, + "guild_ids": { + "type": "array", + "items": { + "type": "string" + } + }, + "id": { + "type": "integer" + }, + "name": { + "type": "string" + } + }, + "additionalProperties": false } }, "$schema": "http://json-schema.org/draft-07/schema#" @@ -12827,6 +13310,27 @@ "end_time", "selected_time_window" ] + }, + "Partial<{color:number;guild_ids:string[];id:number;name:string;}>": { + "type": "object", + "properties": { + "color": { + "type": "integer" + }, + "guild_ids": { + "type": "array", + "items": { + "type": "string" + } + }, + "id": { + "type": "integer" + }, + "name": { + "type": "string" + } + }, + "additionalProperties": false } }, "$schema": "http://json-schema.org/draft-07/schema#" @@ -13339,6 +13843,27 @@ "end_time", "selected_time_window" ] + }, + "Partial<{color:number;guild_ids:string[];id:number;name:string;}>": { + "type": "object", + "properties": { + "color": { + "type": "integer" + }, + "guild_ids": { + "type": "array", + "items": { + "type": "string" + } + }, + "id": { + "type": "integer" + }, + "name": { + "type": "string" + } + }, + "additionalProperties": false } }, "$schema": "http://json-schema.org/draft-07/schema#" @@ -13855,6 +14380,27 @@ "end_time", "selected_time_window" ] + }, + "Partial<{color:number;guild_ids:string[];id:number;name:string;}>": { + "type": "object", + "properties": { + "color": { + "type": "integer" + }, + "guild_ids": { + "type": "array", + "items": { + "type": "string" + } + }, + "id": { + "type": "integer" + }, + "name": { + "type": "string" + } + }, + "additionalProperties": false } }, "$schema": "http://json-schema.org/draft-07/schema#" @@ -14367,6 +14913,27 @@ "end_time", "selected_time_window" ] + }, + "Partial<{color:number;guild_ids:string[];id:number;name:string;}>": { + "type": "object", + "properties": { + "color": { + "type": "integer" + }, + "guild_ids": { + "type": "array", + "items": { + "type": "string" + } + }, + "id": { + "type": "integer" + }, + "name": { + "type": "string" + } + }, + "additionalProperties": false } }, "$schema": "http://json-schema.org/draft-07/schema#" @@ -14876,6 +15443,27 @@ "end_time", "selected_time_window" ] + }, + "Partial<{color:number;guild_ids:string[];id:number;name:string;}>": { + "type": "object", + "properties": { + "color": { + "type": "integer" + }, + "guild_ids": { + "type": "array", + "items": { + "type": "string" + } + }, + "id": { + "type": "integer" + }, + "name": { + "type": "string" + } + }, + "additionalProperties": false } }, "$schema": "http://json-schema.org/draft-07/schema#" @@ -15391,6 +15979,27 @@ "end_time", "selected_time_window" ] + }, + "Partial<{color:number;guild_ids:string[];id:number;name:string;}>": { + "type": "object", + "properties": { + "color": { + "type": "integer" + }, + "guild_ids": { + "type": "array", + "items": { + "type": "string" + } + }, + "id": { + "type": "integer" + }, + "name": { + "type": "string" + } + }, + "additionalProperties": false } }, "$schema": "http://json-schema.org/draft-07/schema#" @@ -15938,6 +16547,27 @@ "end_time", "selected_time_window" ] + }, + "Partial<{color:number;guild_ids:string[];id:number;name:string;}>": { + "type": "object", + "properties": { + "color": { + "type": "integer" + }, + "guild_ids": { + "type": "array", + "items": { + "type": "string" + } + }, + "id": { + "type": "integer" + }, + "name": { + "type": "string" + } + }, + "additionalProperties": false } }, "$schema": "http://json-schema.org/draft-07/schema#" @@ -16470,6 +17100,27 @@ "end_time", "selected_time_window" ] + }, + "Partial<{color:number;guild_ids:string[];id:number;name:string;}>": { + "type": "object", + "properties": { + "color": { + "type": "integer" + }, + "guild_ids": { + "type": "array", + "items": { + "type": "string" + } + }, + "id": { + "type": "integer" + }, + "name": { + "type": "string" + } + }, + "additionalProperties": false } }, "$schema": "http://json-schema.org/draft-07/schema#" @@ -17057,6 +17708,27 @@ "end_time", "selected_time_window" ] + }, + "Partial<{color:number;guild_ids:string[];id:number;name:string;}>": { + "type": "object", + "properties": { + "color": { + "type": "integer" + }, + "guild_ids": { + "type": "array", + "items": { + "type": "string" + } + }, + "id": { + "type": "integer" + }, + "name": { + "type": "string" + } + }, + "additionalProperties": false } }, "$schema": "http://json-schema.org/draft-07/schema#" @@ -17718,6 +18390,27 @@ "end_time", "selected_time_window" ] + }, + "Partial<{color:number;guild_ids:string[];id:number;name:string;}>": { + "type": "object", + "properties": { + "color": { + "type": "integer" + }, + "guild_ids": { + "type": "array", + "items": { + "type": "string" + } + }, + "id": { + "type": "integer" + }, + "name": { + "type": "string" + } + }, + "additionalProperties": false } }, "$schema": "http://json-schema.org/draft-07/schema#" @@ -18250,6 +18943,27 @@ "end_time", "selected_time_window" ] + }, + "Partial<{color:number;guild_ids:string[];id:number;name:string;}>": { + "type": "object", + "properties": { + "color": { + "type": "integer" + }, + "guild_ids": { + "type": "array", + "items": { + "type": "string" + } + }, + "id": { + "type": "integer" + }, + "name": { + "type": "string" + } + }, + "additionalProperties": false } }, "$schema": "http://json-schema.org/draft-07/schema#" @@ -18826,6 +19540,27 @@ "end_time", "selected_time_window" ] + }, + "Partial<{color:number;guild_ids:string[];id:number;name:string;}>": { + "type": "object", + "properties": { + "color": { + "type": "integer" + }, + "guild_ids": { + "type": "array", + "items": { + "type": "string" + } + }, + "id": { + "type": "integer" + }, + "name": { + "type": "string" + } + }, + "additionalProperties": false } }, "$schema": "http://json-schema.org/draft-07/schema#" @@ -19347,6 +20082,27 @@ "end_time", "selected_time_window" ] + }, + "Partial<{color:number;guild_ids:string[];id:number;name:string;}>": { + "type": "object", + "properties": { + "color": { + "type": "integer" + }, + "guild_ids": { + "type": "array", + "items": { + "type": "string" + } + }, + "id": { + "type": "integer" + }, + "name": { + "type": "string" + } + }, + "additionalProperties": false } }, "$schema": "http://json-schema.org/draft-07/schema#" @@ -19411,9 +20167,6 @@ } }, "additionalProperties": false, - "required": [ - "channel_overrides" - ], "definitions": { "ChannelPermissionOverwriteType": { "enum": [ @@ -19908,6 +20661,27 @@ "end_time", "selected_time_window" ] + }, + "Partial<{color:number;guild_ids:string[];id:number;name:string;}>": { + "type": "object", + "properties": { + "color": { + "type": "integer" + }, + "guild_ids": { + "type": "array", + "items": { + "type": "string" + } + }, + "id": { + "type": "integer" + }, + "name": { + "type": "string" + } + }, + "additionalProperties": false } }, "$schema": "http://json-schema.org/draft-07/schema#" @@ -20424,6 +21198,27 @@ "end_time", "selected_time_window" ] + }, + "Partial<{color:number;guild_ids:string[];id:number;name:string;}>": { + "type": "object", + "properties": { + "color": { + "type": "integer" + }, + "guild_ids": { + "type": "array", + "items": { + "type": "string" + } + }, + "id": { + "type": "integer" + }, + "name": { + "type": "string" + } + }, + "additionalProperties": false } }, "$schema": "http://json-schema.org/draft-07/schema#" @@ -20945,12 +21740,195 @@ "end_time", "selected_time_window" ] + }, + "Partial<{color:number;guild_ids:string[];id:number;name:string;}>": { + "type": "object", + "properties": { + "color": { + "type": "integer" + }, + "guild_ids": { + "type": "array", + "items": { + "type": "string" + } + }, + "id": { + "type": "integer" + }, + "name": { + "type": "string" + } + }, + "additionalProperties": false } }, "$schema": "http://json-schema.org/draft-07/schema#" }, - "ActivitySchema": { - "$ref": "#/definitions/ActivitySchema", + "UserSettingsSchema": { + "type": "object", + "properties": { + "guild_folders": { + "type": "array", + "items": { + "$ref": "#/definitions/Partial<{color:number;guild_ids:string[];id:number;name:string;}>" + } + }, + "afk_timeout": { + "type": "integer" + }, + "allow_accessibility_detection": { + "type": "boolean" + }, + "animate_emoji": { + "type": "boolean" + }, + "animate_stickers": { + "type": "integer" + }, + "contact_sync_enabled": { + "type": "boolean" + }, + "convert_emoticons": { + "type": "boolean" + }, + "custom_status": { + "anyOf": [ + { + "type": "object", + "properties": { + "emoji_id": { + "type": "string" + }, + "emoji_name": { + "type": "string" + }, + "expires_at": { + "type": "integer" + }, + "text": { + "type": "string" + } + }, + "additionalProperties": false + }, + { + "type": "null" + } + ] + }, + "default_guilds_restricted": { + "type": "boolean" + }, + "detect_platform_accounts": { + "type": "boolean" + }, + "developer_mode": { + "type": "boolean" + }, + "disable_games_tab": { + "type": "boolean" + }, + "enable_tts_command": { + "type": "boolean" + }, + "explicit_content_filter": { + "type": "integer" + }, + "friend_source_flags": { + "type": "object", + "properties": { + "all": { + "type": "boolean" + } + }, + "additionalProperties": false, + "required": [ + "all" + ] + }, + "gateway_connected": { + "type": "boolean" + }, + "gif_auto_play": { + "type": "boolean" + }, + "guild_positions": { + "type": "array", + "items": { + "type": "string" + } + }, + "inline_attachment_media": { + "type": "boolean" + }, + "inline_embed_media": { + "type": "boolean" + }, + "locale": { + "type": "string" + }, + "message_display_compact": { + "type": "boolean" + }, + "native_phone_integration_enabled": { + "type": "boolean" + }, + "render_embeds": { + "type": "boolean" + }, + "render_reactions": { + "type": "boolean" + }, + "restricted_guilds": { + "type": "array", + "items": { + "type": "string" + } + }, + "show_current_game": { + "type": "boolean" + }, + "status": { + "enum": [ + "dnd", + "idle", + "invisible", + "offline", + "online" + ], + "type": "string" + }, + "stream_notifications_enabled": { + "type": "boolean" + }, + "theme": { + "enum": [ + "dark", + "white" + ], + "type": "string" + }, + "timezone_offset": { + "type": "integer" + }, + "banner_color": { + "type": [ + "null", + "string" + ] + }, + "friend_discovery_flags": { + "type": "integer" + }, + "view_nsfw_guilds": { + "type": "boolean" + }, + "passwordless": { + "type": "boolean" + } + }, + "additionalProperties": false, "definitions": { "ChannelPermissionOverwriteType": { "enum": [ @@ -21445,24 +22423,33 @@ "end_time", "selected_time_window" ] + }, + "Partial<{color:number;guild_ids:string[];id:number;name:string;}>": { + "type": "object", + "properties": { + "color": { + "type": "integer" + }, + "guild_ids": { + "type": "array", + "items": { + "type": "string" + } + }, + "id": { + "type": "integer" + }, + "name": { + "type": "string" + } + }, + "additionalProperties": false } }, "$schema": "http://json-schema.org/draft-07/schema#" }, - "BulkDeleteSchema": { - "type": "object", - "properties": { - "messages": { - "type": "array", - "items": { - "type": "string" - } - } - }, - "additionalProperties": false, - "required": [ - "messages" - ], + "ActivitySchema": { + "$ref": "#/definitions/ActivitySchema", "definitions": { "ChannelPermissionOverwriteType": { "enum": [ @@ -21957,20 +22944,44 @@ "end_time", "selected_time_window" ] + }, + "Partial<{color:number;guild_ids:string[];id:number;name:string;}>": { + "type": "object", + "properties": { + "color": { + "type": "integer" + }, + "guild_ids": { + "type": "array", + "items": { + "type": "string" + } + }, + "id": { + "type": "integer" + }, + "name": { + "type": "string" + } + }, + "additionalProperties": false } }, "$schema": "http://json-schema.org/draft-07/schema#" }, - "MemberNickChangeSchema": { + "BulkDeleteSchema": { "type": "object", "properties": { - "nick": { - "type": "string" + "messages": { + "type": "array", + "items": { + "type": "string" + } } }, "additionalProperties": false, "required": [ - "nick" + "messages" ], "definitions": { "ChannelPermissionOverwriteType": { @@ -22466,20 +23477,41 @@ "end_time", "selected_time_window" ] + }, + "Partial<{color:number;guild_ids:string[];id:number;name:string;}>": { + "type": "object", + "properties": { + "color": { + "type": "integer" + }, + "guild_ids": { + "type": "array", + "items": { + "type": "string" + } + }, + "id": { + "type": "integer" + }, + "name": { + "type": "string" + } + }, + "additionalProperties": false } }, "$schema": "http://json-schema.org/draft-07/schema#" }, - "PruneSchema": { + "MemberNickChangeSchema": { "type": "object", "properties": { - "days": { - "type": "integer" + "nick": { + "type": "string" } }, "additionalProperties": false, "required": [ - "days" + "nick" ], "definitions": { "ChannelPermissionOverwriteType": { @@ -22975,198 +24007,42 @@ "end_time", "selected_time_window" ] - } - }, - "$schema": "http://json-schema.org/draft-07/schema#" - }, - "UserSettingsSchema": { - "type": "object", - "properties": { - "afk_timeout": { - "type": "integer" - }, - "allow_accessibility_detection": { - "type": "boolean" - }, - "animate_emoji": { - "type": "boolean" - }, - "animate_stickers": { - "type": "integer" - }, - "contact_sync_enabled": { - "type": "boolean" - }, - "convert_emoticons": { - "type": "boolean" - }, - "custom_status": { - "anyOf": [ - { - "type": "object", - "properties": { - "emoji_id": { - "type": "string" - }, - "emoji_name": { - "type": "string" - }, - "expires_at": { - "type": "integer" - }, - "text": { - "type": "string" - } - }, - "additionalProperties": false - }, - { - "type": "null" - } - ] - }, - "default_guilds_restricted": { - "type": "boolean" - }, - "detect_platform_accounts": { - "type": "boolean" - }, - "developer_mode": { - "type": "boolean" - }, - "disable_games_tab": { - "type": "boolean" - }, - "enable_tts_command": { - "type": "boolean" - }, - "explicit_content_filter": { - "type": "integer" }, - "friend_source_flags": { + "Partial<{color:number;guild_ids:string[];id:number;name:string;}>": { "type": "object", "properties": { - "all": { - "type": "boolean" - } - }, - "additionalProperties": false, - "required": [ - "all" - ] - }, - "gateway_connected": { - "type": "boolean" - }, - "gif_auto_play": { - "type": "boolean" - }, - "guild_folders": { - "type": "array", - "items": { - "type": "object", - "properties": { - "color": { - "type": "integer" - }, - "guild_ids": { - "type": "array", - "items": { - "type": "string" - } - }, - "id": { - "type": "integer" - }, - "name": { + "color": { + "type": "integer" + }, + "guild_ids": { + "type": "array", + "items": { "type": "string" } }, - "additionalProperties": false, - "required": [ - "color", - "guild_ids", - "id", - "name" - ] - } - }, - "guild_positions": { - "type": "array", - "items": { - "type": "string" - } - }, - "inline_attachment_media": { - "type": "boolean" - }, - "inline_embed_media": { - "type": "boolean" - }, - "locale": { - "type": "string" - }, - "message_display_compact": { - "type": "boolean" - }, - "native_phone_integration_enabled": { - "type": "boolean" - }, - "render_embeds": { - "type": "boolean" - }, - "render_reactions": { - "type": "boolean" - }, - "restricted_guilds": { - "type": "array", - "items": { - "type": "string" - } - }, - "show_current_game": { - "type": "boolean" - }, - "status": { - "enum": [ - "dnd", - "idle", - "invisible", - "offline", - "online" - ], - "type": "string" - }, - "stream_notifications_enabled": { - "type": "boolean" - }, - "theme": { - "enum": [ - "dark", - "white" - ], - "type": "string" - }, - "timezone_offset": { - "type": "integer" - }, - "banner_color": { - "type": [ - "null", - "string" - ] - }, - "friend_discovery_flags": { + "id": { + "type": "integer" + }, + "name": { + "type": "string" + } + }, + "additionalProperties": false + } + }, + "$schema": "http://json-schema.org/draft-07/schema#" + }, + "PruneSchema": { + "type": "object", + "properties": { + "days": { "type": "integer" - }, - "view_nsfw_guilds": { - "type": "boolean" - }, - "passwordless": { - "type": "boolean" } }, "additionalProperties": false, + "required": [ + "days" + ], "definitions": { "ChannelPermissionOverwriteType": { "enum": [ @@ -23661,6 +24537,27 @@ "end_time", "selected_time_window" ] + }, + "Partial<{color:number;guild_ids:string[];id:number;name:string;}>": { + "type": "object", + "properties": { + "color": { + "type": "integer" + }, + "guild_ids": { + "type": "array", + "items": { + "type": "string" + } + }, + "id": { + "type": "integer" + }, + "name": { + "type": "string" + } + }, + "additionalProperties": false } }, "$schema": "http://json-schema.org/draft-07/schema#" diff --git a/fosscord-server.code-workspace b/fosscord-server.code-workspace index bab8e15b..60d8a538 100644 --- a/fosscord-server.code-workspace +++ b/fosscord-server.code-workspace @@ -4,9 +4,6 @@ "path": "src" }, { - "path": "src-slowcord" - }, - { "path": "assets" }, { diff --git a/src/api/routes/users/@me/settings.ts b/src/api/routes/users/@me/settings.ts index 4493fcc7..8fb86012 100644 --- a/src/api/routes/users/@me/settings.ts +++ b/src/api/routes/users/@me/settings.ts @@ -1,5 +1,5 @@ import { Router, Response, Request } from "express"; -import { User, UserSettings } from "@fosscord/util"; +import { OrmUtils, User, UserSettingsSchema } from "@fosscord/util"; import { route } from "@fosscord/api"; const router = Router(); @@ -16,14 +16,15 @@ router.patch( "/", route({ body: "UserSettingsSchema" }), async (req: Request, res: Response) => { - const body = req.body as UserSettings; + const body = req.body as UserSettingsSchema; if (body.locale === "en") body.locale = "en-US"; // fix discord client crash on unkown locale const user = await User.findOneOrFail({ where: { id: req.user_id, bot: false }, + select: ["settings"] }); - user.settings = { ...user.settings, ...body }; - await user.save(); + user.settings = OrmUtils.mergeDeep(user.settings, body); + User.update({ id: user.id }, { settings: user.settings }); res.json(user.settings); }, diff --git a/src/util/entities/User.ts b/src/util/entities/User.ts index 7f37391a..700a6dae 100644 --- a/src/util/entities/User.ts +++ b/src/util/entities/User.ts @@ -453,10 +453,10 @@ export interface UserSettings { gif_auto_play: boolean; // every top guild is displayed as a "folder" guild_folders: { - color: number; + color?: number; guild_ids: string[]; - id: number; - name: string; + id?: number; + name?: string; }[]; guild_positions: string[]; // guild ids ordered by position inline_attachment_media: boolean; diff --git a/src/util/schemas/UserGuildSettingsSchema.ts b/src/util/schemas/UserGuildSettingsSchema.ts index 43028c58..e78bbf7c 100644 --- a/src/util/schemas/UserGuildSettingsSchema.ts +++ b/src/util/schemas/UserGuildSettingsSchema.ts @@ -3,7 +3,7 @@ import { UserGuildSettings, ChannelOverride } from "@fosscord/util"; // This sucks. I would use a DeepPartial, my own or typeorms, but they both generate inncorect schema export interface UserGuildSettingsSchema extends Partial<Omit<UserGuildSettings, "channel_overrides">> { - channel_overrides: { + channel_overrides?: { [channel_id: string]: Partial<ChannelOverride>; }; } \ No newline at end of file diff --git a/src/util/schemas/index.ts b/src/util/schemas/index.ts index 8881b247..780022c6 100644 --- a/src/util/schemas/index.ts +++ b/src/util/schemas/index.ts @@ -44,4 +44,5 @@ export * from "./ChannelPermissionOverwriteSchema"; export * from "./UserGuildSettingsSchema"; export * from "./GatewayPayloadSchema"; export * from "./RolePositionUpdateSchema"; -export * from "./ChannelReorderSchema"; \ No newline at end of file +export * from "./ChannelReorderSchema"; +export * from "./UserSettingsSchema"; \ No newline at end of file |