Something went wrong. Try again.
Mirror — see github.com/blacksky-algorithms/blacksky.community
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556import {Platform} from 'react-native'import {type Service} from '@atproto/lex'import {AtUri} from '@atproto/syntax'
import {BSKY_FEED_OWNER_DIDS} from '#/lib/constants'import {type UsePreferencesQueryResponse} from '#/state/queries/preferences'import {ALT_PROXY_DID, IS_WEB} from '#/env'
const TRENDING_FEED_DID = 'did:plc:qrz3lhbyuxbeilrc6nekdqme'const PROXY_TO_BLUESKY: Service = `${ALT_PROXY_DID}#bsky_appview`
let debugTopics = ''if (IS_WEB && typeof window !== 'undefined') { const params = new URLSearchParams(window.location.search) debugTopics = params.get('debug_topics') ?? ''}
export function createBskyTopicsHeader(userInterests?: string) { return { 'x-atproto-bsky-topics': debugTopics || userInterests || '', }}
/** Only disclose platform and service geolocation to Bluesky-owned feeds. */export function createBskyFeedHeaders(feedUri: string) { return isBlueskyOwnedFeed(feedUri) ? createBskyAppviewHeaders() : {}}
/** Platform data for Bluesky appview requests. */export function createBskyAppviewHeaders() { return {'x-atproto-bsky-platform': Platform.OS}}
export function aggregateUserInterests( preferences?: UsePreferencesQueryResponse,) { const tags = preferences?.interests.tags ?? [] const updatedAt = preferences?.interests.updatedAt
const interests = tags.join(',') return updatedAt ? `${interests};${updatedAt}` : interests}
export function isBlueskyOwnedFeed(feedUri: string) { const uri = new AtUri(feedUri) return BSKY_FEED_OWNER_DIDS.includes(uri.host)}
/** Call options that send a feed's requests to the appview that can serve it. */export function getProxyOptsForFeed(feedUri: string): {service?: Service} { if (feedUri.includes(TRENDING_FEED_DID)) { return {service: PROXY_TO_BLUESKY} } return {}}