1
0
mirror of https://github.com/spacebarchat/server.git synced 2024-11-09 20:22:47 +01:00

Prettier & fix merge util/handlers/Message

This commit is contained in:
TomatoCake 2024-07-18 14:42:22 +02:00
parent 128b81bc6a
commit 15a2e57b05

View File

@ -43,16 +43,12 @@ import {
//CHANNEL_MENTION,
USER_MENTION,
Webhook,
Attachment,
Config,
Sticker,
MessageCreateSchema,
EmbedCache,
handleFile,
Permissions,
} from "@spacebar/util";
import { HTTPError } from "lambert-server";
import { In } from "typeorm";
import { EmbedHandlers } from "@spacebar/api";
import * as Sentry from "@sentry/node";
import fetch from "node-fetch";
const allow_empty = false;
// TODO: check webhook, application, system author, stickers
// TODO: embed gifs/videos/images
@ -175,6 +171,11 @@ export async function handleMessage(opts: MessageOptions): Promise<Message> {
const guild = await Guild.findOneOrFail({
where: { id: channel.guild_id },
});
if (!opts.message_reference.guild_id)
opts.message_reference.guild_id = channel.guild_id;
if (!opts.message_reference.channel_id)
opts.message_reference.channel_id = opts.channel_id;
if (!guild.features.includes("CROSS_CHANNEL_REPLIES")) {
if (opts.message_reference.guild_id !== channel.guild_id)
throw new HTTPError(
@ -185,11 +186,14 @@ export async function handleMessage(opts: MessageOptions): Promise<Message> {
"You can only reference messages from this channel",
);
}
message.message_reference = opts.message_reference;
}
/** Q: should be checked if the referenced message exists? ANSWER: NO
otherwise backfilling won't work **/
message.type = MessageType.REPLY;
}
}
// TODO: stickers/activity
if (