migrate the signup and onboarding profile writes to sdk actions

The post-signup and onboarding writes (setPersonalDetails, upsertProfile,
overwriteSavedFeeds, setInterestsPref) move onto sdk actions over the pds
client, and the starter-pack and contact-import reads move to the lex
clients. Every upsertProfile call now writes a lex blob directly, so the
toLegacyBlobRef bridge has no remaining callers and is deleted.
This commit is contained in:
Samuel Newman
2026-08-04 01:38:37 +03:00
parent 926abd0566
commit a40c199523
6 changed files with 92 additions and 117 deletions
+1 -1
View File
@@ -61,7 +61,7 @@ export function useAllListMembersQuery(uri?: string) {
export async function getAllListMembers(client: Client, uri: string) {
let hasMore = true
let cursor: string | undefined
const listItems: AppBskyGraphDefs.ListItemView[] = []
const listItems: app.bsky.graph.defs.ListItemView[] = []
// We want to cap this at 6 pages, just for anything weird happening with the api
let i = 0
while (hasMore && i < 6) {
+23 -20
View File
@@ -1,7 +1,12 @@
import {type AppBskyActorProfile, type Un$Typed} from '@atproto/api'
import {TID} from '@atproto/common-web'
import {type Client} from '@atproto/lex'
import {PasswordSession} from '@atproto/lex-password-session'
import {toDatetimeString} from '@atproto/syntax'
import {
overwriteSavedFeeds,
setPersonalDetails,
upsertProfile,
} from '@bsky.app/sdk'
import {networkRetry} from '#/lib/async/retry'
import {
@@ -21,7 +26,7 @@ import {
} from '#/ageAssurance/data'
import {unsafeGetAndComputeAgeAssurance} from '#/ageAssurance/state'
import {features} from '#/analytics'
import {type BskyAppAgent} from './bridge-agent'
import {type app} from '#/lexicons'
import {agentToPdsClient} from './clients'
import {configureModerationForAccount} from './moderation'
import {
@@ -88,7 +93,7 @@ export async function createSessionBundleAndCreateAccount(
const gates = features.refresh({strategy: 'prefer-fresh-gates'})
configureModerationForAccount(bundle.agent, earlyAccount)
const createdAt = new Date().toISOString()
const createdAt = toDatetimeString(new Date())
const birthdate = birthDate.toISOString()
/*
@@ -104,18 +109,16 @@ export async function createSessionBundleAndCreateAccount(
const aa = prefetchAgeAssuranceServerData({agent: bundle.agent})
const isProd = Boolean(IS_PROD_SERVICE(service))
// Post-signup writes all target the account's own repo and actor store.
const pdsClient = agentToPdsClient(bundle.agent)
const postSignupTasks: Promise<unknown>[] = [
savePersonalDetails(bundle.agent, birthdate),
initializeProfile(bundle.agent, {handle, createdAt, isProd}),
savePersonalDetails(pdsClient, birthDate),
initializeProfile(pdsClient, {handle, createdAt, isProd}),
]
if (isProd) {
postSignupTasks.push(
initializeSavedFeeds(bundle.agent),
restrictChatAfterAgeAssurance(
aa,
agentToPdsClient(bundle.agent),
earlyAccount.did,
),
initializeSavedFeeds(pdsClient),
restrictChatAfterAgeAssurance(aa, pdsClient, earlyAccount.did),
)
}
// Post-signup writes are not required to enter onboarding.
@@ -170,41 +173,41 @@ function snapshotNewAccount(
}
}
function savePersonalDetails(agent: BskyAppAgent, birthDate: string) {
function savePersonalDetails(client: Client, birthDate: Date) {
return retryPostSignupTask('set birthDate', 3, () =>
agent.setPersonalDetails({birthDate}),
client.call(setPersonalDetails, {birthDate}),
)
}
function initializeProfile(
agent: BskyAppAgent,
client: Client,
{
handle,
createdAt,
isProd,
}: {
handle: string
createdAt: string
createdAt: ReturnType<typeof toDatetimeString>
isProd: boolean
},
) {
return retryPostSignupTask('set initial profile', 3, () =>
agent.upsertProfile(prev => {
const next: Un$Typed<AppBskyActorProfile.Record> = prev || {}
client.call(upsertProfile, prev => {
const next: Partial<app.bsky.actor.profile.Main> = prev || {}
if (isProd) {
next.displayName = handle
next.createdAt = createdAt
} else {
next.createdAt = prev?.createdAt || new Date().toISOString()
next.createdAt = prev?.createdAt || toDatetimeString(new Date())
}
return next
}),
)
}
function initializeSavedFeeds(agent: BskyAppAgent) {
function initializeSavedFeeds(client: Client) {
return retryPostSignupTask('set initial feeds', 1, () =>
agent.overwriteSavedFeeds([
client.call(overwriteSavedFeeds, [
{...DISCOVER_SAVED_FEED, id: TID.nextStr()},
{...TIMELINE_SAVED_FEED, id: TID.nextStr()},
]),