Run prettier

This commit is contained in:
dangered wolf 2022-08-13 00:45:12 -04:00
parent 50be0d6394
commit c4b908aec1
No known key found for this signature in database
GPG key ID: 41E4D37680ED8B58
6 changed files with 45 additions and 31 deletions

View file

@ -11,6 +11,7 @@
### Add `fx` before your Twitter link to make it `fxtwitter.com`
### In a hurry? On Discord, send a Twitter link and type `s/e/p` to make `twittpr.com`.
<img src="https://cdn.discordapp.com/attachments/165560751363325952/1006346785985417307/fixtweet.webp">
## Embed Videos

View file

@ -176,7 +176,11 @@ export const cacheWrapper = async (
});
}
if (cacheUrl.pathname.startsWith('/api/') || cacheUrl.pathname.startsWith('/other/') || cacheUrl.pathname.startsWith('/info/')) {
if (
cacheUrl.pathname.startsWith('/api/') ||
cacheUrl.pathname.startsWith('/other/') ||
cacheUrl.pathname.startsWith('/info/')
) {
return new Response(Strings.TWITFIX_API_SUNSET, {
headers: Constants.RESPONSE_HEADERS,
status: 404

View file

@ -80,7 +80,9 @@ export const handleStatus = async (
];
if (userAgent?.indexOf('Telegram') === -1) {
headers.push(`<meta http-equiv="refresh" content="0;url=https://twitter.com/${tweet.author.screen_name}/status/${tweet.id}"/>`)
headers.push(
`<meta http-equiv="refresh" content="0;url=https://twitter.com/${tweet.author.screen_name}/status/${tweet.id}"/>`
);
}
if (tweet.translation) {
@ -139,10 +141,7 @@ export const handleStatus = async (
const { photos } = tweet.media;
let photo = photos[(mediaNumber || 1) - 1];
if (
typeof mediaNumber !== 'number' &&
tweet.media.mosaic
) {
if (typeof mediaNumber !== 'number' && tweet.media.mosaic) {
photo = {
url:
userAgent?.indexOf('Telegram') === -1

View file

@ -87,5 +87,7 @@ This is caused by Twitter API downtime or a new bug. Try again in a little while
ERROR_PRIVATE: `I can't embed Tweets from private accounts, sorry about that :(`,
ERROR_TWEET_NOT_FOUND: `Sorry, that Tweet doesn't exist :(`,
ERROR_UNKNOWN: `Unknown error occurred, sorry about that :(`,
TWITFIX_API_SUNSET: `The original TwitFix API has been sunset. To learn more about the FixTweet API, check out <a href="https://${API_HOST_LIST.split(',')[0]}">${API_HOST_LIST.split(',')[0]}</a>`,
TWITFIX_API_SUNSET: `The original TwitFix API has been sunset. To learn more about the FixTweet API, check out <a href="https://${
API_HOST_LIST.split(',')[0]
}">${API_HOST_LIST.split(',')[0]}</a>`
};

View file

@ -97,7 +97,9 @@ test('API fetch video Tweet', async () => {
expect(tweet).toBeTruthy();
expect(tweet.url).toEqual('https://twitter.com/Twitter/status/854416760933556224');
expect(tweet.id).toEqual('854416760933556224');
expect(tweet.text).toEqual('Get the sauces ready, #NuggsForCarter has 3 million+ Retweets.');
expect(tweet.text).toEqual(
'Get the sauces ready, #NuggsForCarter has 3 million+ Retweets.'
);
expect(tweet.author.screen_name?.toLowerCase()).toEqual('twitter');
expect(tweet.author.name).toBeTruthy();
expect(tweet.author.avatar_url).toBeTruthy();
@ -113,15 +115,16 @@ test('API fetch video Tweet', async () => {
expect(tweet.replying_to).toBeNull();
expect(tweet.media?.video).toBeTruthy();
const video = tweet.media?.video as APIVideo;
expect(video.url).toEqual('https://video.twimg.com/amplify_video/854415175776059393/vid/720x720/dNEi0crU-jA4mTtr.mp4');
expect(video.url).toEqual(
'https://video.twimg.com/amplify_video/854415175776059393/vid/720x720/dNEi0crU-jA4mTtr.mp4'
);
expect(video.thumbnail_url).toEqual('https://pbs.twimg.com/media/C9t-btLVoAEqZI1.jpg');
expect(video.width).toEqual(1596);
expect(video.height).toEqual(1600);
expect(video.format).toEqual("video/mp4");
expect(video.type).toEqual("video");
expect(video.format).toEqual('video/mp4');
expect(video.type).toEqual('video');
});
test('API fetch multi-photo Tweet', async () => {
const result = await cacheWrapper(
new Request('https://api.fxtwitter.com/dangeredwolf/status/1554870933449482240', {
@ -137,7 +140,9 @@ test('API fetch multi-photo Tweet', async () => {
const tweet = response.tweet as APITweet;
expect(tweet).toBeTruthy();
expect(tweet.url).toEqual('https://twitter.com/dangeredwolf/status/1554870933449482240');
expect(tweet.url).toEqual(
'https://twitter.com/dangeredwolf/status/1554870933449482240'
);
expect(tweet.id).toEqual('1554870933449482240');
expect(tweet.text).toEqual('4 photos');
expect(tweet.author.screen_name?.toLowerCase()).toEqual('dangeredwolf');
@ -167,7 +172,10 @@ test('API fetch multi-photo Tweet', async () => {
const mosaic = tweet.media?.mosaic as APIMosaicPhoto;
expect(mosaic.width).toEqual(1610);
expect(mosaic.height).toEqual(846);
expect(mosaic.formats?.jpeg).toEqual('https://mosaic.fxtwitter.com/jpeg/1554870933449482240/FZQCeMmXwAAOJTt/FZQCl-lWIAMtoW9/FZQCsQPX0AIbY6H/FZQCxmLXEAMST4q');
expect(mosaic.formats?.webp).toEqual('https://mosaic.fxtwitter.com/webp/1554870933449482240/FZQCeMmXwAAOJTt/FZQCl-lWIAMtoW9/FZQCsQPX0AIbY6H/FZQCxmLXEAMST4q');
expect(mosaic.formats?.jpeg).toEqual(
'https://mosaic.fxtwitter.com/jpeg/1554870933449482240/FZQCeMmXwAAOJTt/FZQCl-lWIAMtoW9/FZQCsQPX0AIbY6H/FZQCxmLXEAMST4q'
);
expect(mosaic.formats?.webp).toEqual(
'https://mosaic.fxtwitter.com/webp/1554870933449482240/FZQCeMmXwAAOJTt/FZQCl-lWIAMtoW9/FZQCsQPX0AIbY6H/FZQCxmLXEAMST4q'
);
});