mirror of
https://github.com/spacebarchat/server.git
synced 2024-11-10 04:32:35 +01:00
Fix user settings not saving properly and guild folders
This commit is contained in:
parent
a75af3d9ff
commit
4c58a8bc24
4987
assets/schemas.json
4987
assets/schemas.json
File diff suppressed because it is too large
Load Diff
@ -3,9 +3,6 @@
|
|||||||
{
|
{
|
||||||
"path": "src"
|
"path": "src"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"path": "src-slowcord"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"path": "assets"
|
"path": "assets"
|
||||||
},
|
},
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { Router, Response, Request } from "express";
|
import { Router, Response, Request } from "express";
|
||||||
import { User, UserSettings } from "@fosscord/util";
|
import { OrmUtils, User, UserSettingsSchema } from "@fosscord/util";
|
||||||
import { route } from "@fosscord/api";
|
import { route } from "@fosscord/api";
|
||||||
|
|
||||||
const router = Router();
|
const router = Router();
|
||||||
@ -16,14 +16,15 @@ router.patch(
|
|||||||
"/",
|
"/",
|
||||||
route({ body: "UserSettingsSchema" }),
|
route({ body: "UserSettingsSchema" }),
|
||||||
async (req: Request, res: Response) => {
|
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
|
if (body.locale === "en") body.locale = "en-US"; // fix discord client crash on unkown locale
|
||||||
|
|
||||||
const user = await User.findOneOrFail({
|
const user = await User.findOneOrFail({
|
||||||
where: { id: req.user_id, bot: false },
|
where: { id: req.user_id, bot: false },
|
||||||
|
select: ["settings"]
|
||||||
});
|
});
|
||||||
user.settings = { ...user.settings, ...body };
|
user.settings = OrmUtils.mergeDeep(user.settings, body);
|
||||||
await user.save();
|
User.update({ id: user.id }, { settings: user.settings });
|
||||||
|
|
||||||
res.json(user.settings);
|
res.json(user.settings);
|
||||||
},
|
},
|
||||||
|
@ -453,10 +453,10 @@ export interface UserSettings {
|
|||||||
gif_auto_play: boolean;
|
gif_auto_play: boolean;
|
||||||
// every top guild is displayed as a "folder"
|
// every top guild is displayed as a "folder"
|
||||||
guild_folders: {
|
guild_folders: {
|
||||||
color: number;
|
color?: number;
|
||||||
guild_ids: string[];
|
guild_ids: string[];
|
||||||
id: number;
|
id?: number;
|
||||||
name: string;
|
name?: string;
|
||||||
}[];
|
}[];
|
||||||
guild_positions: string[]; // guild ids ordered by position
|
guild_positions: string[]; // guild ids ordered by position
|
||||||
inline_attachment_media: boolean;
|
inline_attachment_media: boolean;
|
||||||
|
@ -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
|
// This sucks. I would use a DeepPartial, my own or typeorms, but they both generate inncorect schema
|
||||||
export interface UserGuildSettingsSchema
|
export interface UserGuildSettingsSchema
|
||||||
extends Partial<Omit<UserGuildSettings, "channel_overrides">> {
|
extends Partial<Omit<UserGuildSettings, "channel_overrides">> {
|
||||||
channel_overrides: {
|
channel_overrides?: {
|
||||||
[channel_id: string]: Partial<ChannelOverride>;
|
[channel_id: string]: Partial<ChannelOverride>;
|
||||||
};
|
};
|
||||||
}
|
}
|
@ -44,4 +44,5 @@ export * from "./ChannelPermissionOverwriteSchema";
|
|||||||
export * from "./UserGuildSettingsSchema";
|
export * from "./UserGuildSettingsSchema";
|
||||||
export * from "./GatewayPayloadSchema";
|
export * from "./GatewayPayloadSchema";
|
||||||
export * from "./RolePositionUpdateSchema";
|
export * from "./RolePositionUpdateSchema";
|
||||||
export * from "./ChannelReorderSchema";
|
export * from "./ChannelReorderSchema";
|
||||||
|
export * from "./UserSettingsSchema";
|
Loading…
Reference in New Issue
Block a user