mirror of
https://github.com/spacebarchat/server.git
synced 2026-08-22 16:20:12 +00:00
Dont (re-/)add embeds if message has embed suppressed
This commit is contained in:
@@ -23,7 +23,7 @@ import probe from "probe-image-size";
|
||||
import { FindOptionsWhere, In } from "typeorm";
|
||||
import { EmbedCache, Message } from "@spacebar/database";
|
||||
import { sleep, arrayDistinctBy, arrayGroupBy, normalizeUrl } from "@spacebar/extensions";
|
||||
import { Config, emitEvent, MessageUpdateEvent, OrmUtils } from "@spacebar/util";
|
||||
import { Config, emitEvent, MessageFlags, MessageUpdateEvent, OrmUtils } from "@spacebar/util";
|
||||
import { Embed, EmbedImage, EmbedType } from "@spacebar/schemas";
|
||||
|
||||
export function getDefaultFetchOptions(): RequestInit {
|
||||
@@ -657,6 +657,9 @@ export async function fillMessageUrlEmbeds(message: Message) {
|
||||
// Filter out embeds that could be links, start from scratch
|
||||
message.embeds = message.embeds.filter((embed) => embed.type === "rich");
|
||||
|
||||
// Dont add embeds if the message has embeds suppressed
|
||||
if ((message.flags & Number(MessageFlags.FLAGS.SUPPRESS_EMBEDS)) !== 0) return message;
|
||||
|
||||
if (linkMatches.length == 0) return message;
|
||||
|
||||
const uniqueLinks: string[] = arrayDistinctBy(linkMatches, normalizeUrl);
|
||||
|
||||
Reference in New Issue
Block a user