mirror of
https://github.com/CompeyDev/fxtwitter-docker.git
synced 2025-04-10 21:10:54 +01:00
Add text-only embeds (Implements #133)
This commit is contained in:
parent
5dfd74ce99
commit
832c3c243a
8 changed files with 16 additions and 3 deletions
|
@ -1,6 +1,7 @@
|
||||||
BRANDING_NAME = "FixTweet"
|
BRANDING_NAME = "FixTweet"
|
||||||
BRANDING_NAME_DISCORD = "FixTweet - Embed videos, polls & more!"
|
BRANDING_NAME_DISCORD = "FixTweet - Embed videos, polls & more!"
|
||||||
DIRECT_MEDIA_DOMAINS = "d.fxtwitter.com,dl.fxtwitter.com,d.pxtwitter.com,d.twittpr.com,dl.pxtwitter.com,dl.twittpr.com"
|
DIRECT_MEDIA_DOMAINS = "d.fxtwitter.com,dl.fxtwitter.com,d.pxtwitter.com,d.twittpr.com,dl.pxtwitter.com,dl.twittpr.com"
|
||||||
|
TEXT_ONLY_DOMAINS = "t.fxtwitter.com,t.twittpr.com"
|
||||||
DEPRECATED_DOMAIN_LIST = "pxtwitter.com,www.pxtwitter.com"
|
DEPRECATED_DOMAIN_LIST = "pxtwitter.com,www.pxtwitter.com"
|
||||||
DEPRECATED_DOMAIN_EPOCH = "1559320000000000000"
|
DEPRECATED_DOMAIN_EPOCH = "1559320000000000000"
|
||||||
MOSAIC_DOMAIN_LIST = "mosaic.fxtwitter.com"
|
MOSAIC_DOMAIN_LIST = "mosaic.fxtwitter.com"
|
||||||
|
@ -10,5 +11,5 @@ REDIRECT_URL = "https://github.com/FixTweet/FixTweet"
|
||||||
EMBED_URL = "https://github.com/FixTweet/FixTweet"
|
EMBED_URL = "https://github.com/FixTweet/FixTweet"
|
||||||
SENTRY_DSN = ""
|
SENTRY_DSN = ""
|
||||||
SENTRY_AUTH_TOKEN = ""
|
SENTRY_AUTH_TOKEN = ""
|
||||||
SENTRY_ORG = "dangeredwolf"
|
SENTRY_ORG = ""
|
||||||
SENTRY_PROJECT = "fixtweet"
|
SENTRY_PROJECT = ""
|
|
@ -6,6 +6,7 @@
|
||||||
"globals": {
|
"globals": {
|
||||||
"BRANDING_NAME": "FixTweet",
|
"BRANDING_NAME": "FixTweet",
|
||||||
"BRANDING_NAME_DISCORD": "FixTweetBrandingDiscord",
|
"BRANDING_NAME_DISCORD": "FixTweetBrandingDiscord",
|
||||||
|
"TEXT_ONLY_DOMAINS": "t.fxtwitter.com,t.twittpr.com",
|
||||||
"DIRECT_MEDIA_DOMAINS": "d.fxtwitter.com,dl.fxtwitter.com",
|
"DIRECT_MEDIA_DOMAINS": "d.fxtwitter.com,dl.fxtwitter.com",
|
||||||
"MOSAIC_DOMAIN_LIST": "mosaic.fxtwitter.com",
|
"MOSAIC_DOMAIN_LIST": "mosaic.fxtwitter.com",
|
||||||
"DEPRECATED_DOMAIN_LIST": "pxtwitter.com,www.pxtwitter.com",
|
"DEPRECATED_DOMAIN_LIST": "pxtwitter.com,www.pxtwitter.com",
|
||||||
|
|
|
@ -3,6 +3,7 @@ export const Constants = {
|
||||||
BRANDING_NAME: BRANDING_NAME,
|
BRANDING_NAME: BRANDING_NAME,
|
||||||
BRANDING_NAME_DISCORD: BRANDING_NAME_DISCORD,
|
BRANDING_NAME_DISCORD: BRANDING_NAME_DISCORD,
|
||||||
DIRECT_MEDIA_DOMAINS: DIRECT_MEDIA_DOMAINS.split(','),
|
DIRECT_MEDIA_DOMAINS: DIRECT_MEDIA_DOMAINS.split(','),
|
||||||
|
TEXT_ONLY_DOMAINS: TEXT_ONLY_DOMAINS.split(','),
|
||||||
DEPRECATED_DOMAIN_LIST: DEPRECATED_DOMAIN_LIST.split(','),
|
DEPRECATED_DOMAIN_LIST: DEPRECATED_DOMAIN_LIST.split(','),
|
||||||
DEPRECATED_DOMAIN_EPOCH: BigInt(DEPRECATED_DOMAIN_EPOCH),
|
DEPRECATED_DOMAIN_EPOCH: BigInt(DEPRECATED_DOMAIN_EPOCH),
|
||||||
MOSAIC_DOMAIN_LIST: MOSAIC_DOMAIN_LIST.split(','),
|
MOSAIC_DOMAIN_LIST: MOSAIC_DOMAIN_LIST.split(','),
|
||||||
|
|
|
@ -48,6 +48,9 @@ const statusRequest = async (
|
||||||
} else if (Constants.DIRECT_MEDIA_DOMAINS.includes(url.hostname)) {
|
} else if (Constants.DIRECT_MEDIA_DOMAINS.includes(url.hostname)) {
|
||||||
console.log('Direct media request by domain');
|
console.log('Direct media request by domain');
|
||||||
flags.direct = true;
|
flags.direct = true;
|
||||||
|
} else if (Constants.TEXT_ONLY_DOMAINS.includes(url.hostname)) {
|
||||||
|
console.log('Text-only embed request');
|
||||||
|
flags.textOnly = true;
|
||||||
} else if (prefix === 'dl' || prefix === 'dir') {
|
} else if (prefix === 'dl' || prefix === 'dir') {
|
||||||
console.log('Direct media request by path prefix');
|
console.log('Direct media request by path prefix');
|
||||||
flags.direct = true;
|
flags.direct = true;
|
||||||
|
|
|
@ -74,6 +74,10 @@ export const handleStatus = async (
|
||||||
tweet.twitter_card = tweet.quote.twitter_card;
|
tweet.twitter_card = tweet.quote.twitter_card;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (flags?.textOnly) {
|
||||||
|
tweet.media = undefined;
|
||||||
|
}
|
||||||
|
|
||||||
/* At this point, we know we're going to have to create a
|
/* At this point, we know we're going to have to create a
|
||||||
regular embed because it's not an API or direct media request */
|
regular embed because it's not an API or direct media request */
|
||||||
|
|
||||||
|
@ -292,7 +296,7 @@ export const handleStatus = async (
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If we have no media to display, instead we'll display the user profile picture in the embed */
|
/* If we have no media to display, instead we'll display the user profile picture in the embed */
|
||||||
if (!tweet.media?.video && !tweet.media?.photos) {
|
if (!tweet.media?.video && !tweet.media?.photos && !flags?.textOnly) {
|
||||||
headers.push(
|
headers.push(
|
||||||
/* Use a slightly higher resolution image for profile pics */
|
/* Use a slightly higher resolution image for profile pics */
|
||||||
`<meta property="og:image" content="${tweet.author.avatar_url?.replace(
|
`<meta property="og:image" content="${tweet.author.avatar_url?.replace(
|
||||||
|
|
1
src/types/env.d.ts
vendored
1
src/types/env.d.ts
vendored
|
@ -1,6 +1,7 @@
|
||||||
declare const BRANDING_NAME: string;
|
declare const BRANDING_NAME: string;
|
||||||
declare const BRANDING_NAME_DISCORD: string;
|
declare const BRANDING_NAME_DISCORD: string;
|
||||||
declare const DIRECT_MEDIA_DOMAINS: string;
|
declare const DIRECT_MEDIA_DOMAINS: string;
|
||||||
|
declare const TEXT_ONLY_DOMAINS: string;
|
||||||
declare const DEPRECATED_DOMAIN_LIST: string;
|
declare const DEPRECATED_DOMAIN_LIST: string;
|
||||||
declare const DEPRECATED_DOMAIN_EPOCH: string;
|
declare const DEPRECATED_DOMAIN_EPOCH: string;
|
||||||
declare const HOST_URL: string;
|
declare const HOST_URL: string;
|
||||||
|
|
1
src/types/types.d.ts
vendored
1
src/types/types.d.ts
vendored
|
@ -6,6 +6,7 @@ type InputFlags = {
|
||||||
direct?: boolean;
|
direct?: boolean;
|
||||||
api?: boolean;
|
api?: boolean;
|
||||||
deprecated?: boolean;
|
deprecated?: boolean;
|
||||||
|
textOnly?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
interface StatusResponse {
|
interface StatusResponse {
|
||||||
|
|
|
@ -21,6 +21,7 @@ let envVariables = [
|
||||||
'BRANDING_NAME',
|
'BRANDING_NAME',
|
||||||
'BRANDING_NAME_DISCORD',
|
'BRANDING_NAME_DISCORD',
|
||||||
'DIRECT_MEDIA_DOMAINS',
|
'DIRECT_MEDIA_DOMAINS',
|
||||||
|
'TEXT_ONLY_DOMAINS',
|
||||||
'HOST_URL',
|
'HOST_URL',
|
||||||
'REDIRECT_URL',
|
'REDIRECT_URL',
|
||||||
'EMBED_URL',
|
'EMBED_URL',
|
||||||
|
|
Loading…
Add table
Reference in a new issue