Patch quirky paths for translation (#435 regression)

This commit is contained in:
dangered wolf 2023-11-12 20:18:13 -05:00
parent d682b07fa5
commit e1c3d7d544
No known key found for this signature in database
GPG key ID: 41E4D37680ED8B58
3 changed files with 45 additions and 15 deletions

View file

@ -194,6 +194,8 @@ export const handleStatus = async (
}
}
console.log('translation', tweet.translation)
/* This Tweet has a translation attached to it, so we'll render it. */
if (tweet.translation) {
const { translation } = tweet;

View file

@ -29,40 +29,69 @@ export const getBaseRedirectUrl = (c: Context) => {
/* Workaround for some dumb maybe-build time issue where statusRequest isn't ready or something because none of these trigger*/
const tweetRequest = async (c: Context) => await statusRequest(c);
const _profileRequest = async (c: Context) => await profileRequest(c);
/* How can hono not handle trailing slashes? This is so stupid,
twitter.get('/:endpoint{status(es)?}/:id{.+}/:language{[a-z]+}?', tweetRequest);
twitter.get('/:endpoint{status(es)?}/:id{.+}/', tweetRequest);
serious TODO: Figure out how to make this not stupid. */
twitter.get('/:endpoint{status(es)?}/:id', tweetRequest);
twitter.get('/:endpoint{status(es)?}/:id/', tweetRequest);
twitter.get('/:endpoint{status(es)?}/:id/:language/', tweetRequest);
twitter.get('/:endpoint{status(es)?}/:id/:language', tweetRequest);
twitter.get(
'/:handle{[0-9a-zA-Z_]+}/:endpoint{status(es)?}/:id{.+}/:language{[a-z]+}?',
tweetRequest
);
twitter.get('/:handle{[0-9a-zA-Z_]+}/:endpoint{status(es)?}/:id{.+}/', tweetRequest);
twitter.get(
'/:prefix{(dir|dl)}/:handle{[0-9a-zA-Z_]+}/:endpoint{status(es)?}/:id{.+}/:language{[a-z]+}?',
'/:handle{[0-9a-zA-Z_]+}/:endpoint{status(es)?}/:id/:language',
tweetRequest
);
twitter.get(
'/:prefix{(dir|dl)}/:handle{[0-9a-zA-Z_]+}/:endpoint{status(es)?}/:id{.+}/',
'/:handle{[0-9a-zA-Z_]+}/:endpoint{status(es)?}/:id/:language/',
tweetRequest
);
twitter.get('/:handle{[0-9a-zA-Z_]+}/:endpoint{status(es)?}/:id', tweetRequest);
twitter.get('/:handle{[0-9a-zA-Z_]+}/:endpoint{status(es)?}/:id/', tweetRequest);
twitter.get(
'/:prefix{(dir|dl)}/:handle{[0-9a-zA-Z_]+}/:endpoint{status(es)?}/:id/:language',
tweetRequest
);
twitter.get(
'/:handle{[0-9a-zA-Z_]+}/:endpoint{status(es)?}/:id{.+}/:mediaType{(photos?|videos?)}/:mediaNumber{[1-4]}/',
'/:prefix{(dir|dl)}/:handle{[0-9a-zA-Z_]+}/:endpoint{status(es)?}/:id/:language/',
tweetRequest
);
twitter.get(
'/:handle{[0-9a-zA-Z_]+}/:endpoint{status(es)?}/:id{.+}/:mediaType{(photos?|videos?)}/:mediaNumber{[1-4]}/:language{[a-z]+}?',
'/:prefix{(dir|dl)}/:handle{[0-9a-zA-Z_]+}/:endpoint{status(es)?}/:id',
tweetRequest
);
twitter.get(
'/:handle{[0-9a-zA-Z_]+}/:endpoint{status(es)?}/:id{.+}/:mediaType{(photos?|videos?)}/:mediaNumber{[1-4]}/',
'/:prefix{(dir|dl)}/:handle{[0-9a-zA-Z_]+}/:endpoint{status(es)?}/:id/',
tweetRequest
);
twitter.get(
'/:prefix{(dir|dl)}/:handle{[0-9a-zA-Z_]+}/:endpoint{status(es)?}/:id{.+}/:mediaType{(photos?|videos?)}/:mediaNumber{[1-4]}/:language{[a-z]+}?',
'/:handle{[0-9a-zA-Z_]+}/:endpoint{status(es)?}/:id/:mediaType{(photos?|videos?)}/:mediaNumber{[1-4]}',
tweetRequest
);
twitter.get(
'/:prefix{(dir|dl)}/:handle{[0-9a-zA-Z_]+}/:endpoint{status(es)?}/:id{.+}/:mediaType{(photos?|videos?)}/:mediaNumber{[1-4]}/',
'/:handle{[0-9a-zA-Z_]+}/:endpoint{status(es)?}/:id/:mediaType{(photos?|videos?)}/:mediaNumber{[1-4]}/',
tweetRequest
);
twitter.get(
'/:handle{[0-9a-zA-Z_]+}/:endpoint{status(es)?}/:id/:mediaType{(photos?|videos?)}/:mediaNumber{[1-4]}/:language',
tweetRequest
);
twitter.get(
'/:handle{[0-9a-zA-Z_]+}/:endpoint{status(es)?}/:id/:mediaType{(photos?|videos?)}/:mediaNumber{[1-4]}/:language/',
tweetRequest
);
twitter.get(
'/:prefix{(dir|dl)}/:handle{[0-9a-zA-Z_]+}/:endpoint{status(es)?}/:id/:mediaType{(photos?|videos?)}/:mediaNumber{[1-4]}',
tweetRequest
);
twitter.get(
'/:prefix{(dir|dl)}/:handle{[0-9a-zA-Z_]+}/:endpoint{status(es)?}/:id/:mediaType{(photos?|videos?)}/:mediaNumber{[1-4]}/',
tweetRequest
);
twitter.get(
'/:prefix{(dir|dl)}/:handle{[0-9a-zA-Z_]+}/:endpoint{status(es)?}/:id/:mediaType{(photos?|videos?)}/:mediaNumber{[1-4]}/:language',
tweetRequest
);
twitter.get(
'/:prefix{(dir|dl)}/:handle{[0-9a-zA-Z_]+}/:endpoint{status(es)?}/:id/:mediaType{(photos?|videos?)}/:mediaNumber{[1-4]}/:language/',
tweetRequest
);

View file

@ -50,7 +50,6 @@ export const profileRequest = async (c: Context) => {
console.log('Bypass bot check');
}
/* This throws the necessary data to handleStatus (in status.ts) */
const profileResponse = await handleProfile(c, username, flags);
/* Check for custom redirect */