Merge branch 'master' into webhookFix
This commit is contained in:
commit
da2c004ccd
@ -48,6 +48,7 @@ import { In } from "typeorm";
|
|||||||
import fetch from "node-fetch-commonjs";
|
import fetch from "node-fetch-commonjs";
|
||||||
import { CloudAttachment } from "../../../util/entities/CloudAttachment";
|
import { CloudAttachment } from "../../../util/entities/CloudAttachment";
|
||||||
import { Embed, MessageCreateAttachment, MessageCreateCloudAttachment, MessageCreateSchema, MessageType, Reaction } from "@spacebar/schemas";
|
import { Embed, MessageCreateAttachment, MessageCreateCloudAttachment, MessageCreateSchema, MessageType, Reaction } from "@spacebar/schemas";
|
||||||
|
import { EmbedType } from "../../../schemas/api/messages/Embeds";
|
||||||
const allow_empty = false;
|
const allow_empty = false;
|
||||||
// TODO: check webhook, application, system author, stickers
|
// TODO: check webhook, application, system author, stickers
|
||||||
// TODO: embed gifs/videos/images
|
// TODO: embed gifs/videos/images
|
||||||
@ -348,6 +349,11 @@ export async function postHandleMessage(message: Message) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
data.embeds.forEach((embed) => {
|
||||||
|
if (!embed.type) {
|
||||||
|
embed.type = EmbedType.rich;
|
||||||
|
}
|
||||||
|
});
|
||||||
// Filter out embeds that could be links, start from scratch
|
// Filter out embeds that could be links, start from scratch
|
||||||
data.embeds = data.embeds.filter((embed) => embed.type === "rich");
|
data.embeds = data.embeds.filter((embed) => embed.type === "rich");
|
||||||
|
|
||||||
@ -374,10 +380,7 @@ export async function postHandleMessage(message: Message) {
|
|||||||
|
|
||||||
if (uniqueLinks.length === 0) {
|
if (uniqueLinks.length === 0) {
|
||||||
// No valid unique links found, update message to remove old embeds
|
// No valid unique links found, update message to remove old embeds
|
||||||
data.embeds = data.embeds.filter((embed) => {
|
data.embeds = data.embeds.filter((embed) => embed.type === "rich");
|
||||||
const hasUrl = !!embed.url;
|
|
||||||
return !hasUrl;
|
|
||||||
});
|
|
||||||
const author = data.author?.toPublicUser();
|
const author = data.author?.toPublicUser();
|
||||||
const event = {
|
const event = {
|
||||||
event: "MESSAGE_UPDATE",
|
event: "MESSAGE_UPDATE",
|
||||||
|
|||||||
Reference in New Issue
Block a user