This repository has no description
0

Configure Feed

Select the types of activity you want to include in your feed.

appview/oauth: ensure profile record when onboarding is skipped too

if a user skips onboarding at step 0, empty profile records were not
created.

Signed-off-by: oppiliappan <me@oppi.li>

author
oppiliappan
committer
Tangled
date (Jul 22, 2026, 1:20 PM +0300) commit 7727c9ca parent 25f1f56b change-id upvkwlzu
+48
+48
appview/oauth/handler.go
··· 15 15 comatproto "github.com/bluesky-social/indigo/api/atproto" 16 16 "github.com/bluesky-social/indigo/atproto/auth/oauth" 17 17 "github.com/bluesky-social/indigo/atproto/syntax" 18 + lexutil "github.com/bluesky-social/indigo/lex/util" 18 19 xrpc "github.com/bluesky-social/indigo/xrpc" 19 20 "github.com/go-chi/chi/v5" 20 21 "github.com/posthog/posthog-go" ··· 114 115 } 115 116 } 116 117 } 118 + 119 + o.ensureProfileRecord(sessData.AccountDID, sessData.SessionID) 117 120 118 121 go o.addToDefaultKnot(sessData.AccountDID) 119 122 go o.addToDefaultSpindle(sessData.AccountDID.String()) ··· 520 523 } else { 521 524 l.Info("autoClaimTnglShDomain: claimed domain", "domain", handle) 522 525 } 526 + } 527 + 528 + // ensureProfileRecord writes an empty profile record to the user's PDS if they 529 + // don't already have one, serves as a marker record for tangled uers 530 + // 531 + // also helps inform onboarding state 532 + func (o *OAuth) ensureProfileRecord(did syntax.DID, sessionId string) { 533 + ctx := context.Background() 534 + l := o.Logger.With("did", did) 535 + 536 + didStr := did.String() 537 + if profile, err := db.GetProfile(o.Db, didStr); err != nil { 538 + l.Error("ensureProfileRecord: failed to read profile from db", "err", err) 539 + return 540 + } else if profile != nil { 541 + // already has a profile record, leave it untouched 542 + return 543 + } 544 + 545 + session, err := o.resumeSession(ctx, did, sessionId) 546 + if err != nil { 547 + l.Error("ensureProfileRecord: failed to resume session", "err", err) 548 + return 549 + } 550 + client := session.APIClient() 551 + 552 + _, err = comatproto.RepoPutRecord(ctx, client, &comatproto.RepoPutRecord_Input{ 553 + Collection: tangled.ActorProfileNSID, 554 + Repo: didStr, 555 + Rkey: "self", 556 + Record: &lexutil.LexiconTypeDecoder{ 557 + Val: &tangled.ActorProfile{}, 558 + }, 559 + }) 560 + if err != nil { 561 + l.Error("ensureProfileRecord: failed to write profile record", "err", err) 562 + return 563 + } 564 + 565 + // mirror to the local db so the appview reflects the record immediately 566 + if err := db.UpsertProfile(o.Db, &models.Profile{Did: didStr}); err != nil { 567 + l.Error("ensureProfileRecord: failed to upsert profile in db", "err", err) 568 + } 569 + 570 + l.Info("ensureProfileRecord: created empty profile record") 523 571 } 524 572 525 573 // getAppPasswordSession returns a cached AppPasswordSession, creating one if needed.