mirror of
https://github.com/spacebarchat/server.git
synced 2026-07-21 11:10:59 +00:00
fosscord-server/pulls/858
This commit is contained in:
@@ -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(),
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user