(twitterId: string, domains: string[])
| 1 | /** Pick a video transcode host from `domains` using a stable hash of `id` (Twitter snowflake). */ |
| 2 | export const getVideoTranscodeDomain = (twitterId: string, domains: string[]): string | null => { |
| 3 | if (domains.length === 0) { |
| 4 | return null; |
| 5 | } |
| 6 | |
| 7 | let hash = 0; |
| 8 | for (let i = 0; i < twitterId.length; i++) { |
| 9 | const char = twitterId.charCodeAt(i); |
| 10 | hash = (hash << 5) - hash + char; |
| 11 | } |
| 12 | return domains[Math.abs(hash) % domains.length]; |
| 13 | }; |
| 14 | |
| 15 | /** Pick a Bluesky-oriented transcode host from `domains` using a hash of `blueskyDid`. */ |
| 16 | export const getVideoTranscodeDomainBluesky = ( |
nothing calls this directly
no outgoing calls
no test coverage detected