summary refs log tree commit diff
path: root/api/src/util
diff options
context:
space:
mode:
authorMadeline <46743919+MaddyUnderStars@users.noreply.github.com>2022-07-24 14:13:22 +1000
committerMadeline <46743919+MaddyUnderStars@users.noreply.github.com>2022-07-24 14:21:42 +1000
commit2fc745f9562a25d2d974e8fb95f3a73cfb940318 (patch)
treebaa42effb25235bca5a4b54e5efb319190d81232 /api/src/util
parentOh my god rip database content (diff)
downloadserver-2fc745f9562a25d2d974e8fb95f3a73cfb940318.tar.xz
Turns out I reverted the code I needed rather than the one that will delete all messages, nice
Diffstat (limited to 'api/src/util')
-rw-r--r--api/src/util/handlers/Message.ts10
1 files changed, 9 insertions, 1 deletions
diff --git a/api/src/util/handlers/Message.ts b/api/src/util/handlers/Message.ts
index ed17995b..f98bc2a5 100644
--- a/api/src/util/handlers/Message.ts
+++ b/api/src/util/handlers/Message.ts
@@ -180,8 +180,16 @@ export async function postHandleMessage(message: Message) {
 				}
 			};
 
+			const { endpointPublic, resizeWidthMax, resizeHeightMax } = Config.get().cdn;
+			const resizeWidth = Math.min(resizeWidthMax ?? 1, width ?? 100);
+			const resizeHeight = Math.min(resizeHeightMax ?? 1, height ?? 100);
 			if (author_name) embed.author = { name: author_name };
-			if (image) embed.thumbnail = { proxy_url: image, url: image, width: width, height: height };
+			if (image) embed.thumbnail = {
+				proxy_url: `${endpointPublic}/external/resize/${encodeURIComponent(image)}?width=${resizeWidth}&height=${resizeHeight}`,
+				url: image,
+				width: width,
+				height: height
+			};
 			if (title) embed.title = title;
 			if (url) embed.url = url;
 			if (description) embed.description = description;