diff options
author | Madeline <46743919+MaddyUnderStars@users.noreply.github.com> | 2022-10-03 23:38:53 +1100 |
---|---|---|
committer | Madeline <46743919+MaddyUnderStars@users.noreply.github.com> | 2022-10-03 23:38:53 +1100 |
commit | e8815f1fd595858e85f1c41df9f4cbe51f968760 (patch) | |
tree | 0900328585d42d12b477ffec22f26f42de068aac /src/api/util/handlers | |
parent | Make imagor optional (diff) | |
download | server-e8815f1fd595858e85f1c41df9f4cbe51f968760.tar.xz |
Twitter embeds
Diffstat (limited to 'src/api/util/handlers')
-rw-r--r-- | src/api/util/handlers/Message.ts | 12 |
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([ |