Something went wrong. Try again.
cee sky
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576import {Platform} from 'react-native'import {getCalendars} from 'expo-localization'import {AtUri} from '@atproto/syntax'
import {BSKY_FEED_OWNER_DIDS} from '#/lib/constants'import {type UsePreferencesQueryResponse} from '#/state/queries/preferences'import {IS_WEB} from '#/env'import {device} from '#/storage'
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, service geolocation and timezone to Bluesky-owned * feeds. */export function createBskyFeedHeaders(feedUri: string) { return isBlueskyOwnedFeed(feedUri) ? createBskyAppviewHeaders() : {}}
/** * Platform, IP-based service data and the device timezone for Bluesky appview * requests, never GPS. Read at request time so callers pick up service updates * and timezone changes. */export function createBskyAppviewHeaders() { const headers: Record<string, string> = { 'x-atproto-bsky-platform': Platform.OS, }
const geolocation = device.get(['geolocationServiceResponse']) if (geolocation?.countryCode) { headers['x-atproto-bsky-geo-country'] = geolocation.countryCode } if (geolocation?.regionCode) { headers['x-atproto-bsky-geo-region'] = geolocation.regionCode } if (geolocation?.city) { headers['x-atproto-bsky-geo-city'] = encodeURIComponent(geolocation.city) } if (geolocation?.ip) { headers['x-atproto-bsky-geo-ip'] = geolocation.ip }
// IANA name, e.g. America/Sao_Paulo, so ranking can use local time of day const timezone = getCalendars()[0]?.timeZone if (timezone) { headers['x-atproto-bsky-timezone'] = timezone } return headers}
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)}