mirror of
https://github.com/CompeyDev/fxtwitter-docker.git
synced 2025-04-05 18:40:56 +01:00
Improve Discord twitter_card handling (#387)
This commit is contained in:
parent
433909b936
commit
b7125a4019
2 changed files with 9 additions and 1 deletions
|
@ -130,6 +130,8 @@ const populateTweetProperties = async (
|
||||||
apiTweet.twitter_card = 'player';
|
apiTweet.twitter_card = 'player';
|
||||||
apiTweet.media.videos = apiTweet.media.videos || [];
|
apiTweet.media.videos = apiTweet.media.videos || [];
|
||||||
apiTweet.media.videos.push(mediaObject);
|
apiTweet.media.videos.push(mediaObject);
|
||||||
|
} else {
|
||||||
|
console.log('Unknown media type', mediaObject.type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -284,6 +286,10 @@ export const statusAPI = async (
|
||||||
const quoteTweet = tweet.quoted_status_result;
|
const quoteTweet = tweet.quoted_status_result;
|
||||||
if (quoteTweet) {
|
if (quoteTweet) {
|
||||||
apiTweet.quote = (await populateTweetProperties(quoteTweet, res, language)) as APITweet;
|
apiTweet.quote = (await populateTweetProperties(quoteTweet, res, language)) as APITweet;
|
||||||
|
/* Only override the twitter_card if it's a basic tweet, since media always takes precedence */
|
||||||
|
if (apiTweet.twitter_card === 'tweet') {
|
||||||
|
apiTweet.twitter_card = apiTweet.quote.twitter_card;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Finally, staple the Tweet to the response and return it */
|
/* Finally, staple the Tweet to the response and return it */
|
||||||
|
|
|
@ -344,12 +344,14 @@ export const handleStatus = async (
|
||||||
and we have to pretend to be Medium in order to get working IV, but haven't figured if the template is causing issues. */
|
and we have to pretend to be Medium in order to get working IV, but haven't figured if the template is causing issues. */
|
||||||
const text = useIV ? sanitizeText(newText).replace(/\n/g, '<br>') : sanitizeText(newText);
|
const text = useIV ? sanitizeText(newText).replace(/\n/g, '<br>') : sanitizeText(newText);
|
||||||
|
|
||||||
|
const useCard = tweet.twitter_card === 'tweet' ? tweet.quote?.twitter_card : tweet.twitter_card;
|
||||||
|
|
||||||
/* Push basic headers relating to author, Tweet text, and site name */
|
/* Push basic headers relating to author, Tweet text, and site name */
|
||||||
headers.push(
|
headers.push(
|
||||||
`<meta property="og:title" content="${tweet.author.name} (@${tweet.author.screen_name})"/>`,
|
`<meta property="og:title" content="${tweet.author.name} (@${tweet.author.screen_name})"/>`,
|
||||||
`<meta property="og:description" content="${text}"/>`,
|
`<meta property="og:description" content="${text}"/>`,
|
||||||
`<meta property="og:site_name" content="${siteName}"/>`,
|
`<meta property="og:site_name" content="${siteName}"/>`,
|
||||||
`<meta property="twitter:card" content="${tweet.quote?.twitter_card || tweet.twitter_card}"/>`
|
`<meta property="twitter:card" content="${useCard}"/>`
|
||||||
);
|
);
|
||||||
|
|
||||||
/* Special reply handling if authorText is not overriden */
|
/* Special reply handling if authorText is not overriden */
|
||||||
|
|
Loading…
Add table
Reference in a new issue