Add stable ID to discover requests
This commit is contained in:
@@ -3,6 +3,7 @@ import {type LocationGeocodedAddress} from 'expo-location'
|
|||||||
import {IS_ANDROID} from '#/env'
|
import {IS_ANDROID} from '#/env'
|
||||||
import {logger} from '#/geolocation/logger'
|
import {logger} from '#/geolocation/logger'
|
||||||
import {type Geolocation} from '#/geolocation/types'
|
import {type Geolocation} from '#/geolocation/types'
|
||||||
|
import {device} from '#/storage'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Maps full US region names to their short codes.
|
* Maps full US region names to their short codes.
|
||||||
@@ -125,3 +126,21 @@ export function mergeGeolocations(
|
|||||||
})
|
})
|
||||||
return geolocation
|
return geolocation
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get's the merged geolocation as a string in the format of
|
||||||
|
* "countryCode-regionCode", or just "countryCode" if regionCode is not
|
||||||
|
* available.
|
||||||
|
*/
|
||||||
|
export function getGeolocationString() {
|
||||||
|
const geo = device.get(['mergedGeolocation'])
|
||||||
|
if (!geo) return
|
||||||
|
const {countryCode, regionCode} = geo
|
||||||
|
if (countryCode) {
|
||||||
|
if (regionCode) {
|
||||||
|
return `${countryCode}-${regionCode}`
|
||||||
|
} else {
|
||||||
|
return countryCode
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import {
|
|||||||
getAppLanguageAsContentLanguage,
|
getAppLanguageAsContentLanguage,
|
||||||
getContentLanguages,
|
getContentLanguages,
|
||||||
} from '#/state/preferences/languages'
|
} from '#/state/preferences/languages'
|
||||||
|
import {getDeviceId} from '#/analytics/identifiers'
|
||||||
import {type FeedAPI, type FeedAPIResponse} from './types'
|
import {type FeedAPI, type FeedAPIResponse} from './types'
|
||||||
import {createBskyTopicsHeader, isBlueskyOwnedFeed} from './utils'
|
import {createBskyTopicsHeader, isBlueskyOwnedFeed} from './utils'
|
||||||
|
|
||||||
@@ -62,12 +63,15 @@ export class CustomFeedAPI implements FeedAPI {
|
|||||||
limit,
|
limit,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
headers: {
|
headers: isBlueskyOwned
|
||||||
...(isBlueskyOwned
|
? {
|
||||||
? createBskyTopicsHeader(this.userInterests)
|
...createBskyTopicsHeader(this.userInterests),
|
||||||
: {}),
|
'X-Bsky-Stable-Id': getDeviceId(),
|
||||||
'Accept-Language': contentLangs,
|
'Accept-Language': contentLangs,
|
||||||
},
|
}
|
||||||
|
: {
|
||||||
|
'Accept-Language': contentLangs,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
: await loggedOutFetch({...this.params, cursor, limit})
|
: await loggedOutFetch({...this.params, cursor, limit})
|
||||||
|
|||||||
Reference in New Issue
Block a user