summary refs log tree commit diff
path: root/src/api/util/handlers
diff options
context:
space:
mode:
authorMadeline <46743919+MaddyUnderStars@users.noreply.github.com>2022-10-03 23:38:53 +1100
committerMadeline <46743919+MaddyUnderStars@users.noreply.github.com>2022-10-03 23:38:53 +1100
commite8815f1fd595858e85f1c41df9f4cbe51f968760 (patch)
tree0900328585d42d12b477ffec22f26f42de068aac /src/api/util/handlers
parentMake imagor optional (diff)
downloadserver-e8815f1fd595858e85f1c41df9f4cbe51f968760.tar.xz
Twitter embeds
Diffstat (limited to 'src/api/util/handlers')
-rw-r--r--src/api/util/handlers/Message.ts12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/api/util/handlers/Message.ts b/src/api/util/handlers/Message.ts
index 09b86fc2..d4f0e995 100644
--- a/src/api/util/handlers/Message.ts
+++ b/src/api/util/handlers/Message.ts
@@ -192,19 +192,21 @@ export async function postHandleMessage(message: Message) {
 		const url = new URL(link);
 
 		// bit gross, but whatever!
-		const { endpointPublic } = Config.get().cdn;
-		const handler = url.hostname == new URL(endpointPublic!).hostname ? EmbedHandlers["self"] : EmbedHandlers[url.hostname] || EmbedHandlers["default"];
+		const endpointPublic = Config.get().cdn.endpointPublic || "http://127.0.0.1";	// lol
+		const handler = url.hostname == new URL(endpointPublic).hostname ? EmbedHandlers["self"] : EmbedHandlers[url.hostname] || EmbedHandlers["default"];
 
 		try {
 			const res = await handler(url);
 			if (!res) continue;
-			embed = res;
+			// tried to use shorthand but types didn't like me L
+			if (Array.isArray(res))
+				data.embeds.push(...res)
+			else
+				data.embeds.push(res);
 		}
 		catch (e) {
 			continue;
 		}
-
-		data.embeds.push(embed);
 	}
 
 	await Promise.all([