Translation workaround

This commit is contained in:
dangered wolf 2023-11-02 05:03:37 -04:00
parent 54dc797247
commit 0384e5746e
No known key found for this signature in database
GPG key ID: 41E4D37680ED8B58
3 changed files with 9 additions and 4 deletions

View file

@ -45,7 +45,7 @@ export const handleStatus = async (
status,
fetchWithThreads,
request,
undefined,
language,
flags?.api ?? false
);

View file

@ -272,13 +272,16 @@ export const constructTwitterThread = async (
language: string | undefined,
legacyAPI = false
): Promise<SocialThread> => {
console.log('legacyAPI', legacyAPI);
console.log('language', language);
let response: TweetDetailResult | TweetResultsByRestIdResult | null = null;
let post: APITweet;
/* We can use TweetDetail on elongator accounts to increase per-account rate limit.
We also use TweetDetail to process threads (WIP) */
if (typeof TwitterProxy !== 'undefined' && (experimentCheck(Experiment.TWEET_DETAIL_API) || processThread)) {
We also use TweetDetail to process threads (WIP)
Also - dirty hack. Right now, TweetDetails requests aren't working with language and I haven't figured out why.
I'll figure out why eventually, but for now just don't use TweetDetail for this. */
if (typeof TwitterProxy !== 'undefined' && !language && (experimentCheck(Experiment.TWEET_DETAIL_API) || processThread)) {
console.log('Using TweetDetail for request...');
response = (await fetchTweetDetail(id, request.event)) as TweetDetailResult;

View file

@ -230,6 +230,8 @@ export const buildAPITweet = async (
apiTweet.embed_card = 'player';
}
console.log('language?', language)
/* If a language is specified in API or by user, let's try translating it! */
if (typeof language === 'string' && language.length === 2 && language !== tweet.legacy.lang) {
console.log(`Attempting to translate Tweet to ${language}...`);