summary refs log tree commit diff
path: root/api/src
diff options
context:
space:
mode:
authorMadeline <46743919+MaddyUnderStars@users.noreply.github.com>2022-07-09 16:04:03 +1000
committerMadeline <46743919+MaddyUnderStars@users.noreply.github.com>2022-07-09 16:04:03 +1000
commit9eb7c5de0f6d34eeb6a2f56429e481e285bd1709 (patch)
tree10c5f2835d65543ec6c3ef58d268273d11f51f6a /api/src
parentMerge branch 'feat/latestWebClient' into slowcord (diff)
parent* Make max website preview download size for embeds configurable (diff)
downloadserver-9eb7c5de0f6d34eeb6a2f56429e481e285bd1709.tar.xz
Merge branch 'fix/messageLinkMetas' into slowcord
Diffstat (limited to 'api/src')
-rw-r--r--api/src/util/handlers/Message.ts9
1 files changed, 6 insertions, 3 deletions
diff --git a/api/src/util/handlers/Message.ts b/api/src/util/handlers/Message.ts
index e9f0ac55..48f87dfe 100644
--- a/api/src/util/handlers/Message.ts
+++ b/api/src/util/handlers/Message.ts
@@ -38,7 +38,7 @@ const DEFAULT_FETCH_OPTIONS: any = {
 	headers: {
 		"user-agent": "Mozilla/5.0 (compatible; Fosscord/1.0; +https://github.com/fosscord/fosscord)"
 	},
-	size: 1024 * 1024 * 1,
+	// size: 1024 * 1024 * 5, 	// grabbed from config later
 	compress: true,
 	method: "GET"
 };
@@ -154,7 +154,10 @@ export async function postHandleMessage(message: Message) {
 
 	for (const link of links) {
 		try {
-			const request = await fetch(link, DEFAULT_FETCH_OPTIONS);
+			const request = await fetch(link, {
+				...DEFAULT_FETCH_OPTIONS,
+				size: Config.get().limits.message.maxEmbedDownloadSize,
+			});
 
 			const text = await request.text();
 			const $ = cheerio.load(text);
@@ -191,7 +194,7 @@ export async function postHandleMessage(message: Message) {
 			channel_id: message.channel_id,
 			data
 		} as MessageUpdateEvent),
-		Message.update({ id: message.id, channel_id: message.channel_id }, data)
+		Message.update({ id: message.id, channel_id: message.channel_id }, { embeds: data.embeds })
 	]);
 }