fosscord-server/pulls/858

This commit is contained in:
Madeline
2022-08-21 17:35:04 +10:00
parent b3cc3eb687
commit 60c8f3e6b2
25 changed files with 190 additions and 74 deletions
@@ -135,7 +135,7 @@ router.put(
embeds,
channel_id,
attachments,
edited_timestamp: undefined,
edited_timestamp: null,
timestamp: new Date(snowflake.timestamp),
});
@@ -13,7 +13,8 @@ import {
MessageCreateEvent,
Snowflake,
uploadFile,
Member
Member,
Role,
} from "@fosscord/util";
import { HTTPError } from "lambert-server";
import { handleMessage, postHandleMessage, route } from "@fosscord/api";
@@ -146,11 +147,11 @@ router.get("/", async (req: Request, res: Response) => {
Some clients ( discord.js ) only check if a property exists within the response,
which causes erorrs when, say, the `application` property is `null`.
**/
for (var curr in x) {
if (x[curr] === null)
delete x[curr];
}
// for (var curr in x) {
// if (x[curr] === null)
// delete x[curr];
// }
return x;
})
@@ -217,7 +218,7 @@ router.post(
embeds,
channel_id,
attachments,
edited_timestamp: undefined,
edited_timestamp: null,
timestamp: new Date()
});
@@ -244,8 +245,12 @@ router.post(
);
}
//Fix for the client bug
delete message.member
const member = await Member.findOneOrFail({ where: { id: req.user_id }, relations: ["roles"] });
member.roles = member.roles.filter((role: Role) => {
return role.id !== role.guild_id;
}).map((role: Role) => {
return role.id;
}) as any;
await Promise.all([
message.save(),
+8
View File
@@ -6,6 +6,14 @@ const router = Router();
export interface UserSettingsSchema extends Partial<UserSettings> {}
router.get("/", route({}), async (req: Request, res: Response) => {
const user = await User.findOneOrFail(
{ id: req.user_id },
{ relations: ["settings"] }
)
return res.json(user.settings);
});
router.patch("/", route({ body: "UserSettingsSchema" }), async (req: Request, res: Response) => {
const body = req.body as UserSettings;
if (body.locale === "en") body.locale = "en-US"; // fix discord client crash on unkown locale
+3 -2
View File
@@ -55,7 +55,8 @@ export async function handleMessage(opts: MessageOptions): Promise<Message> {
attachments: opts.attachments || [],
embeds: opts.embeds || [],
reactions: /*opts.reactions ||*/[],
type: opts.type ?? 0
type: opts.type ?? 0,
edited_timestamp: null
});
if (message.content && message.content.length > Config.get().limits.message.maxCharacters) {
@@ -278,6 +279,6 @@ interface MessageOptions extends MessageCreateSchema {
embeds?: Embed[];
channel_id?: string;
attachments?: Attachment[];
edited_timestamp?: Date;
edited_timestamp: Date | null;
timestamp?: Date;
}