mirror of
https://github.com/CompeyDev/fxtwitter-docker.git
synced 2025-04-07 19:40:54 +01:00
upstream fixes
This commit is contained in:
parent
0a616e9731
commit
8ce632308e
2 changed files with 22 additions and 2 deletions
|
@ -16,7 +16,7 @@ const populateTweetProperties = async (
|
|||
conversation: TweetResultsByRestIdResult, // TimelineBlobPartial,
|
||||
language: string | undefined
|
||||
// eslint-disable-next-line sonarjs/cognitive-complexity
|
||||
): Promise<APITweet> => {
|
||||
): Promise<APITweet | null> => {
|
||||
const apiTweet = {} as APITweet;
|
||||
|
||||
/* Sometimes, Twitter returns a different kind of Tweet type called 'TweetWithVisibilityResults'.
|
||||
|
@ -38,6 +38,11 @@ const populateTweetProperties = async (
|
|||
tweet.views = tweet?.tweet?.views;
|
||||
}
|
||||
|
||||
if (typeof tweet.core === 'undefined') {
|
||||
console.log('Tweet still not valid', tweet);
|
||||
return null;
|
||||
}
|
||||
|
||||
/* With v2 conversation API we re-add the user object ot the tweet because
|
||||
Twitter stores it separately in the conversation API. This is to consolidate
|
||||
it in case a user appears multiple times in a thread. */
|
||||
|
|
|
@ -13,7 +13,7 @@ export const buildAPITweet = async (
|
|||
threadPiece = false,
|
||||
legacyAPI = false
|
||||
// eslint-disable-next-line sonarjs/cognitive-complexity
|
||||
): Promise<APITweet> => {
|
||||
): Promise<APITweet | null> => {
|
||||
const apiTweet = {} as APITweet;
|
||||
|
||||
/* Sometimes, Twitter returns a different kind of Tweet type called 'TweetWithVisibilityResults'.
|
||||
|
@ -35,6 +35,11 @@ export const buildAPITweet = async (
|
|||
tweet.views = tweet?.tweet?.views;
|
||||
}
|
||||
|
||||
if (typeof tweet.core === 'undefined') {
|
||||
console.log('Tweet still not valid', tweet);
|
||||
return null;
|
||||
}
|
||||
|
||||
const graphQLUser = tweet.core.user_results.result;
|
||||
const apiUser = convertToApiUser(graphQLUser);
|
||||
|
||||
|
@ -124,6 +129,16 @@ export const buildAPITweet = async (
|
|||
photos: [],
|
||||
videos: [],
|
||||
};
|
||||
|
||||
/* We found a quote tweet, let's process that too */
|
||||
const quoteTweet = tweet.quoted_status_result;
|
||||
if (quoteTweet) {
|
||||
apiTweet.quote = (await buildAPITweet(quoteTweet, language)) as APITweet;
|
||||
/* Only override the embed_card if it's a basic tweet, since media always takes precedence */
|
||||
if (apiTweet.embed_card === 'tweet'&& apiTweet.quote !== null) {
|
||||
apiTweet.embed_card = apiTweet.quote.embed_card;
|
||||
}
|
||||
}
|
||||
|
||||
const mediaList = Array.from(
|
||||
tweet.legacy.extended_entities?.media || tweet.legacy.entities?.media || []
|
||||
|
|
Loading…
Add table
Reference in a new issue