mirror of
https://github.com/CompeyDev/fxtwitter-docker.git
synced 2025-04-07 11:30:53 +01:00
Add TweetWithVisibilityResults support
This commit is contained in:
parent
bfc67935b4
commit
9017056c17
4 changed files with 75 additions and 45 deletions
|
@ -20,10 +20,23 @@ const populateTweetProperties = async (
|
|||
): Promise<APITweet> => {
|
||||
const apiTweet = {} as APITweet;
|
||||
|
||||
/* Sometimes, Twitter returns a different kind of Tweet type called 'TweetWithVisibilityResults'.
|
||||
It has slightly different attributes from the regular 'Tweet' type. We fix that up here. */
|
||||
|
||||
if (typeof tweet.core === 'undefined' && typeof tweet.result !== 'undefined') {
|
||||
tweet = tweet.result;
|
||||
} else {
|
||||
console.log('tweet core exists');
|
||||
}
|
||||
|
||||
if (typeof tweet.core === 'undefined' && typeof tweet.tweet?.core !== 'undefined') {
|
||||
tweet.core = tweet.tweet.core;
|
||||
}
|
||||
|
||||
if (typeof tweet.legacy === 'undefined' && typeof tweet.tweet?.legacy !== 'undefined') {
|
||||
tweet.legacy = tweet.tweet?.legacy;
|
||||
}
|
||||
|
||||
if (typeof tweet.views === 'undefined' && typeof tweet?.tweet?.views !== 'undefined') {
|
||||
tweet.views = tweet?.tweet?.views;
|
||||
}
|
||||
|
||||
/* With v2 conversation API we re-add the user object ot the tweet because
|
||||
|
|
56
src/types/twitterTypes.d.ts
vendored
56
src/types/twitterTypes.d.ts
vendored
|
@ -305,27 +305,7 @@ type GraphQLUser = {
|
|||
};
|
||||
};
|
||||
|
||||
type GraphQLTweet = {
|
||||
// Workaround
|
||||
result: GraphQLTweet;
|
||||
__typename: 'Tweet' | 'TweetUnavailable';
|
||||
rest_id: string; // "1674824189176590336",
|
||||
has_birdwatch_notes: false;
|
||||
core: {
|
||||
user_results: {
|
||||
result: GraphQLUser;
|
||||
};
|
||||
};
|
||||
edit_control: unknown;
|
||||
edit_perspective: unknown;
|
||||
is_translatable: false;
|
||||
views: {
|
||||
count: string; // "562"
|
||||
state: string; // "EnabledWithCount"
|
||||
};
|
||||
source: string; // "<a href=\"https://mobile.twitter.com\" rel=\"nofollow\">Twitter Web App</a>"
|
||||
quoted_status_result?: GraphQLTweet;
|
||||
legacy: {
|
||||
type GraphQLTweetLegacy = {
|
||||
created_at: string; // "Tue Sep 14 20:00:00 +0000 2021"
|
||||
conversation_id_str: string; // "1674824189176590336"
|
||||
bookmark_count: number; // 0
|
||||
|
@ -366,6 +346,40 @@ type GraphQLTweet = {
|
|||
media: TweetMedia[];
|
||||
};
|
||||
};
|
||||
|
||||
type GraphQLTweet = {
|
||||
// Workaround
|
||||
result: GraphQLTweet;
|
||||
__typename: 'Tweet' | 'TweetUnavailable';
|
||||
rest_id: string; // "1674824189176590336",
|
||||
has_birdwatch_notes: false;
|
||||
core: {
|
||||
user_results: {
|
||||
result: GraphQLUser;
|
||||
};
|
||||
};
|
||||
tweet?: {
|
||||
legacy: GraphQLTweetLegacy;
|
||||
views: {
|
||||
count: string; // "562"
|
||||
state: string; // "EnabledWithCount"
|
||||
};
|
||||
core: {
|
||||
user_results: {
|
||||
result: GraphQLUser;
|
||||
};
|
||||
}
|
||||
};
|
||||
edit_control: unknown;
|
||||
edit_perspective: unknown;
|
||||
is_translatable: false;
|
||||
views: {
|
||||
count: string; // "562"
|
||||
state: string; // "EnabledWithCount"
|
||||
};
|
||||
source: string; // "<a href=\"https://mobile.twitter.com\" rel=\"nofollow\">Twitter Web App</a>"
|
||||
quoted_status_result?: GraphQLTweet;
|
||||
legacy: GraphQLTweetLegacy;
|
||||
note_tweet: {
|
||||
is_expandable: boolean;
|
||||
entity_set: {
|
||||
|
|
2
src/types/types.d.ts
vendored
2
src/types/types.d.ts
vendored
|
@ -150,7 +150,7 @@ interface APITweet {
|
|||
replies: number;
|
||||
views?: number | null;
|
||||
|
||||
color: string;
|
||||
color: string | null;
|
||||
|
||||
quote?: APITweet;
|
||||
poll?: APIPoll;
|
||||
|
|
|
@ -15,3 +15,6 @@ command = "npm run build"
|
|||
|
||||
[miniflare.globals]
|
||||
TEST = "true" # Will have unicode character errors in headers if not set to true
|
||||
|
||||
[placement]
|
||||
mode = "smart"
|
Loading…
Add table
Reference in a new issue