fix(route): tweet detail not work (#15355)

This commit is contained in:
GoDotDotDot
2024-04-24 19:17:18 +08:00
committed by GitHub
parent a508a1c706
commit 4787b2c726
3 changed files with 41 additions and 2 deletions
@@ -10,6 +10,7 @@ const graphQLEndpointsPlain = [
'/graphql/tD8zKvQzwY3kdx5yz6YmOw/UserByRestId',
'/graphql/flaR-PUMshxFWZWPNpq4zA/SearchTimeline',
'/graphql/TOTgqavWmxywKv5IbMMK1w/ListLatestTweetsTimeline',
'/graphql/zJvfJs3gSbrVhC0MKjt_OQ/TweetDetail',
];
const gqlMap = Object.fromEntries(graphQLEndpointsPlain.map((endpoint) => [endpoint.split('/')[3].replace(/V2$|Query$|QueryV2$/, ''), endpoint]));
@@ -49,6 +50,34 @@ const gqlFeatureFeed = {
longform_notetweets_inline_media_enabled: true,
responsive_web_enhance_cards_enabled: false,
};
const TweetDetailFeatures = {
rweb_tipjar_consumption_enabled: true,
responsive_web_graphql_exclude_directive_enabled: true,
verified_phone_label_enabled: false,
creator_subscriptions_tweet_preview_api_enabled: true,
responsive_web_graphql_timeline_navigation_enabled: true,
responsive_web_graphql_skip_user_profile_image_extensions_enabled: false,
communities_web_enable_tweet_community_results_fetch: true,
c9s_tweet_anatomy_moderator_badge_enabled: true,
articles_preview_enabled: false,
tweetypie_unmention_optimization_enabled: true,
responsive_web_edit_tweet_api_enabled: true,
graphql_is_translatable_rweb_tweet_is_translatable_enabled: true,
view_counts_everywhere_api_enabled: true,
longform_notetweets_consumption_enabled: true,
responsive_web_twitter_article_tweet_consumption_enabled: true,
tweet_awards_web_tipping_enabled: false,
creator_subscriptions_quote_tweet_preview_enabled: false,
freedom_of_speech_not_reach_fetch_enabled: true,
standardized_nudges_misinfo: true,
tweet_with_visibility_results_prefer_gql_limited_actions_policy_enabled: true,
tweet_with_visibility_results_prefer_gql_media_interstitial_enabled: true,
rweb_video_timestamps_enabled: true,
longform_notetweets_rich_text_read_enabled: true,
longform_notetweets_inline_media_enabled: true,
responsive_web_enhance_cards_enabled: false,
};
const gqlFeatures = {
UserByScreenName: gqlFeatureUser,
UserByRestId: gqlFeatureUser,
@@ -58,6 +87,7 @@ const gqlFeatures = {
SearchTimeline: gqlFeatureFeed,
ListLatestTweetsTimeline: gqlFeatureFeed,
HomeTimeline: gqlFeatureFeed,
TweetDetail: TweetDetailFeatures,
};
const timelineParams = {
+1 -1
View File
@@ -55,7 +55,6 @@ export const paginationTweets = async (endpoint: string, userId: number | undefi
}),
features: JSON.stringify(gqlFeatures[endpoint]),
});
let instructions;
if (path) {
instructions = data;
@@ -121,5 +120,6 @@ export function gatherLegacyFromData(entries: any[], filterNested?: string[], us
}
}
}
return tweets;
}
+10 -1
View File
@@ -39,7 +39,16 @@ async function handler(ctx) {
const status = ctx.req.param('status');
const routeParams = new URLSearchParams(ctx.req.param('original'));
const original = fallback(undefined, queryToBoolean(routeParams.get('original')), false);
const params = { focalTweetId: status };
const params = {
focalTweetId: status,
with_rux_injections: false,
includePromotedContent: true,
withCommunity: true,
withQuickPromoteEligibilityTweetFields: true,
withBirdwatchNotes: true,
withVoice: true,
withV2Timeline: true,
};
await api.init();
const userInfo = await api.getUser(id);
const data = await api.getUserTweet(id, params);