summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorMadeline <46743919+MaddyUnderStars@users.noreply.github.com>2022-10-24 19:53:14 +1100
committerMadeline <46743919+MaddyUnderStars@users.noreply.github.com>2022-10-24 19:53:14 +1100
commitd3d9f4ae2fa6f785a4293f02d21f7220f2ce8299 (patch)
tree6ca1c976c480e6093dae538fed40479424e68421 /src
parentForgot some schemas + only generate schemas in util/schemas + add setup script (diff)
downloadserver-d3d9f4ae2fa6f785a4293f02d21f7220f2ce8299.tar.xz
Fix tweets with only video breaking embeds
Diffstat (limited to 'src')
-rw-r--r--src/api/util/utility/EmbedHandlers.ts16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/api/util/utility/EmbedHandlers.ts b/src/api/util/utility/EmbedHandlers.ts

index 831cab9a..700f5b55 100644 --- a/src/api/util/utility/EmbedHandlers.ts +++ b/src/api/util/utility/EmbedHandlers.ts
@@ -165,22 +165,22 @@ export const EmbedHandlers: { [key: string]: (url: URL) => Promise<Embed | Embed "c.tenor.com": genericImageHandler, "media.tenor.com": genericImageHandler, - // TODO: twitter, facebook + // TODO: facebook // have to use their APIs or something because they don't send the metas in initial html "twitter.com": (url: URL) => { return EmbedHandlers["www.twitter.com"](url); }, "www.twitter.com": async (url: URL) => { const token = Config.get().external.twitter; - if (!token) return null; // todo move to config + if (!token) return null; if (!url.href.includes("/status/")) return null; // TODO; const id = url.pathname.split("/")[3]; // super bad lol if (!parseInt(id)) return null; - const endpointUrl = `https://api.twitter.com/2/tweets/${id}` - + `?expansions=author_id,attachments.media_keys` - + `&media.fields=url,width,height` - + `&tweet.fields=created_at,public_metrics` - + `&user.fields=profile_image_url`; + const endpointUrl = `https://api.twitter.com/2/tweets/${id}` + + `?expansions=author_id,attachments.media_keys` + + `&media.fields=url,width,height` + + `&tweet.fields=created_at,public_metrics` + + `&user.fields=profile_image_url`; const response = await fetch(endpointUrl, { @@ -225,7 +225,7 @@ export const EmbedHandlers: { [key: string]: (url: URL) => Promise<Embed | Embed // }, }; - if (media) { + if (media.length > 0) { embed.image = { width: media[0].width, height: media[0].height,