improved card embedding

This commit is contained in:
dangered wolf 2022-07-14 20:12:51 -04:00
parent 29f718f599
commit cd9086f63a
No known key found for this signature in database
GPG key ID: 41E4D37680ED8B58
2 changed files with 12 additions and 5 deletions

View file

@ -95,7 +95,6 @@ export const renderCard = async (
`<meta property="og:type" content="video.other">`,
`<meta property="og:video:url" content="${values.player_url.string_value}">`,
`<meta property="og:video:secure_url" content="${values.player_url.string_value}">`,
`<meta property="og:video:type" content="text/html">`,
`<meta property="og:video:width" content="${
values.player_width?.string_value || '1280'
}">`,
@ -103,6 +102,8 @@ export const renderCard = async (
values.player_height?.string_value || '720'
}">`
);
str = 'EMBED_CARD';
}
}

View file

@ -59,12 +59,18 @@ export const handleStatus = async (
let authorText = 'Twitter';
if (tweet.card) {
text += await renderCard(tweet.card, headers, userAgent);
}
text = linkFixer(tweet, text);
if (tweet.card) {
let cardRender = await renderCard(tweet.card, headers, userAgent);
if (cardRender === 'EMBED_CARD') {
authorText = encodeURIComponent(text);
} else {
text += cardRender;
}
}
let quoteTweetMaybe =
conversation.globalObjects?.tweets?.[tweet.quoted_status_id_str || '0'] || null;