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> => {
|
): Promise<APITweet> => {
|
||||||
const apiTweet = {} as 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') {
|
if (typeof tweet.core === 'undefined' && typeof tweet.result !== 'undefined') {
|
||||||
tweet = tweet.result;
|
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
|
/* With v2 conversation API we re-add the user object ot the tweet because
|
||||||
|
|
96
src/types/twitterTypes.d.ts
vendored
96
src/types/twitterTypes.d.ts
vendored
|
@ -305,6 +305,48 @@ type GraphQLUser = {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
type GraphQLTweetLegacy = {
|
||||||
|
created_at: string; // "Tue Sep 14 20:00:00 +0000 2021"
|
||||||
|
conversation_id_str: string; // "1674824189176590336"
|
||||||
|
bookmark_count: number; // 0
|
||||||
|
bookmarked: boolean; // false
|
||||||
|
favorite_count: number; // 28
|
||||||
|
full_text: string; // "This is a test tweet"
|
||||||
|
in_reply_to_screen_name: string; // "username"
|
||||||
|
in_reply_to_status_id_str: string; // "1674824189176590336"
|
||||||
|
in_reply_to_user_id_str: string; // "783214"
|
||||||
|
is_quote_status: boolean; // false
|
||||||
|
quote_count: number; // 39
|
||||||
|
quoted_status_id_str: string; // "1674824189176590336"
|
||||||
|
quoted_status_permalink: {
|
||||||
|
url: string; // "https://t.co/aBcDeFgHiJ"
|
||||||
|
expanded: string; // "https://twitter.com/username/status/1674824189176590336"
|
||||||
|
display: string; // "twitter.com/username/statu…"
|
||||||
|
};
|
||||||
|
reply_count: number; // 1
|
||||||
|
retweet_count: number; // 4
|
||||||
|
lang: string; // "en"
|
||||||
|
possibly_sensitive: boolean; // false
|
||||||
|
possibly_sensitive_editable: boolean; // false
|
||||||
|
entities: {
|
||||||
|
media: {
|
||||||
|
display_url: string; // "pic.twitter.com/1X2X3X4X5X"
|
||||||
|
expanded_url: string; // "https://twitter.com/username/status/1674824189176590336/photo/1" "https://twitter.com/username/status/1674824189176590336/video/1"
|
||||||
|
id_str: string; // "1674824189176590336"
|
||||||
|
indices: [number, number]; // [number, number]
|
||||||
|
media_url_https: string; // "https://pbs.twimg.com/media/FAKESCREENSHOT.jpg" With videos appears to be the thumbnail
|
||||||
|
type: string; // "photo" Seems to be photo even with videos
|
||||||
|
}[];
|
||||||
|
user_mentions: unknown[];
|
||||||
|
urls: TcoExpansion[];
|
||||||
|
hashtags: unknown[];
|
||||||
|
symbols: unknown[];
|
||||||
|
};
|
||||||
|
extended_entities: {
|
||||||
|
media: TweetMedia[];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
type GraphQLTweet = {
|
type GraphQLTweet = {
|
||||||
// Workaround
|
// Workaround
|
||||||
result: GraphQLTweet;
|
result: GraphQLTweet;
|
||||||
|
@ -316,6 +358,18 @@ type GraphQLTweet = {
|
||||||
result: GraphQLUser;
|
result: GraphQLUser;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
tweet?: {
|
||||||
|
legacy: GraphQLTweetLegacy;
|
||||||
|
views: {
|
||||||
|
count: string; // "562"
|
||||||
|
state: string; // "EnabledWithCount"
|
||||||
|
};
|
||||||
|
core: {
|
||||||
|
user_results: {
|
||||||
|
result: GraphQLUser;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
};
|
||||||
edit_control: unknown;
|
edit_control: unknown;
|
||||||
edit_perspective: unknown;
|
edit_perspective: unknown;
|
||||||
is_translatable: false;
|
is_translatable: false;
|
||||||
|
@ -325,47 +379,7 @@ type GraphQLTweet = {
|
||||||
};
|
};
|
||||||
source: string; // "<a href=\"https://mobile.twitter.com\" rel=\"nofollow\">Twitter Web App</a>"
|
source: string; // "<a href=\"https://mobile.twitter.com\" rel=\"nofollow\">Twitter Web App</a>"
|
||||||
quoted_status_result?: GraphQLTweet;
|
quoted_status_result?: GraphQLTweet;
|
||||||
legacy: {
|
legacy: GraphQLTweetLegacy;
|
||||||
created_at: string; // "Tue Sep 14 20:00:00 +0000 2021"
|
|
||||||
conversation_id_str: string; // "1674824189176590336"
|
|
||||||
bookmark_count: number; // 0
|
|
||||||
bookmarked: boolean; // false
|
|
||||||
favorite_count: number; // 28
|
|
||||||
full_text: string; // "This is a test tweet"
|
|
||||||
in_reply_to_screen_name: string; // "username"
|
|
||||||
in_reply_to_status_id_str: string; // "1674824189176590336"
|
|
||||||
in_reply_to_user_id_str: string; // "783214"
|
|
||||||
is_quote_status: boolean; // false
|
|
||||||
quote_count: number; // 39
|
|
||||||
quoted_status_id_str: string; // "1674824189176590336"
|
|
||||||
quoted_status_permalink: {
|
|
||||||
url: string; // "https://t.co/aBcDeFgHiJ"
|
|
||||||
expanded: string; // "https://twitter.com/username/status/1674824189176590336"
|
|
||||||
display: string; // "twitter.com/username/statu…"
|
|
||||||
};
|
|
||||||
reply_count: number; // 1
|
|
||||||
retweet_count: number; // 4
|
|
||||||
lang: string; // "en"
|
|
||||||
possibly_sensitive: boolean; // false
|
|
||||||
possibly_sensitive_editable: boolean; // false
|
|
||||||
entities: {
|
|
||||||
media: {
|
|
||||||
display_url: string; // "pic.twitter.com/1X2X3X4X5X"
|
|
||||||
expanded_url: string; // "https://twitter.com/username/status/1674824189176590336/photo/1" "https://twitter.com/username/status/1674824189176590336/video/1"
|
|
||||||
id_str: string; // "1674824189176590336"
|
|
||||||
indices: [number, number]; // [number, number]
|
|
||||||
media_url_https: string; // "https://pbs.twimg.com/media/FAKESCREENSHOT.jpg" With videos appears to be the thumbnail
|
|
||||||
type: string; // "photo" Seems to be photo even with videos
|
|
||||||
}[];
|
|
||||||
user_mentions: unknown[];
|
|
||||||
urls: TcoExpansion[];
|
|
||||||
hashtags: unknown[];
|
|
||||||
symbols: unknown[];
|
|
||||||
};
|
|
||||||
extended_entities: {
|
|
||||||
media: TweetMedia[];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
note_tweet: {
|
note_tweet: {
|
||||||
is_expandable: boolean;
|
is_expandable: boolean;
|
||||||
entity_set: {
|
entity_set: {
|
||||||
|
|
2
src/types/types.d.ts
vendored
2
src/types/types.d.ts
vendored
|
@ -150,7 +150,7 @@ interface APITweet {
|
||||||
replies: number;
|
replies: number;
|
||||||
views?: number | null;
|
views?: number | null;
|
||||||
|
|
||||||
color: string;
|
color: string | null;
|
||||||
|
|
||||||
quote?: APITweet;
|
quote?: APITweet;
|
||||||
poll?: APIPoll;
|
poll?: APIPoll;
|
||||||
|
|
|
@ -14,4 +14,7 @@ analytics_engine_datasets = [
|
||||||
command = "npm run build"
|
command = "npm run build"
|
||||||
|
|
||||||
[miniflare.globals]
|
[miniflare.globals]
|
||||||
TEST = "true" # Will have unicode character errors in headers if not set to true
|
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