more fixes

This commit is contained in:
dangered wolf 2023-10-22 17:38:07 -04:00
parent d588946bb3
commit 0fe63e6af5
No known key found for this signature in database
GPG key ID: 41E4D37680ED8B58
4 changed files with 20 additions and 18 deletions

View file

@ -301,8 +301,8 @@ export const statusAPI = async (
if (quoteTweet) { if (quoteTweet) {
apiTweet.quote = (await populateTweetProperties(quoteTweet, res, language)) as APITweet; apiTweet.quote = (await populateTweetProperties(quoteTweet, res, language)) as APITweet;
/* Only override the twitter_card if it's a basic tweet, since media always takes precedence */ /* Only override the twitter_card if it's a basic tweet, since media always takes precedence */
if (apiTweet.twitter_card === 'tweet' && apiTweet.quote !== null) { if (apiTweet.embed_card === 'tweet' && apiTweet.quote !== null) {
apiTweet.twitter_card = apiTweet.quote.twitter_card; apiTweet.embed_card = apiTweet.quote.embed_card;
} }
} }

View file

@ -1,7 +1,7 @@
import { Strings } from '../strings'; import { Strings } from '../strings';
/* Helper for Quote Tweets */ /* Helper for Quote Tweets */
export const handleQuote = (quote: APITweet): string | null => { export const handleQuote = (quote: APIPost): string | null => {
console.log('Quoting status ', quote.id); console.log('Quoting status ', quote.id);
let str = `\n`; let str = `\n`;

View file

@ -6,6 +6,7 @@ import { handleMosaic } from '../../helpers/mosaic';
import { unescapeText } from '../../helpers/utils'; import { unescapeText } from '../../helpers/utils';
import { processMedia } from '../../helpers/media'; import { processMedia } from '../../helpers/media';
import { convertToApiUser } from '../../api/user'; import { convertToApiUser } from '../../api/user';
import { translateTweet } from '../../helpers/translate';
export const buildAPITweet = async ( export const buildAPITweet = async (
tweet: GraphQLTweet, tweet: GraphQLTweet,
@ -135,7 +136,7 @@ export const buildAPITweet = async (
if (quoteTweet) { if (quoteTweet) {
apiTweet.quote = (await buildAPITweet(quoteTweet, language)) as APITweet; apiTweet.quote = (await buildAPITweet(quoteTweet, language)) as APITweet;
/* Only override the embed_card if it's a basic tweet, since media always takes precedence */ /* Only override the embed_card if it's a basic tweet, since media always takes precedence */
if (apiTweet.embed_card === 'tweet'&& apiTweet.quote !== null) { if (apiTweet.embed_card === 'tweet' && apiTweet.quote !== null) {
apiTweet.embed_card = apiTweet.quote.embed_card; apiTweet.embed_card = apiTweet.quote.embed_card;
} }
} }
@ -199,10 +200,6 @@ export const buildAPITweet = async (
} }
} }
/* Workaround: Force player card by default for videos */
/* TypeScript gets confused and re-interprets the type'tweet' instead of 'tweet' | 'summary' | 'summary_large_image' | 'player'
The mediaList however can set it to something else. TODO: Reimplement as enums */
// @ts-expect-error see above comment
if (apiTweet.media?.videos && apiTweet.embed_card !== 'player') { if (apiTweet.media?.videos && apiTweet.embed_card !== 'player') {
apiTweet.embed_card = 'player'; apiTweet.embed_card = 'player';
} }
@ -210,16 +207,16 @@ export const buildAPITweet = async (
/* If a language is specified in API or by user, let's try translating it! */ /* 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) { if (typeof language === 'string' && language.length === 2 && language !== tweet.legacy.lang) {
/* TODO: Reimplement */ /* TODO: Reimplement */
// console.log(`Attempting to translate Tweet to ${language}...`); console.log(`Attempting to translate Tweet to ${language}...`);
// const translateAPI = await translateTweet(tweet, conversation.guestToken || '', language); const translateAPI = await translateTweet(tweet, '', language);
// if (translateAPI !== null && translateAPI?.translation) { if (translateAPI !== null && translateAPI?.translation) {
// apiTweet.translation = { apiTweet.translation = {
// text: unescapeText(linkFixer(tweet.legacy?.entities?.urls, translateAPI?.translation || '')), text: unescapeText(linkFixer(tweet.legacy?.entities?.urls, translateAPI?.translation || '')),
// source_lang: translateAPI?.sourceLanguage || '', source_lang: translateAPI?.sourceLanguage || '',
// target_lang: translateAPI?.destinationLanguage || '', target_lang: translateAPI?.destinationLanguage || '',
// source_lang_en: translateAPI?.localizedSourceLanguage || '' source_lang_en: translateAPI?.localizedSourceLanguage || ''
// }; };
// } }
} }
return apiTweet; return apiTweet;

View file

@ -172,6 +172,11 @@ export const processTwitterThread = async (id: string, processThread = false, re
} }
const post = await buildAPITweet(originalTweet, undefined, false, false); const post = await buildAPITweet(originalTweet, undefined, false, false);
if (post === null) {
return { post: null, thread: null, author: null };
}
const author = post.author; const author = post.author;
/* remove post.author */ /* remove post.author */
// @ts-expect-error lmao // @ts-expect-error lmao