mirror of
https://github.com/CompeyDev/fxtwitter-docker.git
synced 2025-04-02 00:50:57 +01:00
Change GIF_TRANSCODE_DOMAIN to GIF_TRANSCODE_DOMAIN_LIST
This commit is contained in:
parent
174cc65782
commit
c1ef1f3ba7
5 changed files with 22 additions and 6 deletions
|
@ -15,4 +15,4 @@ SENTRY_DSN = ""
|
|||
SENTRY_AUTH_TOKEN = ""
|
||||
SENTRY_ORG = ""
|
||||
SENTRY_PROJECT = ""
|
||||
GIF_TRANSCODE_DOMAIN = "gif.fxtwitter.com"
|
||||
GIF_TRANSCODE_DOMAIN_LIST = "gif.fxtwitter.com"
|
|
@ -46,7 +46,7 @@ let envVariables = [
|
|||
'MOSAIC_DOMAIN_LIST',
|
||||
'API_HOST_LIST',
|
||||
'SENTRY_DSN',
|
||||
'GIF_TRANSCODE_DOMAIN'
|
||||
'GIF_TRANSCODE_DOMAIN_LIST'
|
||||
];
|
||||
|
||||
// Create defines for all environment variables
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
"REDIRECT_URL": "https://github.com/FixTweet/FxTwitter",
|
||||
"EMBED_URL": "https://github.com/FixTweet/FxTwitter",
|
||||
"RELEASE_NAME": "fixtweet-test",
|
||||
"GIF_TRANSCODE_DOMAIN": "gif.fxtwitter.com",
|
||||
"GIF_TRANSCODE_DOMAIN_LIST": "gif.fxtwitter.com",
|
||||
"SENTRY_DSN": null
|
||||
},
|
||||
"testRegex": "/test/.*\\.test\\.ts$",
|
||||
|
|
|
@ -3,6 +3,22 @@ import { Constants } from '../constants';
|
|||
import { Experiment, experimentCheck } from '../experiments';
|
||||
import { handleQuote } from '../helpers/quote';
|
||||
|
||||
const getGIFTranscodeDomain = (twitterId: string): string | null => {
|
||||
const gifTranscoderList = Constants.GIF_TRANSCODE_DOMAIN_LIST;
|
||||
|
||||
if (gifTranscoderList.length === 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
let hash = 0;
|
||||
for (let i = 0; i < twitterId.length; i++) {
|
||||
const char = twitterId.charCodeAt(i);
|
||||
hash = (hash << 5) - hash + char;
|
||||
}
|
||||
return gifTranscoderList[Math.abs(hash) % gifTranscoderList.length];
|
||||
};
|
||||
|
||||
|
||||
export const renderVideo = (
|
||||
properties: RenderProperties,
|
||||
video: APIVideo
|
||||
|
@ -53,13 +69,13 @@ export const renderVideo = (
|
|||
let url = video.url;
|
||||
|
||||
if (
|
||||
experimentCheck(Experiment.TRANSCODE_GIFS, !!Constants.GIF_TRANSCODE_DOMAIN) &&
|
||||
experimentCheck(Experiment.TRANSCODE_GIFS, !!Constants.GIF_TRANSCODE_DOMAIN_LIST) &&
|
||||
!userAgent?.includes('Telegram') &&
|
||||
video.type === 'gif'
|
||||
) {
|
||||
url = video.url.replace(
|
||||
Constants.TWITTER_VIDEO_BASE,
|
||||
`https://${Constants.GIF_TRANSCODE_DOMAIN}`
|
||||
`https://${getGIFTranscodeDomain(status.id)}`
|
||||
);
|
||||
console.log('We passed checks for transcoding GIFs, feeding embed url', url);
|
||||
}
|
||||
|
|
2
src/types/env.d.ts
vendored
2
src/types/env.d.ts
vendored
|
@ -11,7 +11,7 @@ declare const EMBED_URL: string;
|
|||
declare const REDIRECT_URL: string;
|
||||
declare const MOSAIC_DOMAIN_LIST: string;
|
||||
declare const API_HOST_LIST: string;
|
||||
declare const GIF_TRANSCODE_DOMAIN: string;
|
||||
declare const GIF_TRANSCODE_DOMAIN_LIST: string;
|
||||
|
||||
declare const SENTRY_DSN: string;
|
||||
declare const RELEASE_NAME: string;
|
||||
|
|
Loading…
Add table
Reference in a new issue